CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
configuration_list.h
1#pragma once
2
3#include <system/object_ext.h>
4#include <system/exceptions.h>
5#include <system/details/pointer_collection_helpers.h>
6#include <system/details/patterns.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
13namespace System
14{
15namespace Collections
16{
17namespace Generic
18{
19template <typename> class IEnumerable;
20} // namespace Generic
21} // namespace Collections
22} // namespace System
23
24namespace System {
25
26namespace Text {
27
28namespace Json {
29
30namespace Serialization {
31
32template<typename TItem>
34{
37
38 typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
39 RTTI_INFO_TEMPLATE_CLASS(ThisType, ThisTypeBaseTypesInfo);
40
41 template<typename FT0> friend class ConfigurationList;
42
43public:
54
55private:
56
57 class ConfigurationListDebugView final : public System::Object
58 {
59 typedef ConfigurationListDebugView ThisType;
61
62 typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
63 RTTI_INFO_TEMPLATE_CLASS(ThisType, ThisTypeBaseTypesInfo);
64
65 template<typename FT0> friend class ConfigurationList;
66
67 public:
68
70 {
71 return pr_collection->_list->ToArray();
72 }
73
74 ConfigurationListDebugView(System::SharedPtr<ConfigurationList<TItem>> collection) : pr_collection(collection)
75 {
76 }
77
78 protected:
79
80 #ifdef ASPOSE_GET_SHARED_MEMBERS
81 void GetSharedMembers(System::Object::shared_members_type& result) const override
82 {
83 Object::GetSharedMembers(result);
84
85 result.Add("System::Text::Json::Serialization::ConfigurationList::ConfigurationListDebugView::pr_collection", this->pr_collection);
86 }
87 #endif
88
89 private:
90
92
93 };
94
95public:
96
97 bool get_IsReadOnly() const override = 0;
98 int32_t get_Count() const override
99 {
100 return _list->get_Count();
101 }
102
104 {
105 _list = System::IsNull(source) ? System::MakeObject<Collections::Generic::List<TItem>>() : System::MakeObject<Collections::Generic::List<TItem>>(source);
106 }
107
108 TItem idx_get(int32_t index) const override
109 {
110 return _list->idx_get(index);
111 }
112
113 void idx_set(int32_t index, TItem value) override
114 {
115 if (System::IsNull(System::ExplicitCast<System::Object>(value)))
116 {
117 throw System::ArgumentNullException(u"value");
118 }
119
122 _list->idx_set(index, value);
124 }
125
126 void Add(const TItem& item) override
127 {
128 if (System::IsNull(System::ExplicitCast<System::Object>(item)))
129 {
130 throw System::ArgumentNullException(u"item");
131 }
132
134 ValidateAddedValue(item);
135 _list->Add(item);
137 }
138
139 void Clear() override
140 {
142 _list->Clear();
144 }
145
146 bool Contains(const TItem& item) const override
147 {
148 return _list->Contains(item);
149 }
150
151 void CopyTo(System::SharedPtr<Array<TItem>> array, int32_t arrayIndex) override
152 {
153 _list->CopyTo(array, arrayIndex);
154 }
155
157 {
158 return _list->GetEnumerator();
159 }
160
161 int32_t IndexOf(const TItem& item) const override
162 {
163 return _list->IndexOf(item);
164 }
165
166 void Insert(int32_t index, const TItem& item) override
167 {
168 if (System::IsNull(System::ExplicitCast<System::Object>(item)))
169 {
170 throw System::ArgumentNullException(u"item");
171 }
172
174 ValidateAddedValue(item);
175 _list->Insert(index, item);
177 }
178
179 bool Remove(const TItem& item) override
180 {
182 bool removed = _list->Remove(item);
183 if (removed)
184 {
186 }
187
188 return removed;
189 }
190
191 void RemoveAt(int32_t index) override
192 {
194 _list->RemoveAt(index);
196 }
197
200 iterator begin() noexcept
201 {
202 return _list->begin();
203 }
204
207 iterator end() noexcept
208 {
209 return _list->end();
210 }
211
214 const_iterator begin() const noexcept
215 {
216 return _list->cbegin();
217 }
218
221 const_iterator end() const noexcept
222 {
223 return _list->cend();
224 }
225
228 const_iterator cbegin() const noexcept
229 {
230 return _list->cbegin();
231 }
232
235 const_iterator cend() const noexcept
236 {
237 return _list->cend();
238 }
239
245 {
246 return _list->virtualizeBeginIterator();
247 }
248
254 {
255 return _list->virtualizeEndIterator();
256 }
257
263 {
264 return _list->virtualizeBeginConstIterator();
265 }
266
272 {
273 return _list->virtualizeEndConstIterator();
274 }
275
276 void SetTemplateWeakPtr(uint32_t argument) override
277 {
278 switch (argument)
279 {
280 case 0:
281 System::Details::CollectionHelpers::SetWeakPointer(0, _list);
282 break;
283
284 }
285 }
286
287protected:
288
290
291 virtual void OnCollectionModifying() = 0;
292 virtual void OnCollectionModified()
293 {
294 }
295
296 virtual void ValidateAddedValue(TItem item)
297 {
298 ASPOSE_UNUSED(item);
299 }
300
302 {
303 }
304
305 #ifdef ASPOSE_GET_SHARED_MEMBERS
306 void GetSharedMembers(System::Object::shared_members_type& result) const override
307 {
308 Object::GetSharedMembers(result);
309
310 result.Add("System::Text::Json::Serialization::ConfigurationList::_list", this->_list);
311 }
312 #endif
313
314private:
315
316 String get_DebuggerDisplay()
317 {
318 return System::String::Format(u"Count = {0}, IsReadOnly = {1}", get_Count(), get_IsReadOnly());
319 }
320
321};
322
323} // namespace Serialization
324} // namespace Json
325} // namespace Text
326} // namespace System
Class that represents an array data structure. Objects of this class should only be allocated using S...
Definition: array.h:296
T virtualized_iterator_element
Inner iterator element type.
Definition: ienumerable.h:359
System::Details::VirtualizedIteratorBase< T > virtualized_iterator
Inner iterator base type.
Definition: ienumerable.h:357
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
vector_t::const_iterator const_iterator
Const iterator type.
Definition: list.h:149
vector_t::iterator iterator
Iterator type.
Definition: list.h:147
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
static String Format(const SharedPtr< IFormatProvider > &fp, const String &format, const Args &... args)
Formats string in C# style.
Definition: string.h:1449
Definition: configuration_list.h:34
TItem idx_get(int32_t index) const override
Definition: configuration_list.h:108
virtualized_iterator * virtualizeBeginIterator() override
Gets iterator pointing to the first element (if any) of the collection.
Definition: configuration_list.h:244
virtualized_iterator * virtualizeEndConstIterator() const override
Gets iterator pointing right after the last element (if any)of the const-qualified instance of the co...
Definition: configuration_list.h:271
const_iterator cbegin() const noexcept
Gets iterator pointing to the first const-qualified element (if any) of the collection.
Definition: configuration_list.h:228
typename iterator_holder_type::const_iterator const_iterator
Const iterator type.
Definition: configuration_list.h:49
int32_t IndexOf(const TItem &item) const override
Gets index of first appearance of item in container.
Definition: configuration_list.h:161
ConfigurationList(System::SharedPtr< Collections::Generic::IEnumerable< TItem > > source=nullptr)
Definition: configuration_list.h:103
virtual void OnCollectionModified()
Definition: configuration_list.h:292
void Clear() override
Deletes all elements from collection.
Definition: configuration_list.h:139
const_iterator cend() const noexcept
Gets iterator pointing right after the last const-qualified element (if any) of the collection.
Definition: configuration_list.h:235
virtual void ValidateAddedValue(TItem item)
Definition: configuration_list.h:296
void RemoveAt(int32_t index) override
Definition: configuration_list.h:191
void idx_set(int32_t index, TItem value) override
Definition: configuration_list.h:113
typename iterator_holder_type::virtualized_iterator_element virtualized_iterator_element
Virtualized element type.
Definition: configuration_list.h:51
const_iterator end() const noexcept
Gets iterator pointing right after the last element (if any) of the const-qualified instance of the c...
Definition: configuration_list.h:221
iterator begin() noexcept
Gets iterator pointing to the first element (if any) of the collection.
Definition: configuration_list.h:200
const_iterator begin() const noexcept
Gets iterator pointing to the first element (if any) of the const-qualified instance of the collectio...
Definition: configuration_list.h:214
bool get_IsReadOnly() const override=0
Checks if collection is read only.
virtual ~ConfigurationList()
Definition: configuration_list.h:301
virtualized_iterator * virtualizeBeginConstIterator() const override
Gets iterator pointing to the first element (if any)of the const-qualified instance of the collection...
Definition: configuration_list.h:262
virtualized_iterator * virtualizeEndIterator() override
Gets iterator pointing right after the last element (if any) of the collection.
Definition: configuration_list.h:253
void Add(const TItem &item) override
Adds element into collection.
Definition: configuration_list.h:126
int32_t get_Count() const override
Gets number of elements in collection.
Definition: configuration_list.h:98
System::SharedPtr< Collections::Generic::IEnumerator< TItem > > GetEnumerator() override
Gets enumerator.
Definition: configuration_list.h:156
typename iterator_holder_type::virtualized_iterator virtualized_iterator
Virtualized type.
Definition: configuration_list.h:53
void SetTemplateWeakPtr(uint32_t argument) override
Set n'th template argument a weak pointer (rather than shared). Allows switching pointers in containe...
Definition: configuration_list.h:276
void CopyTo(System::SharedPtr< Array< TItem > > array, int32_t arrayIndex) override
Definition: configuration_list.h:151
bool Remove(const TItem &item) override
Deletes element from collection.
Definition: configuration_list.h:179
System::SharedPtr< Collections::Generic::List< TItem > > _list
Definition: configuration_list.h:289
iterator end() noexcept
Gets iterator pointing right after the last element (if any) of the collection.
Definition: configuration_list.h:207
void Insert(int32_t index, const TItem &item) override
Definition: configuration_list.h:166
bool Contains(const TItem &item) const override
Checks if element is present in collection.
Definition: configuration_list.h:146
typename iterator_holder_type::iterator iterator
Iterator type.
Definition: configuration_list.h:47
@ Text
Defines color adjustment information for text.
Definition: db_command.h:9
std::enable_if<!IsSmartPtr< T >::value, SmartPtr< T > >::type MakeObject(Args &&... args)
Creates object on heap and returns shared pointer to it.
Definition: smart_ptr.h:1496