BESApacheRequests.cc
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #include "BESApacheRequests.h"
00034 #include "BESInternalError.h"
00035
00036 #include <iostream>
00037
00038 using std::cout ;
00039 using std::endl ;
00040
00041 BESApacheRequests::BESApacheRequests( const string &requests )
00042 {
00043 if( requests != "" )
00044 {
00045 unsigned int len = requests.length() ;
00046 const char *request = requests.c_str() ;
00047 if( request )
00048 {
00049 unsigned int index = 0 ;
00050 unsigned int start = 0 ;
00051 bool inquotes = false ;
00052 bool done = false ;
00053 char c ;
00054 while( !done )
00055 {
00056 c = request[index] ;
00057 if( inquotes )
00058 {
00059 if( c == '\"' )
00060 {
00061 inquotes = false ;
00062 }
00063 }
00064 else
00065 {
00066 if( c == '\"' )
00067 {
00068 inquotes = true ;
00069 }
00070 else if( c == ';' )
00071 {
00072 string req = requests.substr( start, index-start+1 ) ;
00073 _requests.push_back( req ) ;
00074 start = index+1 ;
00075 }
00076 }
00077 index++ ;
00078 if( index == len )
00079 {
00080 if( index != start )
00081 {
00082 if( inquotes )
00083 {
00084 string err = "ending double quote missing in request string" ;
00085 throw BESInternalError( err, __FILE__, __LINE__ ) ;
00086 }
00087 else
00088 {
00089 string err = "requests must end with a semicolon (;)" ;
00090 throw BESInternalError( err, __FILE__, __LINE__ ) ;
00091 }
00092 }
00093 done = true ;
00094 }
00095 }
00096 }
00097 }
00098 }
00099
00100 BESApacheRequests::~BESApacheRequests()
00101 {
00102 }
00103
00104 BESApacheRequests::requests_citer
00105 BESApacheRequests::get_first_request()
00106 {
00107 return _requests.begin() ;
00108 }
00109
00110 BESApacheRequests::requests_citer
00111 BESApacheRequests::get_end_request()
00112 {
00113 return _requests.end() ;
00114 }
00115