/home/greg/src/restcgi-test/src/env.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_env_h
00023 #define restcgi_env_h
00024 #include "apidefs.h"
00025 #include <string>
00026 #include <map>
00027 #ifdef _WIN32
00028 #pragma warning (disable: 4251)
00029 #endif
00030 namespace restcgi {
00058     class RESTCGI_API env {
00059     public:
00060         typedef std::map<std::string, std::string> map_type; 
00061 
00062         env();
00064         env(const char **pcstr);
00066         env(const map_type& m);
00070         std::string server_software() const;
00073         std::string server_name() const;
00076         std::string gateway_interface() const;
00079         std::string server_protocol() const;
00081         std::string server_port() const;
00084         std::string request_method() const;
00092         std::string path_info() const;
00097         std::string path_translated() const;
00104         std::string script_name() const;
00108         std::string request_uri() const;
00111         std::string script_filename() const;
00116         std::string script_url() const;
00120         std::string script_uri() const;
00125         std::string query_string() const;
00128         std::string remote_host() const;
00130         std::string remote_addr() const;
00134         std::string auth_type() const;
00137         std::string remote_user() const;
00142         std::string remote_ident() const;
00144         std::string redirect_request() const;
00146         std::string redirect_url() const;
00149         std::string redirect_status() const;
00153         std::string content_type() const;
00156         std::string content_length() const;
00162         std::string accept() const;
00165         std::string accept_charset() const;
00168         std::string accept_encoding() const;
00172         std::string accept_language() const;
00176         std::string user_agent() const;
00179         bool hdr_find(const std::string& hname, std::string& value) const;
00181         bool find(const char* name, std::string& value) const;
00184         std::string find(const char* name) const;
00186         class RESTCGI_API hdr_iterator {
00187         public:
00188             typedef std::pair<std::string, std::string> referent_type; 
00189             hdr_iterator& operator ++(); 
00190             hdr_iterator operator ++(int); 
00191             bool operator ==(const hdr_iterator& rhs) const; 
00192             bool operator !=(const hdr_iterator& rhs) const {return !operator ==(rhs);} 
00193             const referent_type& operator *() const; 
00194             const referent_type* operator ->() const; 
00195         private:
00196             friend class env;
00197             hdr_iterator() : end_(true) {}
00198             hdr_iterator(const env& e);
00199             void increment(bool initialize = false);
00200             bool end_;
00201             char** p_;
00202             map_type::const_iterator it_;
00203             map_type::const_iterator it_end_;
00204             referent_type current_;
00205         };
00206         hdr_iterator hdr_begin() const {return hdr_iterator(*this);} 
00207         hdr_iterator hdr_end() const {return hdr_iterator();} 
00208 
00209         void override(const std::string& name, const std::string& value);
00214         static std::string to_env_name(const std::string& hname);
00216         static std::string from_env_name(const std::string& ename);
00217     private:
00218         friend class hdr_iterator;
00219         bool map_override_mode_;
00220         map_type map_;
00221     };
00222 }
00223 #endif

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