cgicc: HTTPCookie.h Source File

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

# HTTPCookie.h

Go to the documentation of this file.

    00001 /* -*-mode:c++; c-file-style: "gnu";-*- */
    00002 /*
    00003  *  $Id: HTTPCookie.h,v 1.8 2007/07/02 18:48:18 sebdiaz Exp $
    00004  *
    00005  *  Copyright (C) 1996 - 2004 Stephen F. Booth <sbooth@gnu.org>
    00006  *                       2007 Sebastien DIAZ <sebastien.diaz@gmail.com>
    00007  *  Part of the GNU cgicc library, http://www.gnu.org/software/cgicc
    00008  *
    00009  *  This library is free software; you can redistribute it and/or
    00010  *  modify it under the terms of the GNU Lesser General Public
    00011  *  License as published by the Free Software Foundation; either
    00012  *  version 3 of the License, or (at your option) any later version.
    00013  *
    00014  *  This library is distributed in the hope that it will be useful,
    00015  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    00016  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00017  *  Lesser General Public License for more details.
    00018  *
    00019  *  You should have received a copy of the GNU Lesser General Public
    00020  *  License along with this library; if not, write to the Free Software
    00021  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
    00022  */
    00023
    00024 #ifndef _HTTPCOOKIE_H_
    00025 #define _HTTPCOOKIE_H_ 1
    00026
    00027 #ifdef __GNUG__
    00028 #  pragma interface
    00029 #endif
    00030
    00035 #include <string>
    00036
    00037 #include "cgicc/MStreamable.h"
    00038 #include "cgicc/CgiDefs.h"
    00039
    00040 namespace cgicc {
    00041
    00042   // ============================================================
    00043   // Class HTTPCookie
    00044   // ============================================================
    00058   class CGICC_API HTTPCookie : public MStreamable
    00059   {
    00060   public:
    00061
    00064
    00070     HTTPCookie();
    00071
    00079     HTTPCookie(const std::string& name,
    00080                const std::string& value);
    00081
    00098     HTTPCookie(const std::string& name,
    00099                const std::string& value,
    00100                const std::string& comment,
    00101                const std::string& domain,
    00102                unsigned long maxAge,
    00103                const std::string& path,
    00104                bool secure);
    00105
    00113     HTTPCookie(const HTTPCookie& cookie);
    00114
    00120     virtual ~HTTPCookie();
    00122
    00123     // ============================================================
    00124
    00127
    00136     bool
    00137     operator== (const HTTPCookie& cookie)       const;
    00138
    00147     inline bool
    00148     operator != (const HTTPCookie& cookie)      const
    00149     { return ! operator==(cookie); }
    00150
    00151 #ifdef WIN32
    00152     /* Dummy operator for MSVC++ */
    00153     inline bool
    00154     operator< (const HTTPCookie& cookie)        const
    00155     { return false; }
    00156 #endif
    00157
    00158
    00159     // ============================================================
    00160
    00163
    00168     inline void
    00169     remove()
    00170     { fRemoved = true; }
    00171
    00177     inline void
    00178     setRemoved(bool removed)
    00179     { fRemoved = removed; }
    00185     inline bool
    00186     isRemoved()                                 const
    00187     { return fRemoved; }
    00200     HTTPCookie(const std::string& name,
    00201                const std::string& domain,
    00202                const std::string& path,
    00203                bool secure);
    00204
    00210     inline std::string
    00211     getName()                                   const
    00212     { return fName; }
    00213
    00219     inline std::string
    00220     getValue()                                  const
    00221     { return fValue; }
    00222
    00228     inline std::string
    00229     getComment()                                const
    00230     { return fComment; }
    00231
    00239     inline std::string
    00240     getDomain()                                 const
    00241     { return fDomain; }
    00242
    00248     inline unsigned long
    00249     getMaxAge()                                 const
    00250     { return fMaxAge; }
    00251
    00259     inline std::string
    00260     getPath()                                   const
    00261     { return fPath; }
    00262
    00268     inline bool
    00269     isSecure()                                  const
    00270     { return fSecure; }
    00272
    00273     // ============================================================
    00274
    00277
    00283     inline void
    00284     setName(const std::string& name)
    00285     { fName = name; }
    00286
    00292     inline void
    00293     setValue(const std::string& value)
    00294     { fValue = value; }
    00295
    00301     inline void
    00302     setComment(const std::string& comment)
    00303     { fComment = comment; }
    00304
    00313     inline void
    00314     setDomain(const std::string& domain)
    00315     { fDomain = domain; }
    00316
    00323     inline void
    00324     setMaxAge(unsigned long maxAge)
    00325     { fMaxAge = maxAge; }
    00326
    00334     inline void
    00335     setPath(const std::string& path)
    00336     { fPath = path; }
    00337
    00343     inline void
    00344     setSecure(bool secure)
    00345     { fSecure = secure; }
    00347
    00348     // ============================================================
    00349
    00352     virtual void
    00353     render(std::ostream& out)                   const;
    00355
    00356   private:
    00357     std::string         fName;
    00358     std::string         fValue;
    00359     std::string         fComment;
    00360     std::string         fDomain;
    00361     unsigned long       fMaxAge;
    00362     std::string         fPath;
    00363     bool                fSecure;
    00364         bool            fRemoved;
    00365   };
    00366
    00367 } // namespace cgicc
    00368
    00369 #endif /* ! _HTTPCOOKIE_H_ */