CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
dictionary_default_converter.h
1#pragma once
2
3#include <system/object_ext.h>
4#include <system/details/pointer_collection_helpers.h>
5#include <system/constraints.h>
6#include <system/collections/keyvalue_pair.h>
7#include <system/collections/ienumerator_ng.h>
8#include <system/collections/ienumerator.h>
9#include <system/collections/ienumerable.h>
10#include <cstdint>
11
12#include "system/text/json/serialization/converters/collection/json_dictionary_converter.h"
13#include "system/text/json/writer/utf8_json_writer.h"
14#include "system/text/json/serialization/json_serializer_options.h"
15#include "system/text/json/serialization/write_stack.h"
16#include "system/text/json/serialization/write_stack_frame.h"
17#include "system/text/json/serialization/json_converter.h"
18#include "system/text/json/serialization/stack_frame_property_state.h"
19
20namespace System {
21
22namespace Text {
23
24namespace Json {
25
26namespace Serialization {
27
28namespace Converters {
29
30template<typename TDictionary, typename TKey, typename TValue>
31class DictionaryDefaultConverter : public JsonDictionaryConverter<TDictionary, TKey, TValue>
32{
34 assert_is_base_of(BaseT_IEnumerable, TDictionary);
35
38
39 typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
40 RTTI_INFO_TEMPLATE_CLASS(ThisType, ThisTypeBaseTypesInfo);
41
42 template<typename FT0, typename FT1, typename FT2> friend class DictionaryDefaultConverter;
43
44public:
45
46 bool get_CanHaveMetadata() override
47 {
48 return true;
49 }
50
52 {
54 if (state.Current.CollectionEnumerator == nullptr)
55 {
56 enumerator = value->GetEnumerator();
57 state.Current.CollectionEnumerator = enumerator;
58 if (!enumerator->MoveNext())
59 {
60 enumerator->Dispose();
61 return true;
62 }
63 }
64 else
65 {
66 enumerator = System::ExplicitCast<System::Collections::Generic::IEnumerator<System::Collections::Generic::KeyValuePair<TKey, TValue>>>(state.Current.CollectionEnumerator);
67 }
68
72
73 do
74 {
75 if (this->ShouldFlush(System::Ref(state), writer))
76 {
77 return false;
78 }
79
81 {
83 TKey key = enumerator->get_Current().get_Key();
85 }
86
87 TValue element = enumerator->get_Current().get_Value();
89 {
90 return false;
91 }
92
94 } while (enumerator->MoveNext());
95
96 enumerator->Dispose();
97 return true;
98 }
99
100 void SetTemplateWeakPtr(uint32_t argument) override
101 {
102 switch (argument)
103 {
104 case 0:
106 break;
107
108 case 1:
110 break;
111
112 case 2:
114 break;
115
116 }
117 }
118
119};
120
121} // namespace Converters
122} // namespace Serialization
123} // namespace Json
124} // namespace Text
125} // namespace System
Interface of object providing enumerator on contained elements.
Definition: ienumerable.h:26
static auto CoalesceAssign(T0 &value, T1 func) -> T0 &
Implementation of '??=' operator translation.
Definition: object_ext.h:748
Pointer class to wrap types being allocated on heap. Use it to manage memory for classes inheriting O...
Definition: smart_ptr.h:180
bool get_CanHaveMetadata() override
Definition: dictionary_default_converter.h:46
void SetTemplateWeakPtr(uint32_t argument) override
Set n'th template argument a weak pointer (rather than shared). Allows switching pointers in containe...
Definition: dictionary_default_converter.h:100
bool OnWriteResume(System::SharedPtr< Utf8JsonWriter > writer, TDictionary value, System::SharedPtr< JsonSerializerOptions > options, WriteStack &state) override
Definition: dictionary_default_converter.h:51
static bool ShouldFlush(WriteStack &state, System::SharedPtr< Utf8JsonWriter > writer)
bool TryWrite(System::SharedPtr< Utf8JsonWriter > writer, const TDictionary &value, System::SharedPtr< JsonSerializerOptions > options, WriteStack &state)
Definition: json_converter_of_t.h:378
void SetTemplateWeakPtr(uint32_t argument) override
Set n'th template argument a weak pointer (rather than shared). Allows switching pointers in containe...
Definition: json_dictionary_converter.h:404
System::SharedPtr< Object > CollectionEnumerator
Definition: write_stack_frame.h:53
bool IsWritingExtensionDataProperty
Definition: write_stack_frame.h:55
System::SharedPtr< System::Text::Json::Serialization::Metadata::JsonTypeInfoBase > JsonTypeInfo
Definition: write_stack_frame.h:56
StackFramePropertyState PropertyState
Definition: write_stack_frame.h:60
Definition: write_stack.h:34
WriteStackFrame Current
Definition: write_stack.h:45
@ Text
Defines color adjustment information for text.
Definition: db_command.h:9
decltype(Ref(std::declval< T & >())) Ref(const std::reference_wrapper< T > &wrapper)
Wrapper to make sure Ref(std::ref(DynamicWeakPtr)) works.
Definition: dynamic_weak_ptr.h:207