Version: 9.15.0
YACS::structtypeParser Struct Reference

Class for struct parser. More...

#include <typeParsers.hxx>

Inheritance diagram for YACS::structtypeParser:
Collaboration diagram for YACS::structtypeParser:

Public Member Functions

virtual void onStart (const XML_Char *el, const XML_Char **attr)
 
virtual void onEnd (const char *el, parser *child)
 
virtual void buildAttr (const XML_Char **attr)
 
virtual void pre ()
 
virtual void name (const std::string &name)
 
virtual void id (const std::string &name)
 
virtual void member (const myprop &prop)
 
virtual YACS::ENGINE::TypeCodepost ()
 
- Public Member Functions inherited from YACS::parser
 parser ()
 
virtual ~parser ()
 
virtual void SetUserDataAndPush (parser *pp)
 
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 required (const std::string &name, const XML_Char **attr)
 
std::stack< parser * > & getStack ()
 
template<class T >
post ()
 
void logError (const std::string &reason)
 

Public Attributes

std::string _name
 
std::string _id
 
std::vector< myprop_members
 
- Public Attributes inherited from YACS::parser
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 structtypeParser structParser
 
- Static Public Attributes inherited from YACS::parser
static parser main_parser
 
static std::stack< parser * > _stackParser
 

Additional Inherited Members

- Static Public Member Functions inherited from YACS::parser
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)
 

Detailed Description

Class for struct parser.

Class used to parse a struct (type) definition (class TypeCodeStruct in implementation)

XML schema is

  <xsd:complexType name="StructType">
    <xsd:sequence>
      <xsd:element name="member" type="MemberType" minOccurs="0" maxOccurs="unbounded"/>
    </xsd:sequence>
    <xsd:attribute name="name" type="xsd:string" use="required"/>
    <xsd:attribute name="id" type="xsd:string" />
  </xsd:complexType>

Definition at line 154 of file typeParsers.hxx.

Member Function Documentation

◆ buildAttr()

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

Reimplemented from YACS::parser.

Definition at line 244 of file typeParsers.cxx.

245  {
246  if (!attr)
247  return;
248  required("name",attr);
249  for (int i = 0; attr[i]; i += 2)
250  {
251  if(std::string(attr[i]) == "name")name(attr[i+1]);
252  if(std::string(attr[i]) == "id")id(attr[i+1]);
253  }
254  }
virtual void required(const std::string &name, const XML_Char **attr)
Definition: parserBase.cxx:186
virtual void name(const std::string &name)
virtual void id(const std::string &name)

References yacsorb.CORBAEngineTest::i, id(), name(), and YACS::parser::required().

◆ id()

void YACS::structtypeParser::id ( const std::string &  name)
virtual

Definition at line 265 of file typeParsers.cxx.

266  {
267  DEBTRACE( "structtype_id: " << name );
268  _id=name;
269  }
#define DEBTRACE(msg)
Definition: YacsTrace.hxx:31

References _id, DEBTRACE, and name().

Referenced by buildAttr().

◆ member()

void YACS::structtypeParser::member ( const myprop prop)
virtual

Definition at line 270 of file typeParsers.cxx.

271  {
272  DEBTRACE( "structtype_member: " << prop._name << prop._value );
273  if(currentProc->typeMap.count(prop._value)==0)
274  {
275  //Check if the typecode is defined in the runtime
277  if(t==0)
278  {
279  std::string msg="Unknown type " + prop._value + " for member " + prop._name + " in struct " + _name;
280  throw Exception(msg);
281  }
282  else
283  {
284  currentProc->typeMap[prop._value]=t;
285  t->incrRef();
286  }
287  }
288 
289  _members.push_back(prop);
290  }
std::map< std::string, TypeCode * > typeMap
Definition: Proc.hxx:90
virtual TypeCode * getTypeCode(const std::string &name)
Get a typecode by its name from runtime catalogs.
Definition: Runtime.cxx:333
Base class for all type objects.
Definition: TypeCode.hxx:68
std::vector< myprop > _members
std::string _name
Definition: factory.hxx:96
std::string _value
Definition: factory.hxx:97
YACS::ENGINE::Runtime * theRuntime
Definition: parsers.cxx:40
YACS::ENGINE::Proc * currentProc
Definition: parserBase.cxx:30

References _members, myprop::_name, _name, myprop::_value, currentProc, DEBTRACE, YACS::ENGINE::Runtime::getTypeCode(), gui.Appli::t, theRuntime, and YACS::ENGINE::Proc::typeMap.

Referenced by onEnd().

◆ name()

void YACS::structtypeParser::name ( const std::string &  name)
virtual

Definition at line 260 of file typeParsers.cxx.

261  {
262  DEBTRACE( "structtype_name: " << name );
263  _name=name;
264  }

References _name, and DEBTRACE.

Referenced by buildAttr(), and id().

◆ onEnd()

void YACS::structtypeParser::onEnd ( const char *  el,
parser child 
)
virtual

Reimplemented from YACS::parser.

Definition at line 238 of file typeParsers.cxx.

239  {
240  DEBTRACE( "structtypeParser::onEnd: " << el )
241  std::string element(el);
242  if(element == "member")member(((membertypeParser*)child)->post());
243  }
virtual void member(const myprop &prop)
virtual YACS::ENGINE::TypeCode * post()

References DEBTRACE, member(), and post().

◆ onStart()

void YACS::structtypeParser::onStart ( const XML_Char el,
const XML_Char **  attr 
)
virtual

Reimplemented from YACS::parser.

Definition at line 227 of file typeParsers.cxx.

228  {
229  DEBTRACE( "structtypeParser::onStart: " << el )
230  std::string element(el);
232  if(element == "member")pp=&membertypeParser::memberParser;
233  SetUserDataAndPush(pp);
234  pp->init();
235  pp->pre();
236  pp->buildAttr(attr);
237  }
static membertypeParser memberParser
virtual void SetUserDataAndPush(parser *pp)
Definition: parserBase.cxx:55
static parser main_parser
Definition: parserBase.hxx:41

References YACS::parser::buildAttr(), DEBTRACE, YACS::parser::init(), YACS::parser::main_parser, YACS::membertypeParser::memberParser, YACS::parser::pre(), and YACS::parser::SetUserDataAndPush().

◆ post()

ENGINE::TypeCode * YACS::structtypeParser::post ( )
virtual

Definition at line 291 of file typeParsers.cxx.

292  {
293  DEBTRACE( "structtype_post" );
294  ENGINE::TypeCodeStruct *t;
295  if(currentProc->typeMap.count(_name)!=0)
296  {
297  //reuse a forward declaration
298  ENGINE::TypeCode* tt=currentProc->typeMap[_name];
299  if(tt->kind()==YACS::ENGINE::Struct)
300  {
301  t=(ENGINE::TypeCodeStruct*)tt;
302  }
303  else
304  {
305  std::string msg="Forward declaration must be a struct type but " + std::string(tt->name()) + " is not one" ;
306  throw Exception(msg);
307  }
308  }
309  else
310  {
311  t = (ENGINE::TypeCodeStruct*)currentProc->createStructTc(_id,_name);
312  }
313  std::vector<myprop>::const_iterator iter;
314  for(iter=_members.begin();iter!=_members.end();iter++)
315  {
316  DEBTRACE("member: " << iter->_name << " " <<iter->_value);
317  t->addMember(iter->_name,currentProc->typeMap[iter->_value]);
318  }
319  return t;
320  }
virtual TypeCode * createStructTc(const std::string &id, const std::string &name)
Definition: Proc.cxx:161

References _id, _members, _name, YACS::ENGINE::Proc::createStructTc(), currentProc, DEBTRACE, YACS::ENGINE::TypeCode::kind(), YACS::ENGINE::TypeCode::name(), YACS::ENGINE::Struct, gui.Appli::t, and YACS::ENGINE::Proc::typeMap.

Referenced by onEnd().

◆ pre()

void YACS::structtypeParser::pre ( )
virtual

Reimplemented from YACS::parser.

Definition at line 255 of file typeParsers.cxx.

256  {
257  _id="";
258  _members.clear();
259  }

References _id, and _members.

Member Data Documentation

◆ _id

std::string YACS::structtypeParser::_id

Definition at line 167 of file typeParsers.hxx.

Referenced by id(), post(), and pre().

◆ _members

std::vector<myprop> YACS::structtypeParser::_members

Definition at line 168 of file typeParsers.hxx.

Referenced by member(), post(), and pre().

◆ _name

std::string YACS::structtypeParser::_name

Definition at line 166 of file typeParsers.hxx.

Referenced by member(), name(), and post().

◆ structParser

structtypeParser YACS::structtypeParser::structParser
static

Definition at line 156 of file typeParsers.hxx.

Referenced by YACS::proctypeParser< T >::onStart().


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