00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 #ifndef _MPCL_NET_CGI_COOKIE__
00029 #define _MPCL_NET_CGI_COOKIE__
00030 
00031 #include "../../io/streamable.hh"
00032 #include "../../text/gmt_date.hh"
00033 #include "../../text/string.hh"
00034 
00035 
00037 namespace mpcl
00038 {
00039 
00041   namespace net
00042   {
00043 
00045     namespace cgi
00046     {
00047 
00048       using io::IStreamable;
00049       using text::IDate;
00050       using text::TGmtDate;
00051       using text::TString;
00052 
00057       class TCookie : public IStreamable<>
00058       {
00059 
00060         private:
00061 
00063           bool   gSecure;
00064 
00066           TGmtDate   tExpires;
00067 
00069           TString    yDomain;
00070 
00072           TString    yName;
00073 
00075           TString    yPath;
00076 
00078           TString    yValue;
00079 
00080 
00081         public:
00082 
00083           
00084           
00085           
00086 
00091           TCookie (const TCookie& rktCGI_COOKIE)   :
00092             IStreamable<> ()                       ,
00093             gSecure       (rktCGI_COOKIE.gSecure)  ,
00094             tExpires      (rktCGI_COOKIE.tExpires) ,
00095             yDomain       (rktCGI_COOKIE.yDomain)  ,
00096             yName         (rktCGI_COOKIE.yName)    ,
00097             yPath         (rktCGI_COOKIE.yPath)    ,
00098             yValue        (rktCGI_COOKIE.yValue)   {}
00099 
00109           TCookie ( const TString&  rkyNAME                               ,
00110                     const TString&  rkyVALUE                              ,
00111                     const TGmtDate& rktEXPIRES = TGmtDate (IDate::eEmpty) ,
00112                     const TString&  rkyPATH    = ""                       ,
00113                     const TString&  rkyDOMAIN  = ""                       ,
00114                     const bool      kgSECURE   = false                    ) :
00115             IStreamable<> ()                                                ,
00116             gSecure       (kgSECURE)                                        ,
00117             tExpires      (rktEXPIRES)                                      ,
00118             yDomain       (rkyDOMAIN)                                       ,
00119             yName         (rkyNAME)                                         ,
00120             yPath         (rkyPATH)                                         ,
00121             yValue        (rkyVALUE)                                        {}
00122 
00127           TCookie (std::basic_istream<char_type, traits_type>& rtSOURCE_ISTREAM) :
00128             IStreamable<> ()                                                     ,
00129             gSecure       (false)                                                ,
00130             tExpires      (TGmtDate (IDate::eEmpty))                             ,
00131             yDomain       ()                                                     ,
00132             yName         ()                                                     ,
00133             yPath         ()                                                     ,
00134             yValue        ()
00135           {
00136             read (rtSOURCE_ISTREAM);
00137           }
00138 
00139 
00140         protected:
00141 
00142           
00143           
00144           
00145 
00150           void read (std::basic_istream<char_type, traits_type>& rtSOURCE_ISTREAM);
00151 
00156           void write (std::basic_ostream<char_type, traits_type>& rtTARGET_OSTREAM) const;
00157 
00158 
00159         public:
00160 
00161           
00162           
00163           
00164 
00166           TString name (void) const
00167           {
00168             return yName;
00169           }
00170 
00172           TString value (void) const
00173           {
00174             return yValue;
00175           }
00176 
00182           bool operator == (const TCookie& rktCOOKIE) const
00183           {
00184             return ( ( yName == rktCOOKIE.yName ) && ( yValue == rktCOOKIE.yValue ) );
00185           }
00186 
00187       };  
00188 
00189     }  
00190 
00191   }  
00192 
00193 }  
00194 
00195 
00196 #endif  // not _MPCL_NET_CGI_COOKIE__