CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
queue_of_t_converter.h
1#pragma once
2
3#include <system/type_info.h>
4#include <system/object_ext.h>
5#include <system/nullable.h>
6#include <system/details/pointer_collection_helpers.h>
7#include <system/constraints.h>
8#include <system/collections/queue.h>
9#include <cstdint>
10
11#include "system/text/json/serialization/converters/collection/i_enumerable_default_converter.h"
12#include "system/text/json/serialization/read_stack.h"
13#include "system/text/json/serialization/read_stack_frame.h"
14#include "system/text/json/reader/utf8_json_reader.h"
15#include "system/text/json/throw_helper.h"
16
17namespace System
18{
19namespace Text
20{
21namespace Json
22{
23class JsonSerializerOptions;
24} // namespace Json
25} // namespace Text
26} // namespace System
27
28namespace System {
29
30namespace Text {
31
32namespace Json {
33
34namespace Serialization {
35
36namespace Converters {
37
38template<typename TCollection, typename TElement>
39class QueueOfTConverter final : public IEnumerableDefaultConverter<TCollection, TElement>
40{
42 assert_is_base_of(BaseT_Queue, TCollection);
43
46
47 typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
48 RTTI_INFO_TEMPLATE_CLASS(ThisType, ThisTypeBaseTypesInfo);
49
50 template<typename FT0, typename FT1> friend class QueueOfTConverter;
51
52public:
53
54 bool get_CanPopulate() override
55 {
56 return true;
57 }
58
59 void SetTemplateWeakPtr(uint32_t argument) override
60 {
61 switch (argument)
62 {
63 case 0:
65 break;
66
67 case 1:
69 break;
70
71 }
72 }
73
74protected:
75
76 void Add(const TElement& value, ReadStack& state) override
77 {
78 (System::ExplicitCast<TCollection>(state.Current.ReturnValue))->Enqueue(value);
79 }
80
82 {
83 ASPOSE_UNUSED(reader);
84 ASPOSE_UNUSED(options);
85 if (System::SafeInvoke(state.get_ParentProperty(), [&](auto&& expr){return expr->TryGetPrePopulatedValue(System::Ref(state));}) == true)
86 {
87 return;
88 }
89
90 if (state.Current.JsonTypeInfo->get_HasCreateObject() == false)
91 {
93 }
94
95 state.Current.ReturnValue = state.Current.JsonTypeInfo->CreateObjectInstance();
96 }
97
98
99};
100
101} // namespace Converters
102} // namespace Serialization
103} // namespace Json
104} // namespace Text
105} // namespace System
Queue class forward declaration.
Definition: queue.h:88
Pointer class to wrap types being allocated on heap. Use it to manage memory for classes inheriting O...
Definition: smart_ptr.h:180
System::SharedPtr< Object > ReturnValue
Definition: read_stack_frame.h:59
System::SharedPtr< System::Text::Json::Serialization::Metadata::JsonTypeInfoBase > JsonTypeInfo
Definition: read_stack_frame.h:60
Definition: read_stack.h:35
ReadStackFrame Current
Definition: read_stack.h:44
System::SharedPtr< Serialization::Metadata::JsonPropertyInfoBase > get_ParentProperty()
void SetTemplateWeakPtr(uint32_t argument) override
Set n'th template argument a weak pointer (rather than shared). Allows switching pointers in containe...
Definition: i_enumerable_default_converter.h:49
bool get_CanPopulate() override
Definition: queue_of_t_converter.h:54
void Add(const TElement &value, ReadStack &state) override
Definition: queue_of_t_converter.h:76
void SetTemplateWeakPtr(uint32_t argument) override
Set n'th template argument a weak pointer (rather than shared). Allows switching pointers in containe...
Definition: queue_of_t_converter.h:59
void CreateCollection(Utf8JsonReader &reader, ReadStack &state, System::SharedPtr< JsonSerializerOptions > options) override
Definition: queue_of_t_converter.h:81
Definition: json_collection_converter.h:43
static void ThrowNotSupportedException_SerializationNotSupported(const TypeInfo &propertyType)
Definition: utf8_json_reader.h:78
@ Text
Defines color adjustment information for text.
Definition: db_command.h:9
static auto SafeInvoke(T0 &&expr, T1 &&func)
Implementation of '?.' operator translation.
Definition: object_ext.h:1434