Cookie.h

Go to the documentation of this file.
00001 /* -*- c++ -*-
00002  * $Id: Cookie.h,v 1.20 2006/05/16 20:06:34 brook Exp $
00003  */
00004 
00005 /*
00006  * ClearSilver++ Software License.
00007  *
00008  * Copyright (c) 2005,2006 Brook Milligan <brook@nmsu.edu>
00009  * All rights reserved.
00010  * 
00011  * Redistribution and use in source and binary forms, with or without
00012  * modification, are permitted provided that the following conditions
00013  * are met:
00014  * 
00015  * 1. Redistributions of source code must retain the above copyright
00016  *    notice, this list of conditions and the following disclaimer.
00017  * 2. Redistributions in binary form must reproduce the above
00018  *    copyright notice, this list of conditions and the following
00019  *    disclaimer in the documentation and/or other materials provided
00020  *    with the distribution.
00021  * 3. The name of the author may not be used to endorse or promote
00022  *    products derived from this software without specific prior
00023  *    written permission.
00024  * 
00025  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
00026  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00027  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00028  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
00029  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00030  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
00031  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00032  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
00033  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00034  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00035  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036  */
00037 
00043 #ifndef Cookie_h_
00044 #define Cookie_h_ 1
00045 
00046 #include <string>
00047 #include <time.h>
00048 #include <boost/date_time/posix_time/posix_time_types.hpp>
00049 
00050 namespace ClearSilver
00051 {
00052 
00062 class Cookie
00063 {
00064 
00065 public:
00066 
00101   class Authority
00102   {
00103   public:
00105     //\{
00107     Authority ();
00109     explicit Authority (const char*);
00111     explicit Authority (const std::string&);
00113     Authority (const Authority&);
00115     ~Authority () throw();
00116 
00118     Authority& operator = (const Authority&);
00119 
00121     void swap (Authority&) throw();
00122     //\}
00123 
00125     //\{
00127     bool empty () const;
00128     //\}
00129 
00131     std::string operator () () const;
00132 
00133   private:
00134     std::string authority_;
00135   };
00136 
00137 public:
00138 
00162   class Path
00163   {
00164   private:
00165     std::string path_;
00166 
00167   public:
00169     //\{
00171     Path ();
00173     explicit Path (const char*);
00175     explicit Path (const std::string&);
00177     Path (const Path&);
00179     ~Path () throw();
00180 
00182     Path& operator = (const Path&);
00183 
00185     void swap (Path&) throw();
00186     //\}
00187 
00189     //\{
00191     bool empty () const;
00192     //\}
00193 
00195     std::string operator () () const;
00196   };
00197 
00198 public:
00199 
00230   class Expires
00231   {
00232   private:
00233     std::string expires_;
00234 
00235   public:
00237     //\{
00239     Expires ();
00251     explicit Expires (const char*);
00263     explicit Expires (const std::string&);
00265     explicit Expires (time_t);
00267     explicit Expires (struct tm);
00282     explicit Expires (const boost::posix_time::ptime&);
00284     Expires (const Expires&);
00286     ~Expires () throw();
00287 
00289     Expires& operator = (const Expires&);
00290 
00292     void swap (Expires&) throw();
00293     //\}
00294 
00296     //\{
00298     operator bool () const;
00300     bool empty () const;
00301     //\}
00302 
00304     std::string operator () () const;
00305   };
00306 
00307 public:
00308 
00339   class Credentials
00340   {
00341   private:
00342     Authority authority_;
00343     Path path_;
00344     Expires expires_;
00345     bool persist_;
00346     bool secure_;
00347 
00348   public:
00350     //\{
00352     Credentials ();
00354     explicit Credentials (const Authority&);
00356     explicit Credentials (const Path&);
00358     explicit Credentials (const Expires&);
00360     explicit Credentials (const Authority&, const Path&);
00362     explicit Credentials (const Authority&, const Path&, const Expires&);
00364     Credentials (const Credentials&);
00366     ~Credentials () throw();
00367 
00369     Credentials& operator = (const Credentials&);
00370 
00372     void swap (Credentials&) throw();
00373     //\}
00374 
00376     //\{
00378     Authority  authority () const;
00380     Authority& authority ();
00382     Path  path () const;
00384     Path& path ();
00386     Expires  expires () const;
00388     Expires& expires ();
00390     bool persist () const;
00392     bool  secure () const;
00394     bool& secure ();
00395     //\}
00396   };
00397 
00398 private:
00399   std::string name_;
00400   std::string value_;
00401   Credentials credentials_;
00402   
00403 public:
00405   //\{
00406                                 // Default constructor.
00407   Cookie ();
00409   explicit Cookie (const char* name);
00411   explicit Cookie (const char* name, const Credentials&);
00413   explicit Cookie (const char* name, const char* value);
00415   explicit Cookie (const char* name, const char* value, const Credentials&);
00417   explicit Cookie (const std::string& name);
00419   explicit Cookie (const std::string& name, const Credentials&);
00421   explicit Cookie (const std::string& name, const std::string& value);
00423   explicit Cookie (const std::string& name, const std::string& value,
00424                    const Credentials&);
00426   Cookie (const Cookie&);
00428   ~Cookie () throw();
00429 
00431   Cookie& operator = (const Cookie&);
00432 
00434   void swap (Cookie&) throw();
00435   //\}
00436 
00438   //\{
00440   std::string name () const;
00442   std::string value () const;
00444   Credentials  credentials () const;
00446   Credentials& credentials ();
00447   //\}
00448 };
00449 
00450 };                              // namespace ClearSilver
00451 
00452 #endif

Generated on Tue May 16 14:50:52 2006 for ClearSilver C++ Library by  doxygen 1.4.5