Version: 8.3.0
YACS::parser Struct Reference

#include <parserBase.hxx>

Inheritance diagram for YACS::parser:
Collaboration diagram for YACS::parser:

Public Member Functions

 parser ()
 
virtual ~parser ()
 
virtual void SetUserDataAndPush (parser *pp)
 
virtual void onStart (const XML_Char *el, const XML_Char **attr)
 
virtual void onEnd (const XML_Char *el, parser *child)
 
virtual void charData (const XML_Char *s, int len)
 
virtual void endParser ()
 
virtual void init ()
 
virtual void incrCount (const XML_Char *elem)
 
virtual void checkOrder (std::string &el)
 
virtual void maxcount (std::string name, int max, std::string &el)
 
virtual void mincount (std::string name, int min)
 
virtual void maxchoice (std::string *names, int max, std::string &el)
 
virtual void minchoice (std::string *names, int min)
 
virtual void pre ()
 
virtual void required (const std::string &name, const XML_Char **attr)
 
virtual void buildAttr (const XML_Char **attr)
 
std::stack< parser * > & getStack ()
 
template<class T >
post ()
 
void logError (const std::string &reason)
 

Static Public Member Functions

static void XMLCALL start_document (void *data)
 
static void XMLCALL end_document (void *data)
 
static void XMLCALL start_element (void *data, const xmlChar *name, const xmlChar **p)
 
static void XMLCALL end_element (void *data, const xmlChar *name)
 
static void XMLCALL characters (void *data, const xmlChar *ch, int len)
 
static void XMLCALL comment (void *data, const xmlChar *value)
 
static void XMLCALL cdata_block (void *data, const xmlChar *value, int len)
 
static void XMLCALL warning (void *data, const char *fmt,...)
 
static void XMLCALL error (void *data, const char *fmt,...)
 
static void XMLCALL fatal_error (void *data, const char *fmt,...)
 
static void XML_SetUserData (_xmlParserCtxt *ctxt, parser *par)
 

Public Attributes

std::string _file
 
std::string _content
 
std::map< std::string, int > * _counts
 
std::map< std::string, int > _orders
 
int _orderState
 
int _level
 
std::stack< std::map
< std::string, int > * > 
_stackCount
 
std::stack< int > _stackOrder
 
std::map< std::string, parser * > * _defaultParsersMap
 

Static Public Attributes

static parser main_parser
 
static std::stack< parser * > _stackParser
 

Detailed Description

Definition at line 39 of file parserBase.hxx.

Constructor & Destructor Documentation

YACS::parser::parser ( )
inline

Definition at line 44 of file parserBase.hxx.

45  {
46  _counts=new std::map<std::string,int>;
47  }
YACS::parser::~parser ( )
virtual

Definition at line 38 of file parserBase.cxx.

References _counts, _level, and DEBTRACE.

39 {
40  if(_level==0)
41  {
42  delete _counts;
43  }
44  else
45  {
46  DEBTRACE("Problem with parser: final stack level should be 0 and not " << _level);
47  }
48 }

Member Function Documentation

void YACS::parser::buildAttr ( const XML_Char **  attr)
virtual

Reimplemented in YACS::optimizerlooptypeParser< T >, YACS::foreachlooptypeParser< T >, YACS::pseudocomposednodetypeParser< T >, YACS::forlooptypeParser< T >, YACS::structtypeParser, YACS::presettypeParser< T >, YACS::HMI::presentationtype_parser, YACS::membertypeParser, YACS::outnodetypeParser< T >, YACS::linktypeParser< T >, YACS::objtypeParser, YACS::loadtypeParser, YACS::switchtypeParser, YACS::bloctypeParser< T >, YACS::defaultcasetypeParser, YACS::functypeParser, YACS::seqtypeParser, YACS::nodetypeParser< T >, YACS::containertypeParser, YACS::inlinetypeParser< T >, YACS::presetdatatypeParser, YACS::outputdatatypeParser, YACS::casetypeParser, YACS::inporttypeParser< T >, YACS::proctypeParser< T >, YACS::looptypeParser< T >, YACS::componentinstancetypeParser, YACS::propertytypeParser, YACS::typetypeParser, and YACS::machinetypeParser.

