| CTPP2Compiler.hpp | | CTPP2Compiler.hpp | |
| | | | |
| skipping to change at line 133 | | skipping to change at line 133 | |
| @param szScopeName - ARRAY name | | @param szScopeName - ARRAY name | |
| @param iScopeNameLength - Length of ARRAY name | | @param iScopeNameLength - Length of ARRAY name | |
| @param oDebugInfo - debug information object | | @param oDebugInfo - debug information object | |
| @return instruction pointer if success, -1 if any error occured | | @return instruction pointer if success, -1 if any error occured | |
| */ | | */ | |
| INT_32 ChangeScope(CCHAR_P szScopeName, | | INT_32 ChangeScope(CCHAR_P szScopeName, | |
| const UINT_32 iScopeNameLength, | | const UINT_32 iScopeNameLength, | |
| const VMDebugInfo & oDebugInfo = VMDebugInfo()); | | const VMDebugInfo & oDebugInfo = VMDebugInfo()); | |
| | | | |
| /** | | /** | |
|
| @brief Change visibility scope of CDT data (for ARRAY iterating) | | | |
| @param szFullVariable - full variable name (ns + name) | | | |
| @param iFullVariableLength - full variable name length | | | |
| @param oDebugInfo - debug information object | | | |
| @return instruction pointer if success, -1 if any error occured | | | |
| */ | | | |
| INT_32 ChangeForeachScope(CCHAR_P szFullVariable, | | | |
| const UINT_32 iFullVariableLength, | | | |
| const VMDebugInfo & oDebugInfo); | | | |
| | | | |
| /** | | | |
| @brief Change visibility scope of CDT data (for ARRAY-of-ARRAYS it | | | |
| erating) | | | |
| @param oDebugInfo - debug information object | | | |
| @return instruction pointer if success, -1 if any error occured | | | |
| */ | | | |
| INT_32 ChangeContextScope(const VMDebugInfo & oDebugInfo); | | | |
| | | | |
| /** | | | |
| @brief Reset scope to previous CDT data (for ARRAY iterating) | | @brief Reset scope to previous CDT data (for ARRAY iterating) | |
| @param iIP - instruction pointer | | @param iIP - instruction pointer | |
| @param oDebugInfo - debug information object | | @param oDebugInfo - debug information object | |
| @return instruction pointer if success, -1 if any error occured | | @return instruction pointer if success, -1 if any error occured | |
| */ | | */ | |
| INT_32 ResetScope(const UINT_32 iIP, | | INT_32 ResetScope(const UINT_32 iIP, | |
| const VMDebugInfo & oDebugInfo = VMDebugInfo()); | | const VMDebugInfo & oDebugInfo = VMDebugInfo()); | |
| | | | |
| /** | | /** | |
|
| @brief Reset scope to previous CDT data (for ARRAY/FOREACH iterati | | | |
| ng) | | | |
| @param iIP - instruction pointer | | | |
| @param oDebugInfo - debug information object | | | |
| @return instruction pointer if success, -1 if any error occured | | | |
| */ | | | |
| INT_32 ResetForeachScope(const UINT_32 iIP, | | | |
| const VMDebugInfo & oDebugInfo = VMDebugIn | | | |
| fo()); | | | |
| | | | |
| /** | | | |
| @brief Execute system call such as HREF_PARAM, FORM_PARAM, etc | | @brief Execute system call such as HREF_PARAM, FORM_PARAM, etc | |
| @param szSyscallName - syscall name | | @param szSyscallName - syscall name | |
| @param iSyscallNameLength - Length of syscall name | | @param iSyscallNameLength - Length of syscall name | |
| @param iArgNum - number of arguments | | @param iArgNum - number of arguments | |
| @param oDebugInfo - debug information object | | @param oDebugInfo - debug information object | |
| @return instruction pointer if success, -1 if any error occured | | @return instruction pointer if success, -1 if any error occured | |
| */ | | */ | |
| INT_32 ExecuteSyscall(CCHAR_P szSyscallName, | | INT_32 ExecuteSyscall(CCHAR_P szSyscallName, | |
| const UINT_32 iSyscallNameLength, | | const UINT_32 iSyscallNameLength, | |
| const UINT_32 iArgNum, | | const UINT_32 iArgNum, | |
| | | | |
| skipping to change at line 203 | | skipping to change at line 176 | |
| INT_32 ClearPushComplexVariable(const VMDebugInfo & oDebugInfo); | | INT_32 ClearPushComplexVariable(const VMDebugInfo & oDebugInfo); | |
| | | | |
| /** | | /** | |
| @brief Push block's variable into stack | | @brief Push block's variable into stack | |
| @param iIdx - stack position | | @param iIdx - stack position | |
| @param oDebugInfo - debug information object | | @param oDebugInfo - debug information object | |
| @return instruction pointer if success, -1 if any error occured | | @return instruction pointer if success, -1 if any error occured | |
| */ | | */ | |
| INT_32 PushBlockVariable(const UINT_32 iIdx, | | INT_32 PushBlockVariable(const UINT_32 iIdx, | |
| const VMDebugInfo & oDebugInfo = VMDebugInf
o()); | | const VMDebugInfo & oDebugInfo = VMDebugInf
o()); | |
|
| | | | |
| | | /** | |
| | | @brief Prepare local scope for searching variable | |
| | | @param oDebugInfo - debug information object | |
| | | @return instruction pointer if success, -1 if any error occured | |
| | | */ | |
| | | INT_32 PrepareLocalScope(const VMDebugInfo & oDebugInfo = VMDebugInfo() | |
| | | ); | |
| | | | |
| /** | | /** | |
| @brief Push variable into stack | | @brief Push variable into stack | |
| @param szVariableName - variable name | | @param szVariableName - variable name | |
| @param iVariableNameLength - Length of variable name | | @param iVariableNameLength - Length of variable name | |
| @param oDebugInfo - debug information object | | @param oDebugInfo - debug information object | |
| @return instruction pointer if success, -1 if any error occured | | @return instruction pointer if success, -1 if any error occured | |
| */ | | */ | |
| INT_32 PushVariable(CCHAR_P szVariableName, | | INT_32 PushVariable(CCHAR_P szVariableName, | |
| const UINT_32 iVariableNameLength, | | const UINT_32 iVariableNameLength, | |
| const VMDebugInfo & oDebugInfo = VMDebugInfo())
; | | const VMDebugInfo & oDebugInfo = VMDebugInfo())
; | |
| | | | |
| /** | | /** | |
|
| @brief Push contextual variable into stack | | | |
| @param iTokenType - type of token | | | |
| @param oDebugInfo - debug information object | | | |
| @return instruction pointer if success, -1 if any error occured | | | |
| */ | | | |
| INT_32 PushContextualVariable(const eCTPP2LoopContextVar & iTokenTy | | | |
| pe, | | | |
| const VMDebugInfo & oDebugIn | | | |
| fo = VMDebugInfo()); | | | |
| | | | |
| /** | | | |
| @brief Push integer value into stack | | @brief Push integer value into stack | |
| @param iVariable - value to push | | @param iVariable - value to push | |
| @param oDebugInfo - debug information object | | @param oDebugInfo - debug information object | |
| @return instruction pointer if success, -1 if any error occured | | @return instruction pointer if success, -1 if any error occured | |
| */ | | */ | |
| INT_32 PushInt(const INT_64 & iVariable, | | INT_32 PushInt(const INT_64 & iVariable, | |
| const VMDebugInfo & oDebugInfo = VMDebugInfo()); | | const VMDebugInfo & oDebugInfo = VMDebugInfo()); | |
| | | | |
| /** | | /** | |
| @brief Push Float value into stack | | @brief Push Float value into stack | |
| | | | |
| skipping to change at line 289 | | skipping to change at line 261 | |
| @param iArgCount - number of arguments | | @param iArgCount - number of arguments | |
| @param oDebugInfo - debug information object | | @param oDebugInfo - debug information object | |
| @return instruction pointer if success, -1 if any error occured | | @return instruction pointer if success, -1 if any error occured | |
| */ | | */ | |
| INT_32 CallBlock(const STLW::string & sBlockName, | | INT_32 CallBlock(const STLW::string & sBlockName, | |
| const bool & bIsVariable, | | const bool & bIsVariable, | |
| const UINT_32 iArgCount, | | const UINT_32 iArgCount, | |
| const VMDebugInfo & oDebugInfo = VMDebugInfo()); | | const VMDebugInfo & oDebugInfo = VMDebugInfo()); | |
| | | | |
| /** | | /** | |
|
| @brief Call block by __CONTENT__ variable | | | |
| @param iArgCount - number of arguments | | | |
| @param oDebugInfo - debug information object | | | |
| @return instruction pointer if success, -1 if any error occured | | | |
| */ | | | |
| INT_32 CallContextBlock(const UINT_32 iArgCount, const VMDebugInfo & | | | |
| oDebugInfo = VMDebugInfo()); | | | |
| | | | |
| /** | | | |
| @brief Start of block | | @brief Start of block | |
| @param sBlockName - block name | | @param sBlockName - block name | |
| @param oDebugInfo - debug information object | | @param oDebugInfo - debug information object | |
| @return instruction pointer if success, -1 if any error occured | | @return instruction pointer if success, -1 if any error occured | |
| */ | | */ | |
| INT_32 StartBlock(const STLW::string & sBlockName, | | INT_32 StartBlock(const STLW::string & sBlockName, | |
| const VMDebugInfo & oDebugInfo = VMDebugInfo()); | | const VMDebugInfo & oDebugInfo = VMDebugInfo()); | |
| | | | |
| /** | | /** | |
| @brief End of block | | @brief End of block | |
| | | | |
| skipping to change at line 432 | | skipping to change at line 396 | |
| */ | | */ | |
| INT_32 StoreScopedVariable(CCHAR_P szNS, | | INT_32 StoreScopedVariable(CCHAR_P szNS, | |
| const UINT_32 iNSLength, | | const UINT_32 iNSLength, | |
| const VMDebugInfo & oDebugInfo); | | const VMDebugInfo & oDebugInfo); | |
| | | | |
| /** | | /** | |
| @brief Push variable into stack | | @brief Push variable into stack | |
| @param szVariableName - variable name | | @param szVariableName - variable name | |
| @param iVariableNameLength - variable name length | | @param iVariableNameLength - variable name length | |
| @param oDebugInfo - debug information object | | @param oDebugInfo - debug information object | |
|
| @param bNoPushVariable - don't push variable, but return 0 | | | |
| @return instruction pointer if success, -1 if any error occured | | @return instruction pointer if success, -1 if any error occured | |
| */ | | */ | |
| INT_32 PushScopedVariable(CCHAR_P szName, | | INT_32 PushScopedVariable(CCHAR_P szName, | |
| const UINT_32 iNameLength, | | const UINT_32 iNameLength, | |
| CCHAR_P szFullVariable, | | CCHAR_P szFullVariable, | |
| const UINT_32 iFullVariableLength, | | const UINT_32 iFullVariableLength, | |
|
| const VMDebugInfo & oDebugInfo, | | const VMDebugInfo & oDebugInfo); | |
| bool bNoPushVariable); | | | |
| | | | |
| /** | | /** | |
| @brief Push variable on stack into stack | | @brief Push variable on stack into stack | |
| @param iStackPos - stack position | | @param iStackPos - stack position | |
| @param oDebugInfo - debug information object | | @param oDebugInfo - debug information object | |
| @return instruction pointer if success, -1 if any error occured | | @return instruction pointer if success, -1 if any error occured | |
| */ | | */ | |
| INT_32 PushStackVariable(const INT_32 iStackPos, | | INT_32 PushStackVariable(const INT_32 iStackPos, | |
| const VMDebugInfo & oDebugInfo = VMDebugIn
fo()); | | const VMDebugInfo & oDebugInfo = VMDebugIn
fo()); | |
| | | | |
| | | | |
End of changes. 7 change blocks. |
| 53 lines changed or deleted | | 10 lines changed or added | |
|
| CTPP2Parser.hpp | | CTPP2Parser.hpp | |
| | | | |
| skipping to change at line 84 | | skipping to change at line 84 | |
| const INT_32 iIRecursionLevel = 0); | | const INT_32 iIRecursionLevel = 0); | |
| | | | |
| /** | | /** | |
| @brief Compile CTPP2 template | | @brief Compile CTPP2 template | |
| @param iHalt - if set to 1, add to end of code HLT instruction | | @param iHalt - if set to 1, add to end of code HLT instruction | |
| @return 0 if success, -1 if any error occured | | @return 0 if success, -1 if any error occured | |
| */ | | */ | |
| INT_32 Compile(const UINT_32 & iHalt = 1); | | INT_32 Compile(const UINT_32 & iHalt = 1); | |
| | | | |
| /** | | /** | |
|
| @brief Set parameter names translation map | | | |
| @param oIParamTranslationMap - translation map | | | |
| */ | | | |
| void SetParamMap(const IncludeMapType & oIParamTranslationMap); | | | |
| | | | |
| /** | | | |
| @brief A destructor | | @brief A destructor | |
| */ | | */ | |
| ~CTPP2Parser() throw(); | | ~CTPP2Parser() throw(); | |
| private: | | private: | |
| typedef STLW::map<STLW::string, UINT_32> BlockArgMapType; | | typedef STLW::map<STLW::string, UINT_32> BlockArgMapType; | |
| | | | |
| typedef STLW::map<STLW::string, UINT_32> BlockArgSizeMapType; | | typedef STLW::map<STLW::string, UINT_32> BlockArgSizeMapType; | |
| | | | |
| enum eCTPP2Operator { UNDEF = 0, | | enum eCTPP2Operator { UNDEF = 0, | |
| TMPL_var = 1, | | TMPL_var = 1, | |
| TMPL_if = 2, | | TMPL_if = 2, | |
| TMPL_unless = 3, | | TMPL_unless = 3, | |
| TMPL_else = 4, | | TMPL_else = 4, | |
| TMPL_elsif = 5, | | TMPL_elsif = 5, | |
|
| TMPL_loop = 6, | | // TMPL_loop = 6, // Obsolete | |
| TMPL_foreach = 7, | | TMPL_foreach = 7, | |
| TMPL_include = 8, | | TMPL_include = 8, | |
| TMPL_call = 9, | | TMPL_call = 9, | |
| TMPL_udf = 10, | | TMPL_udf = 10, | |
| TMPL_comment = 11, | | TMPL_comment = 11, | |
| TMPL_break = 12, | | TMPL_break = 12, | |
| TMPL_block = 13, | | TMPL_block = 13, | |
| TMPL_verbose = 14 }; | | TMPL_verbose = 14 }; | |
| | | | |
| enum eCTPP2ExprOperator { EXPR_UNDEF = 0, | | enum eCTPP2ExprOperator { EXPR_UNDEF = 0, | |
| | | | |
| skipping to change at line 166 | | skipping to change at line 160 | |
| CCHAR_P keyword; | | CCHAR_P keyword; | |
| /** keyword length */ | | /** keyword length */ | |
| UINT_32 keyword_length; | | UINT_32 keyword_length; | |
| /** keyword corresponding operator */ | | /** keyword corresponding operator */ | |
| eCTPP2Operator keyword_operator; | | eCTPP2Operator keyword_operator; | |
| }; | | }; | |
| /** Keywords table */ | | /** Keywords table */ | |
| static CTPP2Keyword aKeywords[]; | | static CTPP2Keyword aKeywords[]; | |
| | | | |
| /** | | /** | |
|
| @class CTPP2LoopKeyword CTPP2Parser.hpp <CTPP2Parser.hpp> | | | |
| @brief CTPP2 reserverd words for loops | | | |
| */ | | | |
| struct CTPP2LoopKeyword | | | |
| { | | | |
| /** keyword */ | | | |
| CCHAR_P keyword; | | | |
| /** keyword length */ | | | |
| UINT_32 keyword_length; | | | |
| /** keyword corresponding operator */ | | | |
| UINT_32 keyword_operator; | | | |
| }; | | | |
| | | | |
| /** Loop modifiers */ | | | |
| static CTPP2LoopKeyword aLoopKeywords []; | | | |
| | | | |
| /** | | | |
| @struct CTPP2Relation CTPP2Parser.hpp <CTPP2Parser.hpp> | | @struct CTPP2Relation CTPP2Parser.hpp <CTPP2Parser.hpp> | |
| @brief CTPP2 Relation | | @brief CTPP2 Relation | |
| */ | | */ | |
| struct CTPP2Relation | | struct CTPP2Relation | |
| { | | { | |
| /** keyword */ | | /** keyword */ | |
| CCHAR_P keyword; | | CCHAR_P keyword; | |
| /** keyword length */ | | /** keyword length */ | |
| UINT_32 keyword_length; | | UINT_32 keyword_length; | |
| /** keyword corresponding operator */ | | /** keyword corresponding operator */ | |
| eCTPP2Relation keyword_operator; | | eCTPP2Relation keyword_operator; | |
| }; | | }; | |
| | | | |
| /** Relations */ | | /** Relations */ | |
| static CTPP2Relation aCTPP2Relations []; | | static CTPP2Relation aCTPP2Relations []; | |
| | | | |
|
| /** | | | |
| @struct CTPP2LoopContextVar CTPP2Parser.hpp <CTPP2Parser.hpp> | | | |
| @brief CTPP2 Loop context variable | | | |
| */ | | | |
| struct CTPP2LoopContextVar | | | |
| { | | | |
| /** keyword */ | | | |
| CCHAR_P keyword; | | | |
| /** keyword length */ | | | |
| UINT_32 keyword_length; | | | |
| /** keyword corresponding operator */ | | | |
| eCTPP2LoopContextVar keyword_operator; | | | |
| }; | | | |
| | | | |
| /** Loop context variable */ | | | |
| static CTPP2LoopContextVar aLoopContextVars []; | | | |
| | | | |
| /** Current operator */ | | /** Current operator */ | |
| eCTPP2Operator eBreakFound; | | eCTPP2Operator eBreakFound; | |
| | | | |
| /** Temp. buffer */ | | /** Temp. buffer */ | |
| STLW::string sTMPBuf; | | STLW::string sTMPBuf; | |
| /** Parsed integer value */ | | /** Parsed integer value */ | |
| INT_64 iIntData; | | INT_64 iIntData; | |
| /** Parsed floating value */ | | /** Parsed floating value */ | |
| W_FLOAT dFloatData; | | W_FLOAT dFloatData; | |
| /** Type of parsed value */ | | /** Type of parsed value */ | |
| | | | |
| skipping to change at line 239 | | skipping to change at line 199 | |
| CTPP2SourceLoader * pSourceLoader; | | CTPP2SourceLoader * pSourceLoader; | |
| /** Compiler */ | | /** Compiler */ | |
| CTPP2Compiler * pCTPP2Compiler; | | CTPP2Compiler * pCTPP2Compiler; | |
| /** Syscalls */ | | /** Syscalls */ | |
| StaticText & oSyscalls; | | StaticText & oSyscalls; | |
| /** Static data segment */ | | /** Static data segment */ | |
| StaticData & oStaticData; | | StaticData & oStaticData; | |
| /** Static text segment */ | | /** Static text segment */ | |
| StaticText & oStaticText; | | StaticText & oStaticText; | |
| | | | |
|
| /** Translation map */ | | | |
| IncludeMapType oParamTranslationMap; | | | |
| | | | |
| /** Template source name */ | | /** Template source name */ | |
| STLW::string sSourceName; | | STLW::string sSourceName; | |
| /** Template source name ID */ | | /** Template source name ID */ | |
| UINT_32 iSourceNameId; | | UINT_32 iSourceNameId; | |
| /** Foreach flag */ | | /** Foreach flag */ | |
| bool bInForeach; | | bool bInForeach; | |
| /** Recursion level */ | | /** Recursion level */ | |
| INT_32 iRecursionLevel; | | INT_32 iRecursionLevel; | |
| /** Complex variable flag */ | | /** Complex variable flag */ | |
| bool bInsideComplexVariable; | | bool bInsideComplexVariable; | |
|
| /** No push variable on stack */ | | | |
| bool bNoPushVariable; | | | |
| /** No map variable */ | | | |
| bool bNoMapVariable; | | | |
| /** enable/disable verbose mode */ | | /** enable/disable verbose mode */ | |
| bool bVerboseMode; | | bool bVerboseMode; | |
| /** Block flag */ | | /** Block flag */ | |
| bool bInBlock; | | bool bInBlock; | |
| /** Current block arguments */ | | /** Current block arguments */ | |
| BlockArgMapType mCurrentBlock; | | BlockArgMapType mCurrentBlock; | |
| /** Map of number of arguments of blocks */ | | /** Map of number of arguments of blocks */ | |
| BlockArgSizeMapType mBlockArgSizes; | | BlockArgSizeMapType mBlockArgSizes; | |
| | | | |
|
| | | /** JMP points for TMPL_break */ | |
| | | STLW::vector<STLW::vector<INT_32> > vBreakJMPPoints; | |
| | | | |
| // Simple tokens: open and close tags, operators, variables, strings
and numbers //////////////////////////////////////////////////////////////
//////////////////// | | // Simple tokens: open and close tags, operators, variables, strings
and numbers //////////////////////////////////////////////////////////////
//////////////////// | |
| | | | |
| /** | | /** | |
| @brief Open tag ([Tt][Mm][Pp][Ll]) | | @brief Open tag ([Tt][Mm][Pp][Ll]) | |
| @param szData - current stream position | | @param szData - current stream position | |
| @param szEnd - end of stream position | | @param szEnd - end of stream position | |
| @return NULL if sequence not found or pointer to end of sequence | | @return NULL if sequence not found or pointer to end of sequence | |
| */ | | */ | |
| CCharIterator IsOpenTag(CCharIterator szData, CCharIterator szEnd); | | CCharIterator IsOpenTag(CCharIterator szData, CCharIterator szEnd); | |
| | | | |
| /** | | /** | |
| @brief Close tag (/[Tt][Mm][Pp][Ll]) | | @brief Close tag (/[Tt][Mm][Pp][Ll]) | |
| @param szData - current stream position | | @param szData - current stream position | |
| @param szEnd - end of stream position | | @param szEnd - end of stream position | |
| @return NULL if sequence not found or pointer to end of sequence | | @return NULL if sequence not found or pointer to end of sequence | |
| */ | | */ | |
| CCharIterator IsCloseTag(CCharIterator szData, CCharIterator szEnd); | | CCharIterator IsCloseTag(CCharIterator szData, CCharIterator szEnd); | |
| | | | |
| /** | | /** | |
|
| @brief Operator (var | if | else | unless | loop | foreach | udf |
comment | call | break) | | @brief Operator (var | if | else | unless | foreach | udf | commen
t | call | break) | |
| @param szData - current stream position | | @param szData - current stream position | |
| @param szEnd - end of stream position | | @param szEnd - end of stream position | |
| @param oOperatorType - operator type | | @param oOperatorType - operator type | |
| @return NULL if sequence not found or pointer to end of sequence | | @return NULL if sequence not found or pointer to end of sequence | |
| */ | | */ | |
| CCharIterator IsOperator(CCharIterator szData, CCharIterator szEnd,
eCTPP2Operator & oOperatorType); | | CCharIterator IsOperator(CCharIterator szData, CCharIterator szEnd,
eCTPP2Operator & oOperatorType); | |
| | | | |
| /** | | /** | |
| @brief Function [a-zA-Z_][a-zA-Z0-9_]( Expr [, Expr2 ... ] ) | | @brief Function [a-zA-Z_][a-zA-Z0-9_]( Expr [, Expr2 ... ] ) | |
| @param szData - current stream position | | @param szData - current stream position | |
| | | | |
| skipping to change at line 335 | | skipping to change at line 291 | |
| | | | |
| /** | | /** | |
| @brief CTPP2 string "blah-blah \" clah-clah " | 'blah-blah \' clah
-clah ' | | @brief CTPP2 string "blah-blah \" clah-clah " | 'blah-blah \' clah
-clah ' | |
| @param szData - current stream position | | @param szData - current stream position | |
| @param szEnd - end of stream position | | @param szEnd - end of stream position | |
| @return NULL if sequence not found or pointer to end of sequence | | @return NULL if sequence not found or pointer to end of sequence | |
| */ | | */ | |
| CCharIterator IsString(CCharIterator szData, CCharIterator szEnd); | | CCharIterator IsString(CCharIterator szData, CCharIterator szEnd); | |
| | | | |
| /** | | /** | |
|
| @brief CTPP2 old fashion string blah-blah.clah-clah | | | |
| @param szData - current stream position | | | |
| @param szEnd - end of stream position | | | |
| @return NULL if sequence not found or pointer to end of sequenc | | | |
| */ | | | |
| CCharIterator IsStringCompatOldVersion(CCharIterator szData, CCharIt | | | |
| erator szEnd); | | | |
| | | | |
| /** | | | |
| @brief Number [-]0-9[. [0-9] ] [E [+-] 0-9] | | @brief Number [-]0-9[. [0-9] ] [E [+-] 0-9] | |
| @param szData - current stream position | | @param szData - current stream position | |
| @param szEnd - end of stream position | | @param szEnd - end of stream position | |
| @return NULL if sequence not found or pointer to end of sequence | | @return NULL if sequence not found or pointer to end of sequence | |
| */ | | */ | |
| CCharIterator IsNum(CCharIterator szData, CCharIterator szEnd); | | CCharIterator IsNum(CCharIterator szData, CCharIterator szEnd); | |
| | | | |
| /** | | /** | |
| @brief Parse Float value | | @brief Parse Float value | |
| @param szData - current stream position | | @param szData - current stream position | |
| @param szEnd - end of stream position | | @param szEnd - end of stream position | |
| */ | | */ | |
| void ParseFloat(CCharIterator & szData, CCharIterator & szEnd); | | void ParseFloat(CCharIterator & szData, CCharIterator & szEnd); | |
| | | | |
| /** | | /** | |
|
| @brief CTPP2 Loop contextual variable (__first__ | __last__ | __in | | | |
| ner__ | __odd__ | __even__ | __counter__ | __size__ ) | | | |
| @param szData - current stream position | | | |
| @param szEnd - end of stream position | | | |
| @param eContextVariable - contextual variable that was found | | | |
| @return NULL if sequence not found or pointer to end of sequence | | | |
| */ | | | |
| CCharIterator IsContextVar(CCharIterator szData, CCharIterator szEnd | | | |
| , eCTPP2LoopContextVar & eContextVariable); | | | |
| | | | |
| /** | | | |
| @brief Loop operator keyword (__global_vars__ | __context_vars__ | | | | |
| __no_global_vars__ | __no_context_vars__ ) | | | |
| @param szData - current stream position | | | |
| @param szEnd - end of stream position | | | |
| @param iLoopKeyword - keyword name | | | |
| @return NULL if sequence not found or pointer to end of sequence | | | |
| */ | | | |
| CCharIterator IsLoopKeyword(CCharIterator szData, CCharIterator szEn | | | |
| d, UINT_32 & iLoopKeyword); | | | |
| | | | |
| /** | | | |
| @brief Foreach operator keyword (as) | | @brief Foreach operator keyword (as) | |
| @param szData - current stream position | | @param szData - current stream position | |
| @param szEnd - end of stream position | | @param szEnd - end of stream position | |
| @return NULL if sequence not found or pointer to end of sequence | | @return NULL if sequence not found or pointer to end of sequence | |
| */ | | */ | |
| CCharIterator IsForeachKeyword(CCharIterator szData, CCharIterator s
zEnd); | | CCharIterator IsForeachKeyword(CCharIterator szData, CCharIterator s
zEnd); | |
| | | | |
| /** | | /** | |
| @brief White space (Tab | ' ') | | @brief White space (Tab | ' ') | |
| @param szData - current stream position | | @param szData - current stream position | |
| | | | |
| skipping to change at line 523 | | skipping to change at line 453 | |
| /** | | /** | |
| @brief CTPP2 reverse branch expression; <TMPL_unless UnlessExpr
> | | @brief CTPP2 reverse branch expression; <TMPL_unless UnlessExpr
> | |
| @param szData - current stream position | | @param szData - current stream position | |
| @param szEnd - end of stream position | | @param szEnd - end of stream position | |
| @param eResultOperator - Result operand of expression | | @param eResultOperator - Result operand of expression | |
| @return NULL if sequence not found or pointer to end of sequence | | @return NULL if sequence not found or pointer to end of sequence | |
| */ | | */ | |
| CCharIterator IsUnlessExpr(CCharIterator szData, CCharIterator szEnd
, eCTPP2ExprOperator & eResultOperator); | | CCharIterator IsUnlessExpr(CCharIterator szData, CCharIterator szEnd
, eCTPP2ExprOperator & eResultOperator); | |
| | | | |
| /** | | /** | |
|
| @brief CTPP2 loop expression; <TMPL_loop LoopExpr> | | | |
| @param szData - current stream position | | | |
| @param szEnd - end of stream position | | | |
| @param iRetPoint - return point instruction number [out] | | | |
| @return NULL if sequence not found or pointer to end of sequence | | | |
| */ | | | |
| CCharIterator IsLoopExpr(CCharIterator szData, CCharIterator szEnd, | | | |
| UINT_32 & iRetPoint); | | | |
| | | | |
| /** | | | |
| @brief Foreach expression <TMPL_loop ForeachExpr> | | @brief Foreach expression <TMPL_loop ForeachExpr> | |
| @param szData - current stream position | | @param szData - current stream position | |
| @param szEnd - end of stream position | | @param szEnd - end of stream position | |
| @param iRetPoint - return point instruction number [out] | | @param iRetPoint - return point instruction number [out] | |
| @return NULL if sequence not found or pointer to end of sequence | | @return NULL if sequence not found or pointer to end of sequence | |
| */ | | */ | |
| CCharIterator IsForeachExpr(CCharIterator szData, CCharIterator szEn
d, UINT_32 & iRetPoint); | | CCharIterator IsForeachExpr(CCharIterator szData, CCharIterator szEn
d, UINT_32 & iRetPoint); | |
| | | | |
|
| /** | | | |
| @brief Break expression; <TMPL_break BreakExpr> | | | |
| @param szData - current stream position | | | |
| @param szEnd - end of stream position | | | |
| @param iRetPoint - return point instruction number | | | |
| @return NULL if sequence not found or pointer to end of sequence | | | |
| */ | | | |
| CCharIterator IsBreakExpr(CCharIterator szData, CCharIterator szEnd, | | | |
| UINT_32 & iRetPoint); | | | |
| | | | |
| // Operators ///////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
//////////////////// | | // Operators ///////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
//////////////////// | |
| | | | |
| /** | | /** | |
| @brief Variable/Function/Exression output operator<TMPL_var Exp
r> | | @brief Variable/Function/Exression output operator<TMPL_var Exp
r> | |
| @param szData - current stream position | | @param szData - current stream position | |
| @param szEnd - end of stream position | | @param szEnd - end of stream position | |
| @return NULL if sequence not found or pointer to end of sequence | | @return NULL if sequence not found or pointer to end of sequence | |
| */ | | */ | |
| CCharIterator VarOperator(CCharIterator szData, CCharIterator szEnd)
; | | CCharIterator VarOperator(CCharIterator szData, CCharIterator szEnd)
; | |
| | | | |
| | | | |
| skipping to change at line 576 | | skipping to change at line 488 | |
| | | | |
| /** | | /** | |
| @brief Reverse branch operator <TMPL_unless IfExpr> blah-bla
h-blah [ <TMPL_else> clah-clah-clah ] </TMPL_unless> | | @brief Reverse branch operator <TMPL_unless IfExpr> blah-bla
h-blah [ <TMPL_else> clah-clah-clah ] </TMPL_unless> | |
| @param szData - current stream position | | @param szData - current stream position | |
| @param szEnd - end of stream position | | @param szEnd - end of stream position | |
| @return NULL if sequence not found or pointer to end of sequence | | @return NULL if sequence not found or pointer to end of sequence | |
| */ | | */ | |
| CCharIterator UnlessOperator(CCharIterator szData, CCharIterator szE
nd); | | CCharIterator UnlessOperator(CCharIterator szData, CCharIterator szE
nd); | |
| | | | |
| /** | | /** | |
|
| @brief Loop operator <TMPL_loop Expr> blah-blah-blah </TMP | | | |
| L_loop> | | | |
| @param szData - current stream position | | | |
| @param szEnd - end of stream position | | | |
| @return NULL if sequence not found or pointer to end of sequence | | | |
| */ | | | |
| CCharIterator LoopOperator(CCharIterator szData, CCharIterator szEnd | | | |
| ); | | | |
| | | | |
| /** | | | |
| @brief Foreach operator <TMPL_foreach var_array as var> blah
-blah-blah </TMPL_foreach> | | @brief Foreach operator <TMPL_foreach var_array as var> blah
-blah-blah </TMPL_foreach> | |
| @param szData - current stream position | | @param szData - current stream position | |
| @param szEnd - end of stream position | | @param szEnd - end of stream position | |
| @return NULL if sequence not found or pointer to end of sequence | | @return NULL if sequence not found or pointer to end of sequence | |
| */ | | */ | |
| CCharIterator ForeachOperator(CCharIterator szData, CCharIterator sz
End); | | CCharIterator ForeachOperator(CCharIterator szData, CCharIterator sz
End); | |
| | | | |
| /** | | /** | |
| @brief Include operator <TMPL_include Expr> | | @brief Include operator <TMPL_include Expr> | |
| @param szData - current stream position | | @param szData - current stream position | |
| | | | |
| skipping to change at line 631 | | skipping to change at line 535 | |
| CCharIterator BlockOperator(CCharIterator szData, CCharIterator szEn
d); | | CCharIterator BlockOperator(CCharIterator szData, CCharIterator szEn
d); | |
| | | | |
| /** | | /** | |
| @brief Ignore spaces <TMPL_verbose> ..... </TMPL_verbose&g
t; | | @brief Ignore spaces <TMPL_verbose> ..... </TMPL_verbose&g
t; | |
| @param szData - current stream position | | @param szData - current stream position | |
| @param szEnd - end of stream position | | @param szEnd - end of stream position | |
| @return NULL if sequence not found or pointer to end of sequence | | @return NULL if sequence not found or pointer to end of sequence | |
| */ | | */ | |
| CCharIterator VerboseOperator(CCharIterator szData, CCharIterator sz
End); | | CCharIterator VerboseOperator(CCharIterator szData, CCharIterator sz
End); | |
| | | | |
|
| | | /** | |
| | | @brief Break operator; <TMPL_break> | |
| | | @param szData - current stream position | |
| | | @param szEnd - end of stream position | |
| | | @return NULL if sequence not found or pointer to end of sequence | |
| | | */ | |
| | | CCharIterator BreakOperator(CCharIterator szData, CCharIterator szEn | |
| | | d); | |
| // Other stuff /////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
//////////////////// | | // Other stuff /////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
//////////////////// | |
| | | | |
| /** | | /** | |
| @brief Parse CTPP2 template | | @brief Parse CTPP2 template | |
| @param szData - template start | | @param szData - template start | |
| @param szEnd - template end | | @param szEnd - template end | |
| @return 0 if success, -1 if any error occured | | @return 0 if success, -1 if any error occured | |
| */ | | */ | |
| CCharIterator Parse(CCharIterator szData, CCharIterator szEnd); | | CCharIterator Parse(CCharIterator szData, CCharIterator szEnd); | |
| | | | |
| /** | | /** | |
|
| @brief CTPP2 include map: map { a:b, c:d } | | | |
| @param szData - current stream position | | | |
| @param szEnd - end of stream position | | | |
| @param oIncludeTranslationMap - translation map | | | |
| @return NULL if sequence not found or pointer to end of sequence | | | |
| */ | | | |
| CCharIterator IncludeMap(CCharIterator szData, | | | |
| CCharIterator szEnd, | | | |
| IncludeMapType & oIncludeTranslationMap); | | | |
| | | | |
| /** | | | |
| @brief Store comparison result (if branch) | | @brief Store comparison result (if branch) | |
| @param szData - current position in stream | | @param szData - current position in stream | |
| @param eResultOperator - type of parsed expression | | @param eResultOperator - type of parsed expression | |
| @return instruction pointer to JMP or JXX instrution | | @return instruction pointer to JMP or JXX instrution | |
| */ | | */ | |
| UINT_32 StoreIfComparisonResult(CCharIterator szData, const eCTPP2Ex
prOperator & eResultOperator); | | UINT_32 StoreIfComparisonResult(CCharIterator szData, const eCTPP2Ex
prOperator & eResultOperator); | |
| | | | |
| /** | | /** | |
| @brief Store comparison result (unless branch) | | @brief Store comparison result (unless branch) | |
| @param szData - current position in stream | | @param szData - current position in stream | |
| @param eResultOperator - type of parsed expression | | @param eResultOperator - type of parsed expression | |
| @return instruction pointer to JMP or JXX instrution | | @return instruction pointer to JMP or JXX instrution | |
| */ | | */ | |
| UINT_32 StoreUnlessComparisonResult(CCharIterator szData, const eCTP
P2ExprOperator & eResultOperator); | | UINT_32 StoreUnlessComparisonResult(CCharIterator szData, const eCTP
P2ExprOperator & eResultOperator); | |
| | | | |
| /** | | /** | |
|
| @brief Check translation map | | | |
| @param sParam - parameter to check | | | |
| */ | | | |
| void CheckParamMap(STLW::string & sParam); | | | |
| | | | |
| /** | | | |
| @brief Get printable operator name | | @brief Get printable operator name | |
| @param oOperator operator type | | @param oOperator operator type | |
| @return printable operator name | | @return printable operator name | |
| */ | | */ | |
| CCHAR_P GetOperatorName(const eCTPP2Operator & oOperator); | | CCHAR_P GetOperatorName(const eCTPP2Operator & oOperator); | |
| | | | |
| /** | | /** | |
| @brief Check trailing newline flag | | @brief Check trailing newline flag | |
| @param szData - current stream position | | @param szData - current stream position | |
| @param szEnd - end of stream position | | @param szEnd - end of stream position | |
| | | | |
End of changes. 16 change blocks. |
| 127 lines changed or deleted | | 13 lines changed or added | |
|
| CTPP2Util.hpp | | CTPP2Util.hpp | |
| | | | |
| skipping to change at line 47 | | skipping to change at line 47 | |
| @file CTPP2Util.hpp | | @file CTPP2Util.hpp | |
| @brief CTPP2 useful utilities | | @brief CTPP2 useful utilities | |
| */ | | */ | |
| | | | |
| namespace CTPP // C++ Template Engine | | namespace CTPP // C++ Template Engine | |
| { | | { | |
| // FWD | | // FWD | |
| class CDT; | | class CDT; | |
| | | | |
| /** | | /** | |
|
| | | @class DumpBuffer CTPP2Util.hpp <CTPP2Util.hpp> | |
| | | @brief Buffer for dumping CDTs. Used as an alternative for std::string (a | |
| | | s string's append is quite slow) | |
| | | */ | |
| | | class DumpBuffer { | |
| | | public: | |
| | | /** | |
| | | @var typedef UINT_32 StreamSize | |
| | | @brief internal size_t analog | |
| | | */ | |
| | | typedef UINT_32 StreamSize; | |
| | | | |
| | | /** | |
| | | @brief Constructor | |
| | | */ | |
| | | DumpBuffer(); | |
| | | | |
| | | /** | |
| | | @brief Destructor | |
| | | */ | |
| | | ~DumpBuffer(); | |
| | | | |
| | | /** | |
| | | @brief Appends data to the buffer | |
| | | @param data - ponter to data to append | |
| | | @param n - number of bytes to append | |
| | | */ | |
| | | void Write(CCHAR_P pData , StreamSize iSize); | |
| | | | |
| | | /** | |
| | | @brief Returns pointer to buffer's start | |
| | | @return Pointer to buffer's start | |
| | | */ | |
| | | CCHAR_P Data() const; | |
| | | | |
| | | /** | |
| | | @brief Returns number of bytes available in buffer | |
| | | @return Number of bytes available in buffer | |
| | | */ | |
| | | StreamSize Size() const; | |
| | | | |
| | | private: | |
| | | /** | |
| | | @brief Reallocates buffer if necessary | |
| | | @param n - new capacity (if it's less then current capacity, metho | |
| | | d does nothing) | |
| | | */ | |
| | | void Reserve(StreamSize iSize); | |
| | | | |
| | | CHAR_P pBuffer; | |
| | | CHAR_P pPos; | |
| | | | |
| | | StreamSize iCapacity; | |
| | | }; | |
| | | | |
| | | /** | |
| @fn UINT_32 crc32(UCCHAR_P sBuffer, const UINT_32 & iSize) | | @fn UINT_32 crc32(UCCHAR_P sBuffer, const UINT_32 & iSize) | |
| @brief Calculate crc32 checksum | | @brief Calculate crc32 checksum | |
| @param sBuffer - buffer with source data to calculate CRC | | @param sBuffer - buffer with source data to calculate CRC | |
| @param iSize - buffer size | | @param iSize - buffer size | |
| @return CRC32 checksum | | @return CRC32 checksum | |
| */ | | */ | |
| UINT_32 crc32(UCCHAR_P sBuffer, const UINT_32 & iSize); | | UINT_32 crc32(UCCHAR_P sBuffer, const UINT_32 & iSize); | |
| | | | |
| /** | | /** | |
| @fn UINT_32 Swap32(const UINT_32 & iValue) | | @fn UINT_32 Swap32(const UINT_32 & iValue) | |
| | | | |
| skipping to change at line 120 | | skipping to change at line 174 | |
| | | | |
| /** | | /** | |
| @fn void CDT2JSON(const CTPP::CDT & oCDT, STLW::string & sData) | | @fn void CDT2JSON(const CTPP::CDT & oCDT, STLW::string & sData) | |
| @brief Dump CDT to JSON | | @brief Dump CDT to JSON | |
| @param oCDT - input data | | @param oCDT - input data | |
| @param sData - output string | | @param sData - output string | |
| */ | | */ | |
| void CDT2JSON(const CDT & oCDT, STLW::string & sData); | | void CDT2JSON(const CDT & oCDT, STLW::string & sData); | |
| | | | |
| /** | | /** | |
|
| | | @fn void DumpCDT2JSON(const CTPP::CDT & oCDT, DumpBuffer & oBuffer) | |
| | | @brief Dump CDT to JSON | |
| | | @param oCDT - input data | |
| | | @param oBuffer - buffer to dump CDT to | |
| | | @return reference to oBuffer | |
| | | */ | |
| | | DumpBuffer & DumpCDT2JSON(const CTPP::CDT & oCDT, DumpBuffer & oBuffer); | |
| | | | |
| | | /** | |
| @brief Escape string, if need | | @brief Escape string, if need | |
| @param sSource - input data | | @param sSource - input data | |
| @param bECMAConventions - use ECMA-262 conventions for escape sequences | | @param bECMAConventions - use ECMA-262 conventions for escape sequences | |
| @return Escaped string | | @return Escaped string | |
| */ | | */ | |
| STLW::string EscapeJSONString(const STLW::string & sSource, | | STLW::string EscapeJSONString(const STLW::string & sSource, | |
| const bool & bECMAConventions = true
, | | const bool & bECMAConventions = true
, | |
| const bool & bHTMLSafe = true); | | const bool & bHTMLSafe = true); | |
| | | | |
| /** | | /** | |
|
| | | @brief Escape and dump string to buffer | |
| | | @param oBuffer - buffer to dump string to | |
| | | @param sSource - input data | |
| | | @param bECMAConventions - use ECMA-262 conventions for escape sequences | |
| | | @return reference to oBuffer | |
| | | */ | |
| | | DumpBuffer & DumpJSONString(DumpBuffer& oBuffer, | |
| | | const STLW::string & sSource, | |
| | | const bool & bECMAConventions = true, | |
| | | const bool & bHTMLSafe = true); | |
| | | | |
| | | /** | |
| @fn STLW::string Base64Encode(const STLW::string & sData); | | @fn STLW::string Base64Encode(const STLW::string & sData); | |
| @brief Encode value in BASE64 encoding | | @brief Encode value in BASE64 encoding | |
| @param sData - value to encode | | @param sData - value to encode | |
| @return Encoded value | | @return Encoded value | |
| */ | | */ | |
| STLW::string Base64Encode(const STLW::string & sData); | | STLW::string Base64Encode(const STLW::string & sData); | |
| | | | |
| /** | | /** | |
| @fn STLW::string Base64Decode(const STLW::string & sData); | | @fn STLW::string Base64Decode(const STLW::string & sData); | |
| @brief Decode value from BASE64 encoding | | @brief Decode value from BASE64 encoding | |
| | | | |
End of changes. 3 change blocks. |
| 0 lines changed or deleted | | 77 lines changed or added | |
|