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

Go to the documentation of this file.
00001 /* $Id: OSoLReader.cpp 2698 2009-06-09 04:14:07Z kmartin $ */
00018 //#define OSOL_READER_DEBUG
00019 #ifdef OSOL_READER_DEBUG
00020 #include <cstdio>
00021 #endif
00022 
00023 #include "OSoLReader.h"
00024 
00025 
00026 //bison function
00027 void yygetOSOption(const char *osil, OSOption* osoption, OSoLParserData *parserData) throw(ErrorClass);
00028 //lex functions
00029 int osollex_init(void** ptr_yy_globals);
00030 int osollex_destroy (void* scanner );
00031 void osolset_extra (OSoLParserData* parserData , void* yyscanner );
00032 
00033 
00034 OSoLReader::OSoLReader( ) {
00035 #ifdef OSOL_READER_DEBUG
00036         printf("new OSOption\n");
00037 #endif
00038         m_osoption = new OSOption();
00039 #ifdef OSOL_READER_DEBUG
00040         printf("new OSoLParserData\n");
00041 #endif
00042         m_parserData = new OSoLParserData();
00043         // initialize the lexer and set yyextra
00044 #ifdef OSOL_READER_DEBUG
00045         printf("call osollex_init\n");
00046 #endif
00047 
00048         osollex_init( &(m_parserData->scanner) );
00049 #ifdef OSOL_READER_DEBUG
00050         printf("call osollex_extra\n");
00051 #endif
00052         osolset_extra (m_parserData ,   m_parserData->scanner);
00053 #ifdef OSOL_READER_DEBUG
00054         printf("success\n");
00055 #endif
00056 }
00057 
00058 OSoLReader::~OSoLReader(){
00059         if(m_osoption != NULL) delete m_osoption;
00060         m_osoption = NULL;
00061         // now delete the flex scanner that was initialized
00062         osollex_destroy(m_parserData->scanner );
00063         if( m_parserData != NULL) delete m_parserData;
00064         m_parserData = 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);
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 Fri Nov 19 13:31:04 2010 by  doxygen 1.4.7