Definition at line 195 of file parserBase.cxx.

References DEBTRACE, and CORBAEngineTest::i.

Referenced by YACS::roottypeParser::onStart(), YACS::remotetypeParser< T >::onStart(), YACS::controltypeParser< T >::onStart(), YACS::servertypeParser< T >::onStart(), YACS::codetypeParser::onStart(), YACS::sinlinetypeParser< T >::onStart(), YACS::presetdatatypeParser::onStart(), YACS::outputdatatypeParser::onStart(), YACS::componentinstancetypeParser::onStart(), YACS::proctypeParser< T >::onStart(), YACS::looptypeParser< T >::onStart(), onStart(), YACS::inporttypeParser< T >::onStart(), YACS::valuetypeParser::onStart(), YACS::casetypeParser::onStart(), YACS::inlinetypeParser< T >::onStart(), YACS::servicetypeParser< T >::onStart(), YACS::nodetypeParser< T >::onStart(), YACS::containertypeParser::onStart(), YACS::seqtypeParser::onStart(), YACS::datatypeParser::onStart(), YACS::bloctypeParser< T >::onStart(), YACS::linktypeParser< T >::onStart(), YACS::switchtypeParser::onStart(), YACS::objtypeParser::onStart(), YACS::memberdatatypeParser::onStart(), YACS::outnodetypeParser< T >::onStart(), YACS::HMI::presentationtype_parser::onStart(), YACS::structdatatypeParser::onStart(), YACS::presettypeParser< T >::onStart(), YACS::arraytypeParser::onStart(), YACS::structtypeParser::onStart(), YACS::parametertypeParser::onStart(), and YACS::dynparalooptypeParser< T >::onStart().

196 {
197  if (!attr)
198  return;
199  for (int i = 0; attr[i]; i += 2)
200  {
201  DEBTRACE(attr[i] << "=" << attr[i + 1]);
202  }
203 }
void XMLCALL YACS::parser::cdata_block ( void *  data,
const xmlChar *  value,
int  len 
)
static

Definition at line 275 of file parserBase.cxx.

References charData(), and DEBTRACE.

Referenced by YACS::YACSLoader::load().

278 {
279  DEBTRACE("parser::cdata_block");
280  parser *currentParser = static_cast<parser *> (data);
281  currentParser->charData((const XML_Char*) value, len);
282 }
void XMLCALL YACS::parser::characters ( void *  data,
const xmlChar *  ch,
int  len 
)
static

Definition at line 259 of file parserBase.cxx.

References charData(), and DEBTRACE.

Referenced by YACS::YACSLoader::load().

262 {
263  DEBTRACE("parser::characters " << len);
264  parser *currentParser = (parser *) (data);
265  currentParser->charData((const XML_Char*) ch, len);
266 }
void YACS::parser::charData ( const XML_Char s,
int  len 
)
virtual

Definition at line 67 of file parserBase.cxx.

References _content.

Referenced by cdata_block(), and characters().

68 {
69  _content=_content+std::string(s,len);
70 }
void YACS::parser::checkOrder ( std::string &  el)
virtual

Definition at line 108 of file parserBase.cxx.

References _orders, and _orderState.

109 {
110  if(_orders.count(el)==0)return;
111  if(_orders[el] < _orderState)
112  {
113  std::string msg="unexpected "+el+" element (wrong order)";
114  throw YACS::Exception(msg);
115  }
116  else if(_orders[el] > _orderState)
117  {
118  _orderState=_orders[el];
119  }
120 }
void XMLCALL YACS::parser::comment ( void *  data,
const xmlChar *  value 
)
static

