18 #ifndef CPCD_PARSER_HPP
19 #define CPCD_PARSER_HPP
22 #include "Properties.hpp"
23 #include "InputStream.hpp"
32 ndbout_c("%s:%d:%s", __FILE__, __LINE__, x);
54 InvalidArgumentFormat = 7,
55 UnknownArgumentType = 8,
56 CommandWithoutFunction = 9,
57 ArgumentGivenTwice = 10,
59 MissingMandatoryArgument = 12
71 char * m_currentToken;
72 STATIC_CONST(MaxParseBytes = 512);
73 char m_tokenBuffer[ MaxParseBytes ];
83 bool breakOnCommand =
false,
84 bool breakOnEmptyLine =
true,
85 bool breakOnInvalidArg =
false);
91 bool run(
Context &, T &,
volatile bool * stop = 0)
const;
99 bool getBreakOnCommand()
const;
100 void setBreakOnCommand(
bool v);
102 bool getBreakOnEmptyLine()
const;
103 void setBreakOnEmptyLine(
bool v);
105 bool getBreakOnInvalidArg()
const;
106 void setBreakOnInvalidArg(
bool v);
115 enum Type { Cmd, Arg, CmdAlias, ArgAlias };
117 enum ArgRequired { Mandatory, Optional };
118 enum ArgMinMax { CheckMinMax, IgnoreMinMax };
121 const char * realName;
124 ArgRequired argRequired;
130 const char * description;
145 bool b_cmd,
bool b_empty,
bool b_iarg);
159 bool m_breakOnInvalidArg;
165 bool b_cmd,
bool b_empty,
bool b_iarg){
167 b_cmd, b_empty, b_iarg);
181 DEBUG(
"Executing Parser<T>::run");
191 for(
unsigned i = 0;
i<ctx.m_aliasUsed.size();
i++){
193 if(alias->function != 0){
197 DEBUG(
"Alias usage with callback");
198 (t.* alias->function)(ctx, * p);
202 if(cmd->function == 0){
203 ctx.m_status = CommandWithoutFunction;
204 DEBUG(
"CommandWithoutFunction");
208 (t.* cmd->function)(ctx, * p);
221 volatile bool stop =
false;
222 DEBUG(
"Executing Parser<T>::parse");
233 for(
unsigned i = 0;
i<ctx.m_aliasUsed.size();
i++){
235 if(alias->function != 0){
239 DEBUG(
"Alias usage with callback");
240 (t.* alias->function)(ctx, * p);
244 if(cmd->function == 0){
245 DEBUG(
"CommandWithoutFunction");
246 ctx.m_status = CommandWithoutFunction;
259 return impl->m_breakOnCmd;
266 impl->m_breakOnCmd = v;
273 return impl->m_breakOnEmpty;
279 impl->m_breakOnEmpty = v;
286 return impl->m_breakOnInvalidArg;
293 impl->m_breakOnInvalidArg = v;