CppCMS
|
00001 00002 // 00003 // Copyright (C) 2008-2012 Artyom Beilis (Tonkikh) <artyomtnk@yahoo.com> 00004 // 00005 // See accompanying file COPYING.TXT file for licensing details. 00006 // 00008 #ifndef CPPCMS_HTTP_COOKIE_H 00009 #define CPPCMS_HTTP_COOKIE_H 00010 00011 #include <cppcms/defs.h> 00012 #include <booster/copy_ptr.h> 00013 00014 #include <string> 00015 #include <iostream> 00016 #include <cppcms/cstdint.h> 00017 namespace cppcms { namespace http { 00018 00019 class cookie; 00020 std::ostream CPPCMS_API &operator<<(std::ostream &,cookie const &); 00021 00026 00027 class CPPCMS_API cookie { 00028 public: 00032 std::string name() const; 00033 00037 std::string value() const; 00041 std::string path() const; 00042 00046 std::string domain() const; 00050 std::string comment() const; 00051 00055 bool secure() const; 00056 00060 void name(std::string n); 00061 00065 void value(std::string v); 00066 00070 void path(std::string p); 00071 00075 void domain(std::string); 00079 void comment(std::string); 00080 00084 void expires(time_t when); 00088 void max_age(unsigned a); 00092 void browser_age(); 00093 00097 void secure(bool v); 00098 00102 bool empty() const; 00103 00104 cookie(); 00105 ~cookie(); 00106 cookie(cookie const &); 00107 cookie const &operator=(cookie const &); 00108 00112 cookie(std::string name,std::string value); 00116 cookie(std::string name,std::string value,unsigned age); 00120 cookie(std::string name,std::string value,unsigned age,std::string path,std::string domain = std::string(),std::string comment=std::string()); 00123 cookie(std::string name,std::string value,std::string path,std::string domain=std::string(),std::string comment=std::string()); 00124 00125 private: 00126 friend std::ostream &operator<<(std::ostream &,cookie const &); 00127 00128 void write(std::ostream &) const; 00129 // for future use 00130 struct _data; 00131 booster::copy_ptr<_data> d; 00132 00133 // real members 00134 std::string name_; 00135 std::string value_; 00136 std::string path_; 00137 std::string domain_; 00138 std::string comment_; 00139 00140 unsigned max_age_; 00141 00142 uint32_t secure_ : 1; 00143 uint32_t has_age_ : 1; 00144 uint32_t has_expiration_: 1; 00145 uint32_t reserved_ : 29; 00146 }; 00147 00148 00149 00150 00151 } } //::cppcms::http 00152 00153 00154 #endif