CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
json_object.h
1#pragma once
2
3#include <system/nullable.h>
4#include <system/collections/keyvalue_pair.h>
5#include <system/collections/ilist.h>
6#include <system/collections/idictionary.h>
7#include <system/collections/dictionary.h>
8#include <system/collections/list.h>
9#include <system/array.h>
10#include <cstdint>
11
12#include "system/text/json/nodes/json_node.h"
13#include "system/text/json/nodes/json_node_options.h"
14#include "system/text/json/document/json_element.h"
15
16namespace System
17{
18namespace Collections
19{
20namespace Generic
21{
22template <typename> class ICollection;
23template <typename> class IEnumerable;
24template <typename> class IEnumerator;
25} // namespace Generic
26} // namespace Collections
27namespace Text
28{
29namespace Json
30{
31class JsonSerializerOptions;
32enum class JsonValueKind : uint8_t;
33namespace Serialization
34{
35namespace Converters
36{
37class JsonNodeConverter;
38class JsonObjectConverter;
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 JsonObject final : public JsonNode, public Collections::Generic::IDictionary<String, System::SharedPtr<JsonNode>>, public Collections::Generic::IList<Collections::Generic::KeyValuePair<String, System::SharedPtr<JsonNode>>>
56{
57 typedef JsonObject ThisType;
58 typedef JsonNode BaseType;
61
62 typedef ::System::BaseTypesInfo<BaseType, BaseType1, BaseType2> ThisTypeBaseTypesInfo;
63 RTTI_INFO_DECL();
64
65 friend class JsonNode;
68
69private:
70
71 class DebugView final : public System::Object
72 {
73 typedef DebugView ThisType;
75
76 typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
77 RTTI_INFO_DECL();
78
79 private:
80
81 class DebugViewProperty : public System::Object, public System::Details::BoxableObjectBase
82 {
83 typedef DebugViewProperty ThisType;
85
86 typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
87 RTTI_INFO_DECL();
88
89 public:
90
93
94 String get_Display();
95
96 DebugViewProperty();
97
98 protected:
99
100 #ifdef ASPOSE_GET_SHARED_MEMBERS
101 void GetSharedMembers(System::Object::shared_members_type& result) const override;
102 #endif
103
104 };
105
106 public:
107
108 String get_Json();
109 String get_Path();
110
111 DebugView(System::SharedPtr<JsonObject> node);
112
113 protected:
114
115 #ifdef ASPOSE_GET_SHARED_MEMBERS
116 void GetSharedMembers(System::Object::shared_members_type& result) const override;
117 #endif
118
119 private:
120
122
124
125 };
126
127public:
128
129 int32_t get_Count() const override;
130
131 System::SharedPtr<JsonNode> idx_get(const String& propertyName) const override;
132 void idx_set(const String& propertyName, System::SharedPtr<JsonNode> value) override;
135
138
141 bool TryGetPropertyValue(String propertyName, System::SharedPtr<JsonNode>& jsonNode, int32_t& index);
143 void Add(const String& propertyName, const System::SharedPtr<JsonNode>& value) override;
144 bool TryAdd(String propertyName, System::SharedPtr<JsonNode> value);
145 bool TryAdd(String propertyName, System::SharedPtr<JsonNode> value, int32_t& index);
147 void Clear() override;
148 bool ContainsKey(const String& propertyName) const override;
149 bool Remove(const String& propertyName) override;
152 void SetAt(int32_t index, String propertyName, System::SharedPtr<JsonNode> value);
153 void SetAt(int32_t index, System::SharedPtr<JsonNode> value);
154 int32_t IndexOf(const String& propertyName) const;
155 void Insert(int32_t index, String propertyName, System::SharedPtr<JsonNode> value);
156 void RemoveAt(int32_t index) override;
157
158protected:
159
161
163
165
172 void SetItem(String propertyName, System::SharedPtr<JsonNode> value);
173
174 virtual ~JsonObject();
175
176 #ifdef ASPOSE_GET_SHARED_MEMBERS
177 void GetSharedMembers(System::Object::shared_members_type& result) const override;
178 #endif
179
180private:
181
184
185 Nullable<JsonElement> _jsonElement;
186
187 System::SharedPtr<PropertyList> get_Dictionary() const;
188
191
194 bool get_IsReadOnly() const override;
195
196 System::SharedPtr<JsonNode> GetItem(int32_t index) override;
197 void SetItem(int32_t index, System::SharedPtr<JsonNode> value) override;
198 JsonValueKind GetValueKindCore() override;
199 void DetachParent(System::SharedPtr<JsonNode> item);
201 bool Contains(const PropertyType& item) const override;
202 void CopyTo(System::SharedPtr<Array<PropertyType>> array, int32_t index) override;
203 bool Remove(const PropertyType& item) override;
204 bool TryGetValue(const String& propertyName, System::SharedPtr<JsonNode>& jsonNode) const override;
205 System::SharedPtr<PropertyList> InitializeDictionary();
207 void GetUnderlyingRepresentation(System::SharedPtr<PropertyList>& dictionary, Nullable<JsonElement>& jsonElement);
208 void AddEntry(const String& propertyName, const System::SharedPtr<JsonNode>& value);
209 void SetEntryAt(int32_t index, const String& propertyName, const System::SharedPtr<JsonNode>& value);
210 void SetEntryAt(int32_t index, const System::SharedPtr<JsonNode>& value);
211 int32_t IndexOfKey(const String& propertyName) const;
212 int32_t IndexOfEntry(const PropertyType& item) const;
213 bool RemoveKey(const String& propertyName);
214 void RemoveEntryAt(int32_t index);
215 void ReindexFrom(int32_t startIndex);
216
217 int32_t IndexOf(const PropertyType& item) const override;
218 void Insert(int32_t index, const PropertyType& item) override;
219};
220
221} // namespace Nodes
222} // namespace Json
223} // namespace Text
224} // namespace System
Class that represents an array data structure. Objects of this class should only be allocated using S...
Definition: array.h:296
Forward declaration of Dictionary class.
Definition: dictionary.h:96
Interface for dictionary-alike containers. Objects of this class should only be allocated using Syste...
Definition: idictionary.h:21
Interface of object providing enumerator on contained elements.
Definition: ienumerable.h:26
Interface of indexed container of elements. Objects of this class should only be allocated using Syst...
Definition: ilist.h:20
Pair of key and value. This type should be allocated on stack and passed to functions by value or by ...
Definition: keyvalue_pair.h:20
List forward declaration.
Definition: list.h:129
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
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_node.h:54
Definition: json_object.h:56
bool DeepEqualsCore(System::SharedPtr< JsonNode > node) override
void WriteTo(System::SharedPtr< Utf8JsonWriter > writer, System::SharedPtr< JsonSerializerOptions > options=nullptr) override
void GetPath(ValueStringBuilder &path, System::SharedPtr< JsonNode > child) override
void WriteContentsTo(System::SharedPtr< Utf8JsonWriter > writer, System::SharedPtr< JsonSerializerOptions > options)
void Add(const Collections::Generic::KeyValuePair< String, System::SharedPtr< JsonNode > > &property) override
JsonObject(Nullable< JsonNodeOptions > options=nullptr)
System::SharedPtr< JsonNode > idx_get(const String &propertyName) const override
Getter function.
bool TryGetPropertyValue(String propertyName, System::SharedPtr< JsonNode > &jsonNode)
bool TryAdd(String propertyName, System::SharedPtr< JsonNode > value, int32_t &index)
JsonObject(System::SharedPtr< Collections::Generic::IEnumerable< Collections::Generic::KeyValuePair< String, System::SharedPtr< JsonNode > > > > properties, Nullable< JsonNodeOptions > options=nullptr)
System::SharedPtr< JsonNode > DeepCloneCore() override
void RemoveAt(int32_t index) override
bool ContainsKey(const String &propertyName) const override
Checks if container contains key.
void SetAt(int32_t index, System::SharedPtr< JsonNode > value)
Collections::Generic::KeyValuePair< String, System::SharedPtr< JsonNode > > idx_get(int32_t index) const override
void SetAt(int32_t index, String propertyName, System::SharedPtr< JsonNode > value)
void idx_set(const String &propertyName, System::SharedPtr< JsonNode > value) override
static System::SharedPtr< JsonObject > Create(JsonElement element, Nullable< JsonNodeOptions > options=nullptr)
bool TryAdd(String propertyName, System::SharedPtr< JsonNode > value)
String GetPropertyName(System::SharedPtr< JsonNode > node)
void SetItem(String propertyName, System::SharedPtr< JsonNode > value)
void Clear() override
Deletes all elements from collection.
System::SharedPtr< Collections::Generic::IEnumerator< Collections::Generic::KeyValuePair< String, System::SharedPtr< JsonNode > > > > GetEnumerator() override
Gets enumerator.
MEMBER_FUNCTION_MAKE_OBJECT_DECLARATION(JsonObject, CODEPORTING_ARGS(JsonElement element, Nullable< JsonNodeOptions > options=nullptr))
bool Remove(const String &propertyName) override
Removes key from container.
Collections::Generic::KeyValuePair< String, System::SharedPtr< JsonNode > > GetAt(int32_t index)
int32_t IndexOf(const String &propertyName) const
System::SharedPtr< JsonNode > GetItem(String propertyName)
int32_t get_Count() const override
Gets number of elements in collection.
void Insert(int32_t index, String propertyName, System::SharedPtr< JsonNode > value)
Nullable< JsonElement > get_UnderlyingElement() override
bool TryGetPropertyValue(String propertyName, System::SharedPtr< JsonNode > &jsonNode, int32_t &index)
JsonObject(JsonElement element, Nullable< JsonNodeOptions > options=nullptr)
void Add(const String &propertyName, const System::SharedPtr< JsonNode > &value) override
void idx_set(int32_t index, Collections::Generic::KeyValuePair< String, System::SharedPtr< JsonNode > > value) override
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