3#include <system/scope_guard.h>
4#include <system/exceptions.h>
5#include <system/details/pointer_collection_helpers.h>
6#include <system/collections/list.h>
7#include <system/collections/ienumerator.h>
8#include <system/collections/ienumerable.h>
9#include <system/array.h>
15namespace Collections {
25 typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
26 RTTI_INFO_TEMPLATE_CLASS(
ThisType, ThisTypeBaseTypesInfo);
39 typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
40 RTTI_INFO_TEMPLATE_CLASS(
ThisType, ThisTypeBaseTypesInfo);
67 _base->get_InnerList()->CopyTo(array, index);
76 ASPOSECPP_SHARED_API T
idx_get(int32_t index)
78 if (index < 0 || index >= _base->get_Count())
80 throw ArgumentOutOfRangeException(u
"index");
83 return _base->get_InnerList()->idx_get(index);
92 ASPOSECPP_SHARED_API
void idx_set(int32_t index, T value)
94 if (index < 0 || index >= _base->get_Count())
96 throw ArgumentOutOfRangeException(u
"index");
99 _base->OnValidate(value);
100 T temp = _base->get_InnerList()->idx_get(index);
101 _base->OnSet(index, temp, value);
102 _base->get_InnerList()->idx_set(index, value);
105 _base->OnSetComplete(index, temp, value);
109 _base->get_InnerList()->idx_set(index, temp);
120 return _base->get_InnerList()->Contains(value);
129 ASPOSECPP_SHARED_API int32_t
Add(
const T& value)
131 _base->OnValidate(value);
132 _base->OnInsert(_base->get_InnerList()->get_Count(), value);
133 _base->get_InnerList()->Add(value);
134 int32_t index = _base->get_InnerList()->get_Count() - 1;
137 _base->OnInsertComplete(index, value);
141 _base->get_InnerList()->RemoveAt(index);
154 ASPOSECPP_SHARED_API
void Remove(
const T& value)
156 _base->OnValidate(value);
157 int32_t index = _base->get_InnerList()->IndexOf(value);
160 throw ArgumentException();
162 _base->OnRemove(index, value);
163 _base->get_InnerList()->RemoveAt(index);
166 _base->OnRemoveComplete(index, value);
170 _base->get_InnerList()->Insert(index, value);
181 ASPOSECPP_SHARED_API int32_t
IndexOf(
const T& value)
183 return _base->get_InnerList()->IndexOf(value);
195 ASPOSECPP_SHARED_API
void Insert(int32_t index,
const T& value)
197 if (index < 0 || index > _base->get_Count())
199 throw ArgumentOutOfRangeException(u
"index");
202 _base->OnValidate(value);
203 _base->OnInsert(index, value);
204 _base->get_InnerList()->Insert(index, value);
207 _base->OnInsertComplete(index, value);
211 _base->get_InnerList()->RemoveAt(index);
230 MEMBER_FUNCTION_MAKE_OBJECT(ListImpl, CODEPORTING_ARGS(
const SharedPtr<CollectionBase<T>>& base_), CODEPORTING_ARGS(base_));
232 #ifdef ASPOSE_GET_SHARED_MEMBERS
233 void GetSharedMembers(System::Object::shared_members_type& result)
const override
235 System::Object::GetSharedMembers(result);
237 result.Add(
"System::Collections::CollectionBase::ListImpl::_base", this->_base);
244 CollectionBase<T>*
const _base;
273 return _list->get_Count();
293 throw ArgumentOutOfRangeException(u
"index");
325 System::Details::CollectionHelpers::SetWeakPointer(0, _list);
326 System::Details::CollectionHelpers::SetWeakPointer(0, _impl);
352 System::Details::ThisProtector __local_self_ref(
this);
354 _list = System::MakeObject<System::Collections::Generic::List<T>>();
362 System::Details::ThisProtector __local_self_ref(
this);
364 _list = System::MakeObject<System::Collections::Generic::List<T>>(capacity);
372 virtual void OnSet(int32_t index,
const T& oldValue,
const T& newValue)
374 ASPOSE_UNUSED(index);
375 ASPOSE_UNUSED(oldValue);
376 ASPOSE_UNUSED(newValue);
382 virtual void OnInsert(int32_t index,
const T& value)
384 ASPOSE_UNUSED(index);
385 ASPOSE_UNUSED(value);
396 virtual void OnRemove(int32_t index,
const T& value)
398 ASPOSE_UNUSED(index);
399 ASPOSE_UNUSED(value);
407 if (value ==
nullptr)
409 throw ArgumentNullException(u
"value");
417 virtual void OnSetComplete(int32_t index,
const T& oldValue,
const T& newValue)
419 ASPOSE_UNUSED(index);
420 ASPOSE_UNUSED(oldValue);
421 ASPOSE_UNUSED(newValue);
429 ASPOSE_UNUSED(index);
430 ASPOSE_UNUSED(value);
443 ASPOSE_UNUSED(index);
444 ASPOSE_UNUSED(value);
452 #ifdef ASPOSE_GET_SHARED_MEMBERS
453 void GetSharedMembers(System::Object::shared_members_type& result)
const override
455 System::Object::GetSharedMembers(result);
457 result.Add(
"System::Collections::CollectionBase::_list", this->_list);
458 result.Add(
"System::Collections::CollectionBase::_impl", this->_impl);
Provides an interface for accessing the elements in the collection.
Definition: collection_base.h:35
void CopyTo(const ArrayPtr< T > &array, int32_t index)
Copies the entire collection to a compatible one-dimensional Array, starting at the specified index o...
Definition: collection_base.h:65
T idx_get(int32_t index)
Returns the element at the specified index.
Definition: collection_base.h:76
void Remove(const T &value)
Removes the first occurrence of a specific element from the collection.
Definition: collection_base.h:154
void idx_set(int32_t index, T value)
Sets the element at the specified index.
Definition: collection_base.h:92
int32_t Add(const T &value)
Adds a element to the end of the collection.
Definition: collection_base.h:129
bool Contains(const T &value)
Determines whether the collection contains a specific element.
Definition: collection_base.h:118
void Insert(int32_t index, const T &value)
Inserts an element into the collection at the specified index.
Definition: collection_base.h:195
int32_t IndexOf(const T &value)
Searches for the specified element and returns the zero-based index of the first occurrence within th...
Definition: collection_base.h:181
Provides an abstract base class for a strongly typed collection.
Definition: collection_base.h:21
int32_t get_Capacity()
Returns the number of elements that the collection can contain.
Definition: collection_base.h:253
virtual void OnClearComplete()
Performs additional custom processes after clearing the contents of the collection instance.
Definition: collection_base.h:434
CollectionBase(int32_t capacity)
Initializes a new instance of the Collections::CollectionBase class with the specified capacity.
Definition: collection_base.h:360
virtual ~CollectionBase()
Definition: collection_base.h:447
int32_t get_Count()
Returns the number of elements contained in the collection instance. This method cannot be overridden...
Definition: collection_base.h:271
virtual void OnValidate(const T &value)
Performs additional custom processes when validating a value.
Definition: collection_base.h:405
SharedPtr< Generic::IEnumerator< T > > GetEnumerator() override
Returns an enumerator that iterates through the collection instance.
Definition: collection_base.h:314
virtual void OnInsert(int32_t index, const T &value)
Performs additional custom processes before inserting a new element into the collection instance.
Definition: collection_base.h:382
void RemoveAt(int32_t index)
Removes the element at the specified index of the collection instance. This method is not overridable...
Definition: collection_base.h:289
virtual void OnSetComplete(int32_t index, const T &oldValue, const T &newValue)
Performs additional custom processes after setting a value in the collection instance.
Definition: collection_base.h:417
void set_Capacity(int32_t value)
Sets the number of elements that the collection can contain.
Definition: collection_base.h:262
virtual void OnSet(int32_t index, const T &oldValue, const T &newValue)
Performs additional custom processes before setting a value in the collection instance.
Definition: collection_base.h:372
void SetTemplateWeakPtr(uint32_t argument) override
Set n'th template argument a weak pointer (rather than shared). Allows switching pointers in containe...
Definition: collection_base.h:320
SharedPtr< System::Collections::Generic::List< T > > get_InnerList()
Returns a List containing the list of elements in the collection instance.
Definition: collection_base.h:337
virtual void OnRemove(int32_t index, const T &value)
Performs additional custom processes when removing an element from the collection instance.
Definition: collection_base.h:396
virtual void OnRemoveComplete(int32_t index, const T &value)
Performs additional custom processes after removing an element from the collection instance.
Definition: collection_base.h:441
SharedPtr< ListImpl > get_List()
Returns a ListImpl containing the list of elements in the collection instance.
Definition: collection_base.h:344
virtual void OnClear()
Performs additional custom processes when clearing the contents of the collection instance.
Definition: collection_base.h:389
void Clear()
Removes all objects from the collection instance. This method cannot be overridden.
Definition: collection_base.h:277
virtual void OnInsertComplete(int32_t index, const T &value)
Performs additional custom processes after inserting a new element into the collection instance.
Definition: collection_base.h:427
CollectionBase()
Initializes a new instance of the Collections::CollectionBase class with the default initial capacity...
Definition: collection_base.h:350
Interface of object providing enumerator on contained elements.
Definition: ienumerable.h:25
Base class that enables using methods available for System.Object class in C#. All non-trivial classe...
Definition: object.h:62
Pointer class to wrap types being allocated on heap. Use it to manage memory for classes inheriting O...
Definition: smart_ptr.h:180
Definition: db_command.h:9
SmartPtr< X > MakeSharedPtr(X *p)
Converts raw pointer to smart pointer.
Definition: smart_ptr.h:1650