00001 #ifndef _RULECONTEXT_H_
00002 #define _RULECONTEXT_H_
00003
00004 #include "stree.h"
00005 #include "rtree.h"
00006 #include "namespace.h"
00007
00008 #define MAINCONTEXTNAME "main"
00009
00011
00015 class RuleContext{
00016 protected:
00018 RuleList &rules;
00019
00020 private:
00021
00023
00028 list<RuleList::iterator> myRules;
00029
00031
00033
00041 bool executeOnPHP(List* phpIn, List* phpOut, List* tplOut);
00042
00044 void executeOnPHPList(List* phpIn, List *phpOut, List *tplOut);
00045
00047 void processSmartyAssignInPhpList(List* phpList);
00048
00049 protected:
00051 NameSpace &nameSpace;
00052
00053 public:
00054
00056 RuleContext(RuleList &irules, NameSpace &inameSpace);
00057
00059 virtual ~RuleContext();
00060
00062 void insert(int priority, Rule *rule);
00063
00065 void insert(PriorityRulePair *rulePair);
00066
00068
00075 void execute(Node* phpIn,List *phpOut, List *tplOut);
00076
00078 void assignVariableNames(List *phpList, List *tplList);
00079
00081 virtual void generateVariableNames(const Node::VariableList &vlist, Node::Assignment &phpAssign, Node::Assignment &tplAssign) = 0;
00082
00084 virtual const string generateVariableName() = 0;
00085
00087 virtual void processSmartyAssign(SmartyAssign *smartyAssign) = 0;
00088
00090 virtual void enterContext(List *phpOut, List *tplOut);
00092
00095 virtual void leaveContext(List *phpOut, List *tplOut);
00096
00098 virtual void registerSmartyVariable(const string &variable) = 0;
00099
00101
00105 virtual const string getVariableNameSufix(const bool stripControlVariableDollar) = 0;
00107 virtual const string getVariableNamePrefix() = 0;
00108
00110 virtual void processTemplate(Node* tpl) const = 0;
00111
00113 NameSpace& getNameSpace() const { return nameSpace; };
00114
00115 friend class MultiContext;
00116 friend class SingleContext;
00117 };
00118
00119 #endif
00120
00121
00122