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 max_age(unsigned a); 00088 void browser_age(); 00089 00093 void secure(bool v); 00094 00098 bool empty() const; 00099 00100 cookie(); 00101 ~cookie(); 00102 cookie(cookie const &); 00103 cookie const &operator=(cookie const &); 00104 00108 cookie(std::string name,std::string value); 00112 cookie(std::string name,std::string value,unsigned age); 00116 cookie(std::string name,std::string value,unsigned age,std::string path,std::string domain = std::string(),std::string comment=std::string()); 00119 cookie(std::string name,std::string value,std::string path,std::string domain=std::string(),std::string comment=std::string()); 00120 00121 private: 00122 friend std::ostream &operator<<(std::ostream &,cookie const &); 00123 00124 void write(std::ostream &) const; 00125 // for future use 00126 struct _data; 00127 booster::copy_ptr<_data> d; 00128 00129 // real members 00130 std::string name_; 00131 std::string value_; 00132 std::string path_; 00133 std::string domain_; 00134 std::string comment_; 00135 00136 unsigned max_age_; 00137 00138 uint32_t secure_ : 1; 00139 uint32_t has_age_ : 1; 00140 uint32_t reserved_ : 30; 00141 }; 00142 00143 00144 00145 00146 } } //::cppcms::http 00147 00148 00149 #endif