HTTPCookie.h
Go to the documentation of this file.
1/* -*-mode:c++; c-file-style: "gnu";-*- */
2/*
3 * $Id: HTTPCookie.h,v 1.10 2014/04/23 20:55:07 sebdiaz Exp $
4 *
5 * Copyright (C) 1996 - 2004 Stephen F. Booth <sbooth@gnu.org>
6 * 2007 Sebastien DIAZ <sebastien.diaz@gmail.com>
7 * Part of the GNU cgicc library, http://www.gnu.org/software/cgicc
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 3 of the License, or (at your option) any later version.
13 *
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
22 */
23
24#ifndef _HTTPCOOKIE_H_
25#define _HTTPCOOKIE_H_ 1
26
27#ifdef __GNUG__
28# pragma interface
29#endif
30
35#include <string>
36
37#include "MStreamable.h"
38#include "CgiDefs.h"
39
40 namespace cgicc {
41
42 // ============================================================
43 // Class HTTPCookie
44 // ============================================================
58 class CGICC_API HTTPCookie : public MStreamable
59 {
60 public:
61
64
70 HTTPCookie();
71
79 HTTPCookie(const std::string& name,
80 const std::string& value);
81
98 HTTPCookie(const std::string& name,
99 const std::string& value,
100 const std::string& comment,
101 const std::string& domain,
102 unsigned long maxAge,
103 const std::string& path,
104 bool secure);
105
113 HTTPCookie(const HTTPCookie& cookie);
114
120 virtual ~HTTPCookie();
122
123 // ============================================================
124
127
136 bool
137 operator== (const HTTPCookie& cookie) const;
138
147 inline bool
148 operator != (const HTTPCookie& cookie) const
149 { return ! operator==(cookie); }
150
151#ifdef WIN32
152 /* Dummy operator for MSVC++ */
153 inline bool
154 operator< (const HTTPCookie& cookie) const
155 { return false; }
156#endif
158
159 // ============================================================
160
163
168 inline void
169 remove()
170 { fRemoved = true; }
171
177 inline void
178 setRemoved(bool removed)
179 { fRemoved = removed; }
185 inline bool
186 isRemoved() const
187 { return fRemoved; }
200 HTTPCookie(const std::string& name,
201 const std::string& domain,
202 const std::string& path,
203 bool secure);
204
210 inline std::string
211 getName() const
212 { return fName; }
213
219 inline std::string
220 getValue() const
221 { return fValue; }
222
228 inline std::string
229 getComment() const
230 { return fComment; }
231
239 inline std::string
240 getDomain() const
241 { return fDomain; }
242
248 inline unsigned long
249 getMaxAge() const
250 { return fMaxAge; }
251
259 inline std::string
260 getPath() const
261 { return fPath; }
262
268 inline bool
269 isSecure() const
270 { return fSecure; }
272
273 // ============================================================
274
277
283 inline void
284 setName(const std::string& name)
285 { fName = name; }
286
292 inline void
293 setValue(const std::string& value)
294 { fValue = value; }
295
301 inline void
302 setComment(const std::string& comment)
303 { fComment = comment; }
304
313 inline void
314 setDomain(const std::string& domain)
315 { fDomain = domain; }
316
323 inline void
324 setMaxAge(unsigned long maxAge)
325 { fMaxAge = maxAge; }
326
334 inline void
335 setPath(const std::string& path)
336 { fPath = path; }
337
343 inline void
344 setSecure(bool secure)
345 { fSecure = secure; }
347
348 // ============================================================
349
352 virtual void
353 render(std::ostream& out) const;
355
356 private:
357 std::string fName;
358 std::string fValue;
359 std::string fComment;
360 std::string fDomain;
361 unsigned long fMaxAge;
362 std::string fPath;
363 bool fSecure;
364 bool fRemoved;
365 };
366
367} // namespace cgicc
368
369#endif /* ! _HTTPCOOKIE_H_ */
CgiDefs.h
Platform and operating system specific macro definitions.
MStreamable.h
Abstract base class for all streamable objects.
cgicc::HTTPCookie
An HTTP cookie.
Definition: HTTPCookie.h:59
cgicc::HTTPCookie::setName
void setName(const std::string &name)
Set the name of this cookie.
Definition: HTTPCookie.h:284
cgicc::HTTPCookie::setPath
void setPath(const std::string &path)
Set the path of this cookie.
Definition: HTTPCookie.h:335
cgicc::HTTPCookie::setSecure
void setSecure(bool secure)
Mark this cookie as secure or unsecure.
Definition: HTTPCookie.h:344
cgicc::HTTPCookie::setRemoved
void setRemoved(bool removed)
Mark this cookie as secure or unsecure.
Definition: HTTPCookie.h:178
cgicc::HTTPCookie::getValue
std::string getValue() const
Get the value of this cookie.
Definition: HTTPCookie.h:220
cgicc::HTTPCookie::getComment
std::string getComment() const
Get the comment of this cookie.
Definition: HTTPCookie.h:229
cgicc::HTTPCookie::HTTPCookie
HTTPCookie()
Default Constructor.
cgicc::HTTPCookie::getPath
std::string getPath() const
Get the path of this cookie.
Definition: HTTPCookie.h:260
cgicc::HTTPCookie::~HTTPCookie
virtual ~HTTPCookie()
Destructor.
cgicc::HTTPCookie::setMaxAge
void setMaxAge(unsigned long maxAge)
Set the lifetime of this cookie, in seconds.
Definition: HTTPCookie.h:324
cgicc::HTTPCookie::HTTPCookie
HTTPCookie(const std::string &name, const std::string &value)
Create a new HTTPCookie.
cgicc::HTTPCookie::HTTPCookie
HTTPCookie(const std::string &name, const std::string &value, const std::string &comment, const std::string &domain, unsigned long maxAge, const std::string &path, bool secure)
Create a new fully-spefified HTTPCookie.
cgicc::HTTPCookie::getName
std::string getName() const
Get the name of this cookie.
Definition: HTTPCookie.h:211
cgicc::HTTPCookie::setValue
void setValue(const std::string &value)
Set the value of this cookie.
Definition: HTTPCookie.h:293
cgicc::HTTPCookie::render
virtual void render(std::ostream &out) const
Write this object to a stream.
cgicc::HTTPCookie::setComment
void setComment(const std::string &comment)
Set the comment of this cookie.
Definition: HTTPCookie.h:302
cgicc::HTTPCookie::getMaxAge
unsigned long getMaxAge() const
Get the lifetime of this cookie, in seconds.
Definition: HTTPCookie.h:249
cgicc::HTTPCookie::remove
void remove()
Mark this cookie as secure or unsecure.
Definition: HTTPCookie.h:169
cgicc::HTTPCookie::isRemoved
bool isRemoved() const
Determine if this is a removed cookie.
Definition: HTTPCookie.h:186
cgicc::HTTPCookie::setDomain
void setDomain(const std::string &domain)
Set the domain of this cookie.
Definition: HTTPCookie.h:314
cgicc::HTTPCookie::isSecure
bool isSecure() const
Determine if this is a secure cookie.
Definition: HTTPCookie.h:269
cgicc::HTTPCookie::HTTPCookie
HTTPCookie(const std::string &name, const std::string &domain, const std::string &path, bool secure)
Create a new partially-spefified HTTPCookie for deletion.
cgicc::HTTPCookie::HTTPCookie
HTTPCookie(const HTTPCookie &cookie)
Copy constructor.
cgicc::HTTPCookie::getDomain
std::string getDomain() const
Get the domain for which this cookie is valid.
Definition: HTTPCookie.h:240
cgicc::MStreamable
Mix-in streamable interface.
Definition: MStreamable.h:67
cgicc::comment
An HTML comment.
Definition: HTMLClasses.h:93
cgicc
The namespace containing the cgicc library.
Definition: Cgicc.h:52