aboutsummaryrefslogtreecommitdiff
path: root/src/rule.h
blob: b7c0049f7fa75cd767195ea27ca56489ef4bf562 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#ifndef RULE_H
#define RULE_H

#include <list>
#include <string>
#include <stdint.h>
#include "regexp.h"
#include "staticstring.h"
#include "builder.h"

class Perform;

class Rule
{
public:
	enum Matches
	{
		matchOne,
		matchAll
	};

	enum ePerform
	{
		perfCommand
	};

public:
	Rule( const char *sName );
	virtual ~Rule();

	const char *getName()
	{
		return sName;
	}

	void debug();

	void addProduces( const char *sProduces );
	void setMatches( Matches how, const char *sWhat );
	void setPerforms( ePerform pwhat, const char *sPerfCmd );

	bool willChain( Rule *pRule );

	std::list<std::string> execute( class Builder &bld, std::list<std::string> lInput, std::list<Perform *> &lPerf, const char *sTarget=NULL );

private:
	class Perform *buildCommand( class Builder &bld, const char *sCmd, Builder::varmap *vars );
	std::list<std::string> findTargets( class Builder &bld, std::list<std::string> &lIn, std::string &sMatches, const char *sTarget );
	StaticString sName;
	std::list<std::string> lProduces;

	Matches mHow;
	RegExp rWhat;
	//StaticString sWhat;
	//regex_t rWhat;

	ePerform pHow;
	StaticString sPerfCmd;

	bool bNoProduces;
};

#endif