OPeNDAP Hyrax Back End Server (BES)
Updated for version 3.8.3
|
00001 // BESApacheRequests.cc 00002 00003 // This file is part of bes, A C++ back-end server implementation framework 00004 // for the OPeNDAP Data Access Protocol. 00005 00006 // Copyright (c) 2004-2009 University Corporation for Atmospheric Research 00007 // Author: Patrick West <pwest@ucar.edu> and Jose Garcia <jgarcia@ucar.edu> 00008 // 00009 // This library is free software; you can redistribute it and/or 00010 // modify it under the terms of the GNU Lesser General Public 00011 // License as published by the Free Software Foundation; either 00012 // version 2.1 of the License, or (at your option) any later version. 00013 // 00014 // This library is distributed in the hope that it will be useful, 00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00017 // Lesser General Public License for more details. 00018 // 00019 // You should have received a copy of the GNU Lesser General Public 00020 // License along with this library; if not, write to the Free Software 00021 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00022 // 00023 // You can contact University Corporation for Atmospheric Research at 00024 // 3080 Center Green Drive, Boulder, CO 80301 00025 00026 // (c) COPYRIGHT University Corporation for Atmospheric Research 2004-2005 00027 // Please read the full copyright statement in the file COPYRIGHT_UCAR. 00028 // 00029 // Authors: 00030 // pwest Patrick West <pwest@ucar.edu> 00031 // jgarcia Jose Garcia <jgarcia@ucar.edu> 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