CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
cookie.h
1
2#pragma once
3#include <cstdint>
4#include <system/array.h>
5#include <system/collections/icomparer.h>
6#include <system/date_time.h>
7#include <system/object.h>
8#include <system/shared_ptr.h>
9#include <system/string.h>
10#include <system/uri.h>
11
12namespace System { namespace Net {
13
15enum class CookieVariant
16{
18 Unknown,
20 Plain,
22 Rfc2109,
24 Rfc2965,
26 Default = static_cast<int32_t>(Rfc2109)
27};
28
33class ASPOSECPP_SHARED_CLASS Cookie final : public System::Object
34{
36 typedef Cookie ThisType;
39
41 typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
43 ASPOSECPP_SHARED_RTTI_INFO_DECL();
44
45public:
47 ASPOSECPP_SHARED_API static const int32_t MaxSupportedVersion;
49 ASPOSECPP_SHARED_API static const String MaxSupportedVersionString;
51 ASPOSECPP_SHARED_API static const String CommentAttributeName;
53 ASPOSECPP_SHARED_API static const String CommentUrlAttributeName;
55 ASPOSECPP_SHARED_API static const String DiscardAttributeName;
57 ASPOSECPP_SHARED_API static const String DomainAttributeName;
59 ASPOSECPP_SHARED_API static const String ExpiresAttributeName;
61 ASPOSECPP_SHARED_API static const String MaxAgeAttributeName;
63 ASPOSECPP_SHARED_API static const String PathAttributeName;
65 ASPOSECPP_SHARED_API static const String PortAttributeName;
67 ASPOSECPP_SHARED_API static const String SecureAttributeName;
69 ASPOSECPP_SHARED_API static const String VersionAttributeName;
71 ASPOSECPP_SHARED_API static const String HttpOnlyAttributeName;
73 ASPOSECPP_SHARED_API static const String SeparatorLiteral;
75 ASPOSECPP_SHARED_API static const String EqualsLiteral;
77 ASPOSECPP_SHARED_API static const String QuotesLiteral;
79 ASPOSECPP_SHARED_API static const String SpecialAttributeLiteral;
83 ASPOSECPP_SHARED_API static System::ArrayPtr<char16_t> ReservedToName;
85 ASPOSECPP_SHARED_API static System::ArrayPtr<char16_t> ReservedToValue;
90
93 ASPOSECPP_SHARED_API String get_Comment() const;
96 ASPOSECPP_SHARED_API void set_Comment(String value);
99 ASPOSECPP_SHARED_API System::SharedPtr<Uri> get_CommentUri() const;
102 ASPOSECPP_SHARED_API void set_CommentUri(System::SharedPtr<Uri> value);
105 ASPOSECPP_SHARED_API bool get_HttpOnly() const;
108 ASPOSECPP_SHARED_API void set_HttpOnly(bool value);
111 ASPOSECPP_SHARED_API bool get_Discard() const;
114 ASPOSECPP_SHARED_API void set_Discard(bool value);
117 ASPOSECPP_SHARED_API String get_Domain() const;
120 ASPOSECPP_SHARED_API void set_Domain(String value);
123 ASPOSECPP_SHARED_API bool get_DomainImplicit();
126 ASPOSECPP_SHARED_API void set_DomainImplicit(bool value);
129 ASPOSECPP_SHARED_API bool get_Expired();
132 ASPOSECPP_SHARED_API void set_Expired(bool value);
135 ASPOSECPP_SHARED_API DateTime get_Expires();
138 ASPOSECPP_SHARED_API void set_Expires(DateTime value);
141 ASPOSECPP_SHARED_API String get_Name() const;
144 ASPOSECPP_SHARED_API void set_Name(String value);
147 ASPOSECPP_SHARED_API String get_Path() const;
150 ASPOSECPP_SHARED_API void set_Path(String value);
153 ASPOSECPP_SHARED_API bool get_Plain() const;
156 ASPOSECPP_SHARED_API String get_Port() const;
159 ASPOSECPP_SHARED_API void set_Port(String value);
162 ASPOSECPP_SHARED_API System::ArrayPtr<int32_t> get_PortList() const;
165 ASPOSECPP_SHARED_API bool get_Secure() const;
168 ASPOSECPP_SHARED_API void set_Secure(bool value);
171 ASPOSECPP_SHARED_API DateTime get_TimeStamp() const;
174 ASPOSECPP_SHARED_API String get_Value() const;
177 ASPOSECPP_SHARED_API void set_Value(String value);
180 ASPOSECPP_SHARED_API CookieVariant get_Variant() const;
183 ASPOSECPP_SHARED_API void set_Variant(CookieVariant value);
186 ASPOSECPP_SHARED_API String get_DomainKey() const;
189 ASPOSECPP_SHARED_API int32_t get_Version() const;
192 ASPOSECPP_SHARED_API void set_Version(int32_t value);
193
195 ASPOSECPP_SHARED_API Cookie();
199 ASPOSECPP_SHARED_API Cookie(String name, String value);
204 ASPOSECPP_SHARED_API Cookie(String name, String value, String path);
210 ASPOSECPP_SHARED_API Cookie(String name, String value, String path, String domain);
211
215 ASPOSECPP_SHARED_API bool InternalSetName(String value);
218 ASPOSECPP_SHARED_API System::SharedPtr<Cookie> Clone();
229 ASPOSECPP_SHARED_API bool VerifySetDefaults(CookieVariant variant, System::SharedPtr<Uri> uri, bool isLocalDomain, String localDomain,
230 bool setDefault, bool shouldThrow);
234 ASPOSECPP_SHARED_API bool Equals(System::SharedPtr<Object> comparand) override;
236 ASPOSECPP_SHARED_API int32_t GetHashCode() const override;
238 ASPOSECPP_SHARED_API String ToString() const override;
241 ASPOSECPP_SHARED_API String ToServerString();
242
243private:
245 String _comment;
247 System::SharedPtr<Uri> _commentUri;
249 CookieVariant _cookieVariant;
251 bool _discard;
253 String _domain;
255 bool _domainImplicit;
257 DateTime _expires;
259 String _name;
261 String _path;
263 bool _pathImplicit;
265 String _port;
267 bool _portImplicit;
271 bool _secure;
273 bool _httpOnly;
275 DateTime _timeStamp;
277 String _value;
279 int32_t _version;
281 String _domainKey;
282
285 String get__Domain() const;
288 String get__Path() const;
291 String get__Port() const;
294 String get__Version() const;
295
300 static bool IsDomainEqualToHost(String domain, String host);
304 static bool DomainCharsTest(String name);
305
307 static struct __StaticConstructor__
308 {
309 __StaticConstructor__();
310 } s_constructor__;
311};
312
317class ASPOSECPP_SHARED_CLASS CookieComparer final : public System::Collections::Generic::IComparer<System::SharedPtr<System::Net::Cookie>>
318{
320 typedef CookieComparer ThisType;
323
325 typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
327 ASPOSECPP_SHARED_RTTI_INFO_DECL();
328
329public:
332 ASPOSECPP_SHARED_API static System::SharedPtr<CookieComparer> get_Instance();
333
339 ASPOSECPP_SHARED_API int Compare(args_type left, args_type right) const override;
340
341private:
343 static System::SharedPtr<CookieComparer> s_instance;
344
347 MEMBER_FUNCTION_MAKE_OBJECT(CookieComparer, CODEPORTING_ARGS(), CODEPORTING_ARGS());
348};
349
350class CookieTokenizer;
351
356class ASPOSECPP_SHARED_CLASS CookieParser : public System::Object
357{
359 typedef CookieParser ThisType;
361 typedef System::Object BaseType;
362
364 typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
366 ASPOSECPP_SHARED_RTTI_INFO_DECL();
367
368public:
371 ASPOSECPP_SHARED_API CookieParser(String cookieString);
372
375 ASPOSECPP_SHARED_API String GetString();
378 ASPOSECPP_SHARED_API System::SharedPtr<Cookie> Get();
381 ASPOSECPP_SHARED_API System::SharedPtr<Cookie> GetServer();
385 ASPOSECPP_SHARED_API static String CheckQuoted(String value);
386
387private:
391 System::SharedPtr<Cookie> _savedCookie;
392};
393
394
395}} // namespace System::Net
Interface that compares two objects in greater-equal-less sense. Objects of this class should only be...
Definition: icomparer.h:20
Represents a specific date and time value on the time continuum. This type should be allocated on sta...
Definition: date_time.h:50
Base class that enables using methods available for System.Object class in C#. All non-trivial classe...
Definition: object.h:62
Pointer class to wrap types being allocated on heap. Use it to manage memory for classes inheriting O...
Definition: smart_ptr.h:180
String class used across the library. Is a substitute for C# System.String when translating code....
Definition: string.h:122
CookieVariant
Enumerates the cookie specifications.
Definition: cookie.h:16
@ Plain
The plain cookie specification.
@ Rfc2109
The 'RFC 2109' cookie specification.
@ Rfc2965
The 'RFC 2965' cookie specification.
Definition: db_command.h:9
std::enable_if< IsExceptionWrapper< T >::value, constT & >::type Default()
Returns the default-constructed instance of the specified type.
Definition: default.h:16