C++ Web Framework  3.0
httpcookie.h
1 /*
2  Copyright 2017 Herik Lima de Castro and Marcelo Medeiros Eler
3  Distributed under MIT license, or public domain if desired and
4  recognized in your jurisdiction.
5  See file LICENSE for detail.
6 */
7 
8 #ifndef HTTPCOOKIE_H
9 #define HTTPCOOKIE_H
10 
11 #include <QList>
12 #include <QDebug>
13 #include <QByteArray>
14 #include "cppwebframework_global.h"
15 
16 CWF_BEGIN_NAMESPACE
20 class CPPWEBFRAMEWORKSHARED_EXPORT HttpCookie
21 {
22  QByteArray name;
23  QByteArray value;
24  QByteArray comment;
25  QByteArray domain;
26  QByteArray path;
27  int maxAge = 0;
28  int version = 1;
29  bool secure = false;
30 public:
34  HttpCookie() = default;
39  explicit HttpCookie(const QByteArray &source);
45  HttpCookie(const QByteArray &name, const QByteArray &value);
47  QByteArray toByteArray() const ;
53  static QList<QByteArray> splitCSV(const QByteArray &source);
57  inline void setName(const QByteArray &value) noexcept { name = value; }
61  inline void setValue(const QByteArray &value) noexcept { this->value = value; }
65  inline void setComment(const QByteArray &value) noexcept { comment = value; }
69  inline void setDomain(const QByteArray &value) noexcept { domain = value; }
73  inline void setMaxAge(int value) noexcept { maxAge = value; }
77  inline void setPath(const QByteArray &value) noexcept { path = value; }
81  inline void setSecure(bool value) noexcept { secure = value; }
85  inline QByteArray getName() const noexcept { return name; }
89  inline QByteArray getValue() const noexcept { return value; }
93  inline QByteArray getComment() const noexcept { return comment; }
97  inline QByteArray getDomain() const noexcept { return domain; }
101  inline int getMaxAge() const noexcept { return maxAge; }
105  inline QByteArray getPath() const noexcept { return path; }
109  inline bool getSecure() const noexcept { return secure; }
113  inline int getVersion() const noexcept { return version; }
114 };
115 
116 CWF_END_NAMESPACE
117 
118 #endif // HTTPCOOKIE_H