4#include <system/action.h>
5#include <system/collections/icollection.h>
6#include <system/constraints.h>
7#include <system/details/pointer_collection_helpers.h>
8#include <system/object.h>
9#include <system/shared_ptr.h>
10#include <system/special_casts.h>
11#include <system/string.h>
13#include <net/http/headers/http_headers.h>
15namespace System {
namespace Net {
namespace Http {
namespace Headers {
26 assert_is_cs_class(T);
34 typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
36 RTTI_INFO_TEMPLATE_CLASS(
ThisType, ThisTypeBaseTypesInfo);
57 if (_specialValue ==
nullptr)
61 return _store->ContainsParsedValue(_headerName, _specialValue);
101 _headerName = headerName;
102 _specialValue = specialValue;
103 _validator = validator;
107 void Add(
const T& item)
override
110 _store->AddParsedValue(_headerName, item);
117 _store->Add(_headerName, input);
125 return _store->TryParseAndAddValue(_headerName, input);
131 _store->Remove(_headerName);
138 return _store->ContainsParsedValue(_headerName, item);
144 if (array ==
nullptr)
146 throw ArgumentNullException(u
"array");
149 if ((arrayIndex < 0) || (arrayIndex > array->get_Length()))
151 throw ArgumentOutOfRangeException(u
"arrayIndex");
156 if (storeValue ==
nullptr)
164 if (storeValues ==
nullptr)
168 if (arrayIndex == array->get_Length())
170 throw ArgumentException(u
"net_http_copyto_array_too_small");
172 array[arrayIndex] =
nullptr;
184 return _store->RemoveParsedValue(_headerName, item);
190 auto list = System::MakeObject<Collections::Generic::List<T>>();
196 if (storeValue ==
nullptr)
205 if (storeValues ==
nullptr)
207 CODEPORTING_DEBUG_ASSERT1(System::ObjectExt::Is<T>(storeValue));
209 T result = System::ExplicitCast<typename T::Pointee_>(storeValue);
215 auto item_enumerator = (storeValues)->GetEnumerator();
216 while (item_enumerator->MoveNext())
218 auto&& item = item_enumerator->get_Current();
219 CODEPORTING_DEBUG_ASSERT1(System::ObjectExt::Is<T>(item));
221 T result = System::ExplicitCast<typename T::Pointee_>(item);
230 return list->GetEnumerator();
236 return _store->GetHeaderString(_headerName);
243 if (!get_IsSpecialValueSet())
247 return _store->GetHeaderString(_headerName, _specialValue);
254 if (!_store->ContainsParsedValue(_headerName, _specialValue))
256 _store->AddParsedValue(_headerName, _specialValue);
266 _store->RemoveParsedValue(_headerName, _specialValue);
275 System::Details::CollectionHelpers::SetWeakPointer(_specialValue);
276 System::Details::CollectionHelpers::SetWeakPointer(0, _validator);
294 void CheckValue(
const T& item)
const
298 throw ArgumentNullException(u
"item");
302 if (_validator !=
nullptr)
310 int32_t GetCount()
const
316 if (storeValue ==
nullptr)
324 if (storeValues ==
nullptr)
330 return storeValues->get_Count();
345 typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
346 RTTI_INFO_TEMPLATE_CLASS(
ThisType, ThisTypeBaseTypesInfo);
362 if (_specialValue ==
nullptr)
366 return _store->ContainsParsedValue(_headerName, _specialValue);
371 headerName, store, nullptr,
378 headerName, store, nullptr,
384 headerName, store, specialValue,
393 _headerName = headerName;
395 _validator = validator;
406 _store->Add(_headerName, input);
411 return _store->TryParseAndAddValue(_headerName, input);
416 _store->Remove(_headerName);
422 return _store->ContainsParsedValue(_headerName,
ObjectExt::Box(item));
427 if (array ==
nullptr)
429 throw ArgumentNullException(u
"array");
432 if ((arrayIndex < 0) || (arrayIndex > array->get_Length()))
434 throw ArgumentOutOfRangeException(u
"arrayIndex");
439 if (storeValue ==
nullptr)
447 if (storeValues ==
nullptr)
451 if (arrayIndex == array->get_Length())
453 throw ArgumentException(u
"net_http_copyto_array_too_small");
455 array[arrayIndex] =
nullptr;
466 return _store->RemoveParsedValue(_headerName,
ObjectExt::Box(item));
471 auto list = System::MakeObject<Collections::Generic::List<String>>();
477 if (storeValue ==
nullptr)
486 if (storeValues ==
nullptr)
488 CODEPORTING_DEBUG_ASSERT1(System::ObjectExt::Is<String>(storeValue));
489 String result = ObjectExt::Unbox<String>(storeValue);
497 while (item_enumerator->MoveNext())
499 auto&& item = item_enumerator->get_Current();
500 CODEPORTING_DEBUG_ASSERT1(System::ObjectExt::Is<String>(item));
502 String result = ObjectExt::Unbox<String>(item);
510 return list->GetEnumerator();
515 return _store->GetHeaderString(_headerName);
524 return _store->GetHeaderString(_headerName, _specialValue);
530 if (!_store->ContainsParsedValue(_headerName, _specialValue))
532 _store->AddParsedValue(_headerName, _specialValue);
541 _store->RemoveParsedValue(_headerName, _specialValue);
549 System::Details::CollectionHelpers::SetWeakPointer(_specialValue);
550 System::Details::CollectionHelpers::SetWeakPointer(0, _validator);
561 void CheckValue(
String item)
const
565 throw ArgumentNullException(u
"item");
569 if (_validator !=
nullptr)
575 int32_t GetCount()
const
581 if (storeValue ==
nullptr)
589 if (storeValues ==
nullptr)
595 return storeValues->get_Count();
Interface of collection of elements. Objects of this class should only be allocated using System::Mak...
Definition: icollection.h:20
static std::enable_if< std::is_enum< T >::value, System::SmartPtr< System::Object > >::type Box(const T &value)
Boxes value types for converting to Object. Implementation for enum types.
Definition: object_ext.h:198
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
Subclass of System::SmartPtr which sets itself to weak mode at construction. Please note that this cl...
Definition: weak_ptr.h:18
Definition: db_command.h:9
std::enable_if_t< System::IsSmartPtr< From >::value, System::SharedPtr< System::Array< To > > > StaticCastArray(const System::SharedPtr< System::Array< From > > &from)
Performs casting of elements of the specified array to different type. Override for cases then From i...
Definition: special_casts.h:67
MulticastDelegate< void(Args...)> Action
Delegate type that references methods that have no return value.
Definition: action.h:40
SmartPtr< X > MakeSharedPtr(X *p)
Converts raw pointer to smart pointer.
Definition: smart_ptr.h:1650