Main Page Class Hierarchy Compound List File List Compound Members File Members

# oracleconfigsource.cpp

Go to the documentation of this file.

    00001 // oracleconfigsource.cpp: implementation of the OracleConfigSource class.
    00002 //
    00004
    00005 #include "oracleconfigsource.h"
    00006
    00008 // Construction/Destruction
    00010
    00011 OracleConfigSource::OracleConfigSource()
    00012 {
    00013    CurrentLineIndex = 0;
    00014 }
    00015 //---------------------------------------------------------------------------
    00016 bool OracleConfigSource::LoadFromDB( int  p_servertype
    00017                                    , int  p_originId   /* = -1 */
    00018                                    )
    00019 {
    00020    bool r_status = false;
    00021
    00022 //   EWDB_PASSPORT * _passports = NULL:
    00023
    00024 //   try
    00025 //   {
    00026
    00027
    00028       int _arraysize = 50
    00029 //        , _listsize
    00030         ;
    00031
    00032       LastError = 0;
    00033       LastMessage[0] = '\0';
    00034       LineParseIndex = -1; // start of line, no tokens yet
    00035       Token[0] = '\0';
    00036
    00037       CommandLines.resize(0);
    00038       CommandLines.reserve(15);
    00039       CurrentLineIndex = 0;
    00040
    00041 /*
    00042       if ( (_passports = new EWDB_PASSPORT[_arraysize]) == NULL )
    00043       {
    00044          throw worm_exception("OracleConfigSource::LoadFromDB() Failed allocating passport list structure");
    00045       }
    00046
    00047       if ( ewdb_api_GetPassportList( p_servertype
    00048                                    , p_originId
    00049                                    , _passports
    00050                                    , &_listsize
    00051                                    )
    00052            == EWDB_RETURN_FAILURE )
    00053       {
    00054          throw worm_exception("ewdb_api_GetPassport() failed");
    00055       }
    00056
    00057       // Check returned size, reallocate and recall if array too small
    00058       //
    00059       if ( _arraysize < _listsize )
    00060       {
    00061          delete [] _passports;
    00062
    00063          if ( (_passports = new EWDB_PASSPORT[_arraysize+10]) == NULL )
    00064          {
    00065             throw worm_exception("OracleConfigSource::LoadFromDB() Failed allocating passport list structure");
    00066          }
    00067
    00068          if ( ewdb_api_GetPassportList( p_servertype
    00069                                       , p_originId
    00070                                       , _passports
    00071                                       , &_listsize
    00072                                       )
    00073               == EWDB_RETURN_FAILURE )
    00074          {
    00075             throw worm_exception("ewdb_api_GetPassport() failed");
    00076          }
    00077       }
    00078
    00079       // copy the strings into the vector
    00080       //
    00081       std::string _cmd;
    00082       for ( int _p = 0 ; _p < _listsize ; _p++ )
    00083       {
    00084          _cmd = _passports[_p].command;
    00085
    00086          CommandLines.push_back( _cmd );
    00087       }
    00088 */
    00089
    00090       r_status = true;
    00091
    00092 //   }
    00093 //   catch( worm_exception & _we )
    00094 //   {
    00095 //   }
    00096
    00097 //   if ( _passports != NULL )
    00098 //   {
    00099 //      delete [] _passports;
    00100 //   }
    00101
    00102    return r_status;
    00103 }
    00104 //---------------------------------------------------------------------------
    00105 int OracleConfigSource::ReadLine()
    00106 {
    00107    int r_status;
    00108
    00109    try
    00110    {
    00111       LastError = 0;
    00112       LastMessage[0] = '\0';
    00113       LineParseIndex = -1; // start of line, no tokens yet
    00114       Token[0] = '\0';
    00115
    00116       if ( CommandLines.size() <= CurrentLineIndex )
    00117       {
    00118          r_status = COMFILE_EOF;
    00119       }
    00120       else
    00121       {
    00122          strcpy( CurrentLine, CommandLines[CurrentLineIndex].c_str() );
    00123          // return length of command line string
    00124          r_status = CommandLines[CurrentLineIndex].length();
    00125       }
    00126    }
    00127    catch( worm_exception & _we )
    00128    {
    00129       r_status = COMFILE_ERROR;
    00130    }
    00131
    00132    return r_status;
    00133 }
    00134 //--------------------------------------------------------------------------