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

Go to the documentation of this file.
00001 /* $Id: OSoLReader.cpp 4292 2011-09-21 05:47:18Z 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 {
00034 #ifdef OSOL_READER_DEBUG
00035     std::cout << "new OSOption()" << std::endl;
00036 #endif
00037     m_osoption = new OSOption();
00038 #ifdef OSOL_READER_DEBUG
00039     std::cout << "new OSoLParserData()" << std::endl;
00040 #endif
00041     m_parserData = new OSoLParserData();
00042 #ifdef OSOL_READER_DEBUG
00043     std::cout << "new OSgLParserData()" << std::endl;
00044 #endif
00045     m_osglData = new OSgLParserData();
00046     // initialize the lexer and set yyextra
00047 #ifdef OSOL_READER_DEBUG
00048     std::cout << "initialize the lexer" << std::endl;
00049 #endif
00050     osollex_init( &(m_parserData->scanner) );
00051     osolset_extra (m_parserData ,   m_parserData->scanner);
00052 #ifdef OSOL_READER_DEBUG
00053     std::cout << "done" << std::endl;
00054 #endif
00055 }
00056 
00057 OSoLReader::~OSoLReader()
00058 {
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     if( m_osglData != NULL) delete m_osglData;
00066     m_osglData = NULL;
00067 }
00068 
00069 OSOption* OSoLReader::readOSoL(const std::string& posol) throw(ErrorClass)
00070 {
00071     try
00072     {
00073         const char *ch = posol.c_str();
00074         yygetOSOption( ch, m_osoption, m_parserData, m_osglData);
00075         return m_osoption;
00076     }
00077     catch(const ErrorClass& eclass)
00078     {
00079         throw ErrorClass( eclass.errormsg);
00080     }
00081 }//end readOSoL
00082 
00083 
00084 
00085 

Generated on Thu Nov 10 03:05:48 2011 by  doxygen 1.4.7