Definition at line 268 of file parserBase.cxx.

References DEBTRACE.

Referenced by YACS::YACSLoader::load().

270 {
271  DEBTRACE("parser::comment");
272  parser *currentParser = static_cast<parser *> (data);
273 }
void XMLCALL YACS::parser::end_document ( void *  data)
static

Definition at line 231 of file parserBase.cxx.

References DEBTRACE.

Referenced by YACS::YACSLoader::load().

232 {
233  DEBTRACE("parser::end_document");
234  parser *currentParser = static_cast<parser *> (data);
235 }
void XMLCALL YACS::parser::end_element ( void *  data,
const xmlChar *  name 
)
static

Definition at line 247 of file parserBase.cxx.

References _stackParser, DEBTRACE, endParser(), onEnd(), saxContext, and XML_SetUserData().

Referenced by YACS::YACSLoader::load().

249 {
250  DEBTRACE("parser::end_element");
251  parser *childParser = static_cast<parser *> (data);
252  _stackParser.pop();
253  parser* pp=_stackParser.top();
255  pp->onEnd((const XML_Char *)name, childParser);
256  childParser->endParser();
257  }
void YACS::parser::endParser ( )
virtual

Definition at line 72 of file parserBase.cxx.

References _counts, _level, _orderState, _stackCount, _stackOrder, and DEBTRACE.

Referenced by end_element().

73 {
74  DEBTRACE("parser::endParser, level: " <<_level);
75  _level=_level-1;
76  if(_level>0)
77  {
78  delete _counts;
79  _counts=_stackCount.top();
81  _stackCount.pop();
82  _stackOrder.pop();
83  }
84 }
void XMLCALL YACS::parser::error ( void *  data,
const char *  fmt,
  ... 
)
static

Definition at line 303 of file parserBase.cxx.

References DEBTRACE.

Referenced by YACS::YACSLoader::load().

305 {
306  DEBTRACE("parser::error");
307  parser *currentParser = static_cast<parser *> (data);
308  va_list args;
309  va_start(args, fmt);
310  std::string format = "%s";
311  if (format == fmt)
312  {
313  char* parv;
314  parv = va_arg(args, char*);
315  std::cerr << parv ;
316  }
317  else std::cerr << __FILE__ << " [" << __LINE__ << "] : "
318  << "error format not taken into account: " << fmt << std::endl;
319  va_end(args);
320 }
void XMLCALL YACS::parser::fatal_error ( void *  data,
const char *  fmt,
  ... 
)
static

Definition at line 322 of file parserBase.cxx.

References DEBTRACE.

Referenced by YACS::YACSLoader::load().

324 {
325  DEBTRACE("parser::fatal_error");
326  parser *currentParser = static_cast<parser *> (data);
327  va_list args;
328  va_start(args, fmt);
329  std::string format = "%s";
330  if (format == fmt)
331  {
332  char* parv;
333  parv = va_arg(args, char*);
334  std::cerr << parv ;
335  }
336  else std::cerr << __FILE__ << " [" << __LINE__ << "] : "
337  << "error format not taken into account: " << fmt << std::endl;
338  va_end(args);
339 }
std::stack< parser * > & YACS::parser::getStack ( )

Definition at line 50 of file parserBase.cxx.

References _stackParser.

51 {
52  return _stackParser;
53 }
void YACS::parser::incrCount ( const XML_Char elem)
virtual

Definition at line 100 of file parserBase.cxx.

References _counts.

Referenced by start_element().

101 {
102  if((*_counts).find(el)==(*_counts).end())
103  (*_counts)[el]=1;
104  else
105  (*_counts)[el]=(*_counts)[el]+1;
106 }
void YACS::parser::init ( )
virtual

Definition at line 86 of file parserBase.cxx.

References _counts, _level, _orderState, _stackCount, _stackOrder, and DEBTRACE.

