CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
json_array.h
1#pragma once
2
3#include <system/object_ext.h>
4#include <system/nullable.h>
5#include <system/func.h>
6#include <system/details/yield.h>
7#include <system/collections/list.h>
8#include <system/collections/ilist.h>
9#include <system/collections/ienumerator.h>
10#include <system/array.h>
11#include <cstdint>
12
13#include "system/text/json/nodes/json_node.h"
14#include "system/text/json/nodes/json_node_options.h"
15#include "system/text/json/document/json_element.h"
16
17namespace System
18{
19namespace Collections
20{
21namespace Generic
22{
23template <typename> class IEnumerable;
24} // namespace Generic
25} // namespace Collections
26template <typename> class ReadOnlySpan;
27namespace Text
28{
29namespace Json
30{
31class JsonSerializerOptions;
32enum class JsonValueKind : uint8_t;
33namespace Serialization
34{
35namespace Converters
36{
37class JsonArrayConverter;
38class JsonNodeConverter;
39} // namespace Converters
40} // namespace Serialization
41class Utf8JsonWriter;
42} // namespace Json
43class ValueStringBuilder;
44} // namespace Text
45} // namespace System
46
47namespace System {
48
49namespace Text {
50
51namespace Json {
52
53namespace Nodes {
54
55class JsonArray final : public JsonNode, public Collections::Generic::IList<System::SharedPtr<JsonNode>>
56{
57 typedef JsonArray ThisType;
58 typedef JsonNode BaseType;
60
61 typedef ::System::BaseTypesInfo<BaseType, BaseType1> ThisTypeBaseTypesInfo;
62 ASPOSECPP_SHARED_RTTI_INFO_DECL();
63
64 friend class JsonNode;
67
68private:
69
70 class DebugView final : public System::Object
71 {
72 typedef DebugView ThisType;
74
75 typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
76 ASPOSECPP_SHARED_RTTI_INFO_DECL();
77
78 private:
79
80 class DebugViewItem : public System::Object, public System::Details::BoxableObjectBase
81 {
82 typedef DebugViewItem ThisType;
84
85 typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
86 ASPOSECPP_SHARED_RTTI_INFO_DECL();
87
88 public:
89
91
92 String get_Display();
93
94 DebugViewItem();
95
96 protected:
97
98 #ifdef ASPOSE_GET_SHARED_MEMBERS
99 void GetSharedMembers(System::Object::shared_members_type& result) const override;
100 #endif
101
102 };
103
104 public:
105
106 String get_Json();
107 String get_Path();
108
109 DebugView(System::SharedPtr<JsonArray> node);
110
111 protected:
112
113 #ifdef ASPOSE_GET_SHARED_MEMBERS
114 void GetSharedMembers(System::Object::shared_members_type& result) const override;
115 #endif
116
117 private:
118
120
122
123 };
124
125public:
126
127 ASPOSECPP_SHARED_API int32_t get_Count() const override;
128
129 ASPOSECPP_SHARED_API System::SharedPtr<JsonNode> idx_get(int index) const override;
130 ASPOSECPP_SHARED_API void idx_set(int index, System::SharedPtr<JsonNode> value) override;
131
132 ASPOSECPP_SHARED_API JsonArray(Nullable<JsonNodeOptions> options = nullptr);
133 ASPOSECPP_SHARED_API JsonArray(JsonNodeOptions options, const System::SharedPtr<Array<System::SharedPtr<JsonNode>>>& items);
134 ASPOSECPP_SHARED_API JsonArray(const System::SharedPtr<Array<System::SharedPtr<JsonNode>>>& items);
135
136 template<typename T>
138 {
141 return System::MakeYieldEnumerable<T>([=](System::Details::YieldContext<T>& __) mutable
142 {
143 if (__.stage == 1) goto __1;
144 {
145 item_enumerator = (get_List())->GetEnumerator();
146 while (item_enumerator->MoveNext())
147 {
148 item = item_enumerator->get_Current();
149
150 __.YieldReturn(item == nullptr ? System::ExplicitCast<T>(System::ExplicitCast<System::Object>(nullptr)) : item->template GetValue<T>(), 1); return; __1:;
151 }
152 }
153 });
154 }
155
156 static ASPOSECPP_SHARED_API System::SharedPtr<JsonArray> Create(JsonElement element, Nullable<JsonNodeOptions> options = nullptr);
157 ASPOSECPP_SHARED_API void WriteTo(System::SharedPtr<Utf8JsonWriter> writer, System::SharedPtr<JsonSerializerOptions> options = nullptr) override;
158 ASPOSECPP_SHARED_API void Add(const System::SharedPtr<JsonNode>& item) override;
159 ASPOSECPP_SHARED_API void Clear() override;
160 ASPOSECPP_SHARED_API bool Contains(const System::SharedPtr<JsonNode>& item) const override;
161 ASPOSECPP_SHARED_API int32_t IndexOf(const System::SharedPtr<JsonNode>& item) const override;
162 ASPOSECPP_SHARED_API void Insert(int32_t index, const System::SharedPtr<JsonNode>& item) override;
163 ASPOSECPP_SHARED_API bool Remove(const System::SharedPtr<JsonNode>& item) override;
164 ASPOSECPP_SHARED_API void RemoveAt(int32_t index) override;
165 ASPOSECPP_SHARED_API int32_t RemoveAll(Func<System::SharedPtr<JsonNode>, bool> match);
166 ASPOSECPP_SHARED_API void RemoveRange(int32_t index, int32_t count);
168
169protected:
170
171 ASPOSECPP_SHARED_API Nullable<JsonElement> get_UnderlyingElement() override;
172
173 ASPOSECPP_SHARED_API System::SharedPtr<JsonNode> DeepCloneCore() override;
174 ASPOSECPP_SHARED_API bool DeepEqualsCore(System::SharedPtr<JsonNode> node) override;
175 ASPOSECPP_SHARED_API int32_t GetElementIndex(System::SharedPtr<JsonNode> node);
176
177 ASPOSECPP_SHARED_API JsonArray(JsonElement element, Nullable<JsonNodeOptions> options = nullptr);
178
180
181 ASPOSECPP_SHARED_API void GetPath(ValueStringBuilder& path, System::SharedPtr<JsonNode> child) override;
182
183 virtual ~JsonArray();
184
185 #ifdef ASPOSE_GET_SHARED_MEMBERS
186 ASPOSECPP_SHARED_API void GetSharedMembers(System::Object::shared_members_type& result) const override;
187 #endif
188
189private:
190
191 Nullable<JsonElement> _jsonElement;
193
195 ASPOSECPP_SHARED_API bool get_IsReadOnly() const override;
196
197 ASPOSECPP_SHARED_API JsonValueKind GetValueKindCore() override;
198 ASPOSECPP_SHARED_API void InitializeFromArray(System::SharedPtr<Array<System::SharedPtr<JsonNode>>> items);
199 ASPOSECPP_SHARED_API void InitializeFromSpan(ReadOnlySpan<System::SharedPtr<JsonNode>> items);
200 ASPOSECPP_SHARED_API System::SharedPtr<JsonNode> GetItem(int32_t index) override;
201 ASPOSECPP_SHARED_API void SetItem(int32_t index, System::SharedPtr<JsonNode> value) override;
203 ASPOSECPP_SHARED_API void GetUnderlyingRepresentation(System::SharedPtr<System::Collections::Generic::List<System::SharedPtr<JsonNode>>>& list, Nullable<JsonElement>& jsonElement);
204 ASPOSECPP_SHARED_API void CopyTo(System::SharedPtr<Array<System::SharedPtr<JsonNode>>> array, int32_t index) override;
205 static ASPOSECPP_SHARED_API void DetachParent(System::SharedPtr<JsonNode> item);
206
207};
208
209} // namespace Nodes
210} // namespace Json
211} // namespace Text
212} // namespace System
Class that represents an array data structure. Objects of this class should only be allocated using S...
Definition: array.h:296
Interface of indexed container of elements. Objects of this class should only be allocated using Syst...
Definition: ilist.h:20
List forward declaration.
Definition: list.h:129
Function delegate. This type should be allocated on stack and passed to functions by value or by refe...
Definition: func.h:82
Forward declaration.
Definition: nullable.h:75
Base class that enables using methods available for System.Object class in C#. All non-trivial classe...
Definition: object.h:51
Forward to use within Span class.
Definition: span.h:415
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:126
Definition: json_element.h:59
Definition: json_array.h:56
void idx_set(int index, System::SharedPtr< JsonNode > value) override
JsonArray(const System::SharedPtr< Array< System::SharedPtr< JsonNode > > > &items)
JsonArray(Nullable< JsonNodeOptions > options=nullptr)
bool Remove(const System::SharedPtr< JsonNode > &item) override
Nullable< JsonElement > get_UnderlyingElement() override
MEMBER_FUNCTION_MAKE_OBJECT_DECLARATION(JsonArray, CODEPORTING_ARGS(JsonElement element, Nullable< JsonNodeOptions > options=nullptr))
System::SharedPtr< JsonNode > DeepCloneCore() override
System::SharedPtr< Collections::Generic::IEnumerable< T > > GetValues()
Definition: json_array.h:137
void RemoveAt(int32_t index) override
System::SharedPtr< JsonNode > idx_get(int index) const override
Gets element at specified index.
void Clear() override
Deletes all elements from collection.
bool Contains(const System::SharedPtr< JsonNode > &item) const override
JsonArray(JsonNodeOptions options, const System::SharedPtr< Array< System::SharedPtr< JsonNode > > > &items)
bool DeepEqualsCore(System::SharedPtr< JsonNode > node) override
int32_t IndexOf(const System::SharedPtr< JsonNode > &item) const override
void Add(const System::SharedPtr< JsonNode > &item) override
int32_t get_Count() const override
Gets number of elements in collection.
int32_t GetElementIndex(System::SharedPtr< JsonNode > node)
int32_t RemoveAll(Func< System::SharedPtr< JsonNode >, bool > match)
System::SharedPtr< Collections::Generic::IEnumerator< System::SharedPtr< JsonNode > > > GetEnumerator() override
Gets enumerator.
JsonArray(JsonElement element, Nullable< JsonNodeOptions > options=nullptr)
void WriteTo(System::SharedPtr< Utf8JsonWriter > writer, System::SharedPtr< JsonSerializerOptions > options=nullptr) override
void RemoveRange(int32_t index, int32_t count)
void GetPath(ValueStringBuilder &path, System::SharedPtr< JsonNode > child) override
static System::SharedPtr< JsonArray > Create(JsonElement element, Nullable< JsonNodeOptions > options=nullptr)
void Insert(int32_t index, const System::SharedPtr< JsonNode > &item) override
Definition: json_node.h:54
Definition: json_node_options.h:14
Definition: value_string_builder.h:17
@ Text
Defines color adjustment information for text.
JsonValueKind
Definition: json_value_kind.h:12
Definition: db_command.h:9