/home/greg/src/restcgi-test/src/httpsyn.h

00001 /*
00002 Copyright (c) 2009 zooml.com
00003 
00004 Permission is hereby granted, free of charge, to any person obtaining a copy
00005 of this software and associated documentation files (the "Software"), to deal
00006 in the Software without restriction, including without limitation the rights
00007 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00008 copies of the Software, and to permit persons to whom the Software is
00009 furnished to do so, subject to the following conditions:
00010 
00011 The above copyright notice and this permission notice shall be included in
00012 all copies or substantial portions of the Software.
00013 
00014 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00015 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00016 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00017 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00018 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00019 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00020 THE SOFTWARE.
00021 */
00022 #ifndef restcgi_httpsyn_h
00023 #define restcgi_httpsyn_h
00024 #include "apidefs.h"
00025 #include <string>
00026 #ifdef _WIN32
00027 #pragma warning (disable: 4251)
00028 #endif
00029 namespace restcgi {
00061     class RESTCGI_API http_token {
00062     public:
00063         http_token(); 
00064 
00065 
00066         http_token(const std::string& s);
00067         bool is_null() const {return string_.empty();} 
00068         const std::string& string() const {return string_;} 
00069         const std::string& encoding() const {return string_;} 
00070         static bool is_valid(const std::string& v);
00071         static const char ctypes_[256]; 
00072     private:
00073         friend bool RESTCGI_API parse(std::string::const_iterator& first, std::string::const_iterator last, http_token& v, bool noskipls);
00074         std::string string_;
00075     };
00081     bool RESTCGI_API parse(std::string::const_iterator& first, std::string::const_iterator last, http_token& v, bool noskipls = false);
00105     class RESTCGI_API http_text {
00106     public:
00107         http_text(); 
00108 
00109 
00110         http_text(const std::string& s);
00111         bool empty() const {return string_.empty();} 
00112         const std::string& string() const {return string_;} 
00113         const std::string& encoding() const {return string_;} 
00114 
00115 
00116         http_text operator +(const std::string& rhs) const {
00117             http_text result = *this;
00118             return result += rhs;
00119         }
00122         http_text& operator +=(const std::string& rhs);
00124         http_text operator +(const http_text& rhs) const {
00125             http_text result = *this;
00126             return result += rhs;
00127         }
00129         http_text& operator +=(const http_text& rhs) {
00130             string_.append(rhs.string_);
00131             return *this;
00132         }
00133         static const char ctypes_[256]; 
00134     private:
00135         friend bool RESTCGI_API parse(std::string::const_iterator& first, std::string::const_iterator last, http_text& v, const char* terms, bool lastok);
00136         std::string string_;
00137     };
00148     bool RESTCGI_API parse(std::string::const_iterator& first, std::string::const_iterator last, http_text& v, const char* terms = 0, bool lastok = false);
00197     class RESTCGI_API http_word {
00198     public:
00199         http_word(); 
00200 
00201 
00202         http_word(const std::string& s);
00203         http_word(const http_token& tok); 
00204         http_word(const http_text& txt); 
00205         bool empty() const {return string_.empty();} 
00206 
00207 
00208         const std::string& string() const {return string_;}
00211         http_word operator +(const std::string& rhs) const {
00212             http_word result = *this;
00213             return result += rhs;
00214         }
00217         http_word& operator +=(const std::string& rhs);
00219         http_word operator +(const http_text& rhs) const {
00220             http_word result = *this;
00221             return result += rhs;
00222         }
00223         http_word& operator +=(const http_text& rhs); 
00224 
00225         http_word operator +(const http_word& rhs) const {
00226             http_word result = *this;
00227             return result += rhs;
00228         }
00229         http_word& operator +=(const http_word& rhs); 
00230 
00231 
00232         std::string encoding(bool force_quotes = false) const;
00233         static const char ESC_CHAR; 
00234     private:
00235         friend bool RESTCGI_API parse(std::string::const_iterator& first, std::string::const_iterator last, http_word& v);
00236         std::string string_;
00237         bool token_;
00238     };
00243     bool RESTCGI_API parse(std::string::const_iterator& first, std::string::const_iterator last, http_word& v);
00247     namespace httpsyn {
00249         inline bool isspace(char c) {return c == ' ' || c == '\t';}
00252         bool RESTCGI_API parse(std::string::const_iterator& first, std::string::const_iterator last, const char* v);
00255         bool RESTCGI_API parse_any(std::string::const_iterator& first, std::string::const_iterator last);
00259         bool RESTCGI_API parse_eor(std::string::const_iterator& first, std::string::const_iterator last);
00262         bool RESTCGI_API parse_skip(std::string::const_iterator& first, std::string::const_iterator last, const char* terms);
00263     }
00264 }
00265 #endif
00266 

Generated on Fri May 15 11:27:12 2009 for restcgi by  doxygen 1.4.7