Referenced by YACS::YACSLoader::load(), YACS::roottypeParser::onStart(), YACS::remotetypeParser< T >::onStart(), YACS::controltypeParser< T >::onStart(), YACS::servertypeParser< T >::onStart(), YACS::codetypeParser::onStart(), YACS::sinlinetypeParser< T >::onStart(), YACS::presetdatatypeParser::onStart(), YACS::outputdatatypeParser::onStart(), YACS::componentinstancetypeParser::onStart(), YACS::proctypeParser< T >::onStart(), YACS::looptypeParser< T >::onStart(), onStart(), YACS::inporttypeParser< T >::onStart(), YACS::valuetypeParser::onStart(), YACS::casetypeParser::onStart(), YACS::inlinetypeParser< T >::onStart(), YACS::servicetypeParser< T >::onStart(), YACS::nodetypeParser< T >::onStart(), YACS::containertypeParser::onStart(), YACS::seqtypeParser::onStart(), YACS::datatypeParser::onStart(), YACS::bloctypeParser< T >::onStart(), YACS::linktypeParser< T >::onStart(), YACS::switchtypeParser::onStart(), YACS::objtypeParser::onStart(), YACS::memberdatatypeParser::onStart(), YACS::outnodetypeParser< T >::onStart(), YACS::HMI::presentationtype_parser::onStart(), YACS::structdatatypeParser::onStart(), YACS::presettypeParser< T >::onStart(), YACS::arraytypeParser::onStart(), YACS::structtypeParser::onStart(), YACS::parametertypeParser::onStart(), and YACS::dynparalooptypeParser< T >::onStart().

87 {
88  DEBTRACE("parser::init, level: " <<_level);
89  if(_level>0)
90  {
91  _stackCount.push(_counts);
93  _counts=new std::map<std::string,int>;
94  }
95  _level=_level+1;
96  _counts->clear();
97  _orderState=0;
98 }
void YACS::parser::maxchoice ( std::string *  names,
int  max,
std::string &  el 
)
virtual

Definition at line 145 of file parserBase.cxx.

References CORBAEngineTest::i.

Referenced by YACS::valuetypeParser::onStart(), and YACS::casetypeParser::onStart().

146 {
147  int i=0;
148  int ncount=0;
149  while (names[i]!= "")
150  {
151  ncount=ncount+(*_counts)[names[i]];
152  ++i;
153  }
154  if(ncount>max)
155  {
156  std::stringstream msg;
157  msg<<"unexpected "+el+" element (choice count="<<ncount<<" > maxOccurs=" << max << ")";
158  throw YACS::Exception(msg.str());
159  }
160 }
void YACS::parser::maxcount ( std::string  name,
int  max,
std::string &  el 
)
virtual

Definition at line 122 of file parserBase.cxx.

References _counts.

Referenced by YACS::memberdatatypeParser::onEnd(), YACS::controltypeParser< T >::onStart(), YACS::presetdatatypeParser::onStart(), YACS::componentinstancetypeParser::onStart(), YACS::valuetypeParser::onStart(), YACS::casetypeParser::onStart(), YACS::linktypeParser< T >::onStart(), YACS::switchtypeParser::onStart(), YACS::arraytypeParser::onStart(), YACS::parametertypeParser::onStart(), and YACS::dynparalooptypeParser< T >::onStart().

123 {
124  if(el!=name)return;
125  if((*_counts)[name]>max)
126  {
127  std::stringstream msg;
128  msg <<"unexpected "+name+" element (count="<<(*_counts)[name];
129  msg <<" > maxOccurs=" << max << ")";
130  throw YACS::Exception(msg.str());
131  }
132 }
void YACS::parser::minchoice ( std::string *  names,
int  min 
)
virtual

Definition at line 162 of file parserBase.cxx.

References CORBAEngineTest::i.

Referenced by YACS::valuetypeParser::post(), and YACS::casetypeParser::post().

