OSiLReader.cpp
Go to the documentation of this file.
1 /* $Id: OSiLReader.cpp 5284 2017-12-08 13:52:50Z stefan $ */
16 #include "OSiLReader.h"
17 
18 
19 //bison function
21 //lex functions
22 int osillex_init(void** ptr_yy_globals);
23 int osillex_destroy (void* scanner );
24 void osilset_extra (OSiLParserData* parserData , void* yyscanner );
25 
26 
28 {
29  m_osinstance = new OSInstance();
31  m_osglData = new OSgLParserData();
32  m_osnlData = new OSnLParserData();
33 
34  // initialize the lexer and set yyextra
37 }
38 
40 {
41  if(m_osinstance != NULL) delete m_osinstance;
42  m_osinstance = NULL;
43  // now delete the flex scanner that was initialized
45  if( m_parserData != NULL) delete m_parserData;
46  m_parserData = NULL;
47  if( m_osglData != NULL) delete m_osglData;
48  m_osglData = NULL;
49  if( m_osnlData != NULL) delete m_osnlData;
50  m_osnlData = NULL;
51 }
52 
53 OSInstance* OSiLReader::readOSiL(const std::string& posil)
54 #if __cplusplus < 201100
55  throw(ErrorClass)
56 #endif
57 {
58  try
59  {
60  const char *ch = posil.c_str();
61  yygetOSInstance( ch, m_osinstance, m_parserData, m_osglData, m_osnlData);
62  return m_osinstance;
63  }
64  catch(const ErrorClass& eclass)
65  {
66  throw ErrorClass( eclass.errormsg);
67  }
68 }//end readOSiL
69 
70 
71 
72 
void yygetOSInstance(const char *osil, OSInstance *osinstance, OSiLParserData *parserData, OSgLParserData *osglData, OSnLParserData *osnlData)
#define scanner
std::string errormsg
errormsg is the error that is causing the exception to be thrown
Definition: OSErrorClass.h:42
OSnLParserData * m_osnlData
m_osnlData is the object used in the parser to temporarily store data from the OSnL schema elements...
Definition: OSiLReader.h:85
OSInstance * readOSiL(const std::string &osil)
parse the OSiL model instance.
Definition: OSiLReader.cpp:53
OSnLParserData * osnlData
OSgLParserData * osglData
OSiLParserData * parserData
int osillex_init(void **ptr_yy_globals)
void osilset_extra(OSiLParserData *parserData, void *yyscanner)
void * scanner
scanner is used to store data in a reentrant lexer we use this to pass an OSiLParserData object to th...
OSiLReader()
Default constructor.
Definition: OSiLReader.cpp:27
OSiLParserData * m_parserData
m_parserData is the object used in the parser to temporarily store data
Definition: OSiLReader.h:75
The in-memory representation of an OSiL instance..
Definition: OSInstance.h:2262
OSInstance * osinstance
OSInstance * m_osinstance
m_osinstance is the OSInstance object returned by the OSiLReader
Definition: OSiLReader.h:71
The OSgLParserData Class.
The OSiLParserData Class, used to store parser data.
used for throwing exceptions.
Definition: OSErrorClass.h:31
The OSnLParserData Class.
OSgLParserData * m_osglData
m_osglData is the object used in the parser to temporarily store data from the OSgL schema elements...
Definition: OSiLReader.h:80
int osillex_destroy(void *scanner)
~OSiLReader()
Class destructor.
Definition: OSiLReader.cpp:39