00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
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