163 {
164  int i=0;
165  int ncount=0;
166  while (names[i]!= "")
167  {
168  ncount=ncount+(*_counts)[names[i]];
169  ++i;
170  }
171  if(ncount<min)
172  {
173  std::stringstream msg;
174  msg << "expected element ";
175  i=0;
176  while (names[i]!= "")
177  {
178  msg << names[i] << ",";
179  ++i;
180  }
181  msg << "(choice count="<<ncount<<" < minOccurs=" << min << ")";
182  throw YACS::Exception(msg.str());
183  }
184 }
void YACS::parser::mincount ( std::string  name,
int  min 
)
virtual

Definition at line 134 of file parserBase.cxx.

References _counts.

Referenced by YACS::componentinstancetypeParser::post(), YACS::controltypeParser< T >::post(), YACS::presetdatatypeParser::post(), YACS::memberdatatypeParser::post(), YACS::linktypeParser< T >::post(), YACS::arraytypeParser::post(), YACS::parametertypeParser::post(), YACS::servertypeParser< T >::post(), and YACS::servicetypeParser< T >::post().

135 {
136  if((*_counts)[name]<min)
137  {
138  std::stringstream msg;
139  msg<<"expected "+name+" element (count="<<(*_counts)[name];
140  msg << " < minOccurs=" << min << ")";
141  throw YACS::Exception(msg.str());
142  }
143 }
template<class T >
T YACS::parser::post ( )
inline

Definition at line 92 of file parserBase.hxx.

Referenced by YACS::roottypeParser::onEnd(), and YACS::dynparalooptypeParser< T >::onEnd().

92 { }
virtual void YACS::parser::pre ( )
inlinevirtual

Reimplemented in YACS::optimizerlooptypeParser< T >, YACS::foreachlooptypeParser< T >, YACS::parametertypeParser, YACS::HMI::presentationtype_parser, YACS::structtypeParser, YACS::arraytypeParser, YACS::presettypeParser< T >, YACS::structdatatypeParser, YACS::outnodetypeParser< T >, YACS::memberdatatypeParser, YACS::objtypeParser, YACS::presetdatatypeParser, YACS::loadtypeParser, YACS::switchtypeParser, YACS::outputdatatypeParser, YACS::nodetypeParser< T >, YACS::defaultcasetypeParser, YACS::datatypeParser, YACS::inlinetypeParser< T >, YACS::containertypeParser, YACS::proctypeParser< T >, YACS::casetypeParser, YACS::controltypeParser< T >, YACS::inporttypeParser< T >, YACS::valuetypeParser, YACS::looptypeParser< T >, YACS::codetypeParser, YACS::componentinstancetypeParser, YACS::typetypeParser, and YACS::machinetypeParser.

Definition at line 61 of file parserBase.hxx.

Referenced by YACS::roottypeParser::onStart(), YACS::remotetypeParser< T >::onStart(), YACS::controltypeParser< T >::onStart(), YACS::servertypeParser< T >::onStart(), YACS::codetypeParser::onStart(), YACS::sinlinetypeParser< T >::onStart(), YACS::presetdatatypeParser::onStart(), YACS::outputdatatypeParser::onStart(), YACS::componentinstancetypeParser::onStart(), YACS::proctypeParser< T >::onStart(), YACS::looptypeParser< T >::onStart(), onStart(), YACS::inporttypeParser< T >::onStart(), YACS::valuetypeParser::onStart(), YACS::casetypeParser::onStart(), YACS::inlinetypeParser< T >::onStart(), YACS::servicetypeParser< T >::onStart(), YACS::nodetypeParser< T >::onStart(), YACS::containertypeParser::onStart(), YACS::seqtypeParser::onStart(), YACS::datatypeParser::onStart(), YACS::bloctypeParser< T >::onStart(), YACS::linktypeParser< T >::onStart(), YACS::switchtypeParser::onStart(), YACS::objtypeParser::onStart(), YACS::memberdatatypeParser::onStart(), YACS::outnodetypeParser< T >::onStart(), YACS::HMI::presentationtype_parser::onStart(), YACS::structdatatypeParser::onStart(), YACS::presettypeParser< T >::onStart(), YACS::arraytypeParser::onStart(), YACS::structtypeParser::onStart(), YACS::parametertypeParser::onStart(), and YACS::dynparalooptypeParser< T >::onStart().

61 {_content="";};
void XMLCALL YACS::parser::start_document ( void *  data)
static

Definition at line 225 of file parserBase.cxx.

References DEBTRACE.

Referenced by YACS::YACSLoader::load().

226 {
227  DEBTRACE("parser::start_document");
228  parser *currentParser = static_cast<parser *> (data);
229 }
void XMLCALL YACS::parser::start_element ( void *  data,
const xmlChar *  name,
const xmlChar **  p 
)
static

Definition at line 237 of file parserBase.cxx.

References DEBTRACE, incrCount(), and onStart().

Referenced by YACS::YACSLoader::load().

240 {
241  DEBTRACE("parser::start_element " << name);
242  parser *currentParser = static_cast<parser *> (data);
243  currentParser->incrCount((const XML_Char *)name);
244  currentParser->onStart((const XML_Char *)name, (const XML_Char **)p);
245 }
void XMLCALL YACS::parser::warning ( void *  data,
const char *  fmt,
  ... 
)
static

Definition at line 284 of file parserBase.cxx.

References DEBTRACE.

Referenced by YACS::YACSLoader::load().

286 {
287  DEBTRACE("parser::warning");
288  parser *currentParser = static_cast<parser *> (data);
289  va_list args;
290  va_start(args, fmt);
291  std::string format = "%s";
292  if (format == fmt)
293  {
294  char* parv;
295  parv = va_arg(args, char*);
296  std::cerr << parv ;
297  }
298  else std::cerr << __FILE__ << " [" << __LINE__ << "] : "
299  << "error format not taken into account: " << fmt << std::endl;
300  va_end(args);
301 }
void YACS::parser::XML_SetUserData ( _xmlParserCtxt *  ctxt,
parser par 
)
static

Definition at line 219 of file parserBase.cxx.

Referenced by end_element(), and SetUserDataAndPush().

221 {
222  ctxt->userData = par;
223 }

Member Data Documentation

std::string YACS::parser::_content
std::map<std::string,int>* YACS::parser::_counts

Definition at line 98 of file parserBase.hxx.

Referenced by endParser(), incrCount(), init(), maxcount(), mincount(), and ~parser().

std::map<std::string,parser*>* YACS::parser::_defaultParsersMap

Definition at line 107 of file parserBase.hxx.

Referenced by YACS::roottypeParser::setDefaultMap().

std::string YACS::parser::_file

Definition at line 96 of file parserBase.hxx.

Referenced by YACS::YACSLoader::load(), and logError().

int YACS::parser::_level

Definition at line 101 of file parserBase.hxx.

Referenced by endParser(), init(), and ~parser().

std::map<std::string,int> YACS::parser::_orders
int YACS::parser::_orderState

Definition at line 100 of file parserBase.hxx.

Referenced by checkOrder(), endParser(), and init().

std::stack<std::map<std::string,int>*> YACS::parser::_stackCount

Definition at line 102 of file parserBase.hxx.

Referenced by endParser(), and init().

std::stack<int> YACS::parser::_stackOrder

Definition at line 103 of file parserBase.hxx.

Referenced by endParser(), and init().

std::stack< parser * > YACS::parser::_stackParser
static

Definition at line 42 of file parserBase.hxx.

Referenced by end_element(), getStack(), YACS::YACSLoader::load(), and SetUserDataAndPush().


The documentation for this struct was generated from the following files: