/home/coin/SVN-release/OS-2.3.5/OS/src/OSCommonInterfaces/OSoLReader.cpp

Go to the documentation of this file.
00001 /* $Id: OSoLReader.cpp 4120 2011-03-30 06:28:16Z kmartin $ */
00016 //#define OSOL_READER_DEBUG
00017 #ifdef OSOL_READER_DEBUG
00018 #include <cstdio>
00019 #endif
00020 
00021 #include "OSoLReader.h"
00022 
00023 
00024 //bison function
00025 void yygetOSOption(const char *osil, OSOption* osoption, OSoLParserData *parserData, OSgLParserData *osglData) throw(ErrorClass);
00026 //lex functions
00027 int osollex_init(void** ptr_yy_globals);
00028 int osollex_destroy (void* scanner );
00029 void osolset_extra (OSoLParserData* parserData , void* yyscanner );
00030 
00031 
00032 OSoLReader::OSoLReader( ) {
00033 #ifdef OSOL_READER_DEBUG
00034         std::cout << "new OSOption()" << std::endl;
00035 #endif
00036         m_osoption = new OSOption();
00037 #ifdef OSOL_READER_DEBUG
00038         std::cout << "new OSoLParserData()" << std::endl;
00039 #endif
00040         m_parserData = new OSoLParserData();
00041 #ifdef OSOL_READER_DEBUG
00042         std::cout << "new OSgLParserData()" << std::endl;
00043 #endif
00044         m_osglData = new OSgLParserData();
00045         // initialize the lexer and set yyextra
00046 #ifdef OSOL_READER_DEBUG
00047         std::cout << "initialize the lexer" << std::endl;
00048 #endif
00049         osollex_init( &(m_parserData->scanner) );
00050         osolset_extra (m_parserData ,   m_parserData->scanner);
00051 #ifdef OSOL_READER_DEBUG
00052         std::cout << "done" << std::endl;
00053 #endif
00054 }
00055 
00056 OSoLReader::~OSoLReader(){
00057         if(m_osoption != NULL) delete m_osoption;
00058         m_osoption = NULL;
00059         // now delete the flex scanner that was initialized
00060         osollex_destroy(m_parserData->scanner );
00061         if( m_parserData != NULL) delete m_parserData;
00062         m_parserData = NULL;
00063         if( m_osglData != NULL) delete m_osglData;
00064         m_osglData = NULL;
00065 } 
00066 
00067 OSOption* OSoLReader::readOSoL(const std::string& posol) throw(ErrorClass){   
00068         try{
00069                 const char *ch = posol.c_str();
00070                 yygetOSOption( ch, m_osoption, m_parserData, m_osglData);
00071                 return m_osoption;
00072         }
00073                 catch(const ErrorClass& eclass){
00074                 throw ErrorClass( eclass.errormsg);
00075         }
00076 }//end readOSoL
00077 
00078 
00079 
00080 

Generated on Thu Mar 31 03:12:51 2011 by  doxygen 1.4.7