CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
base_kv_collection.h
1
2#ifndef _aspose_system_colllections_base_kv_collection_h_
3#define _aspose_system_colllections_base_kv_collection_h_
4
5#include <system/collections/ikvcollection.h>
6#include <system/diagnostics/debug.h>
7
8namespace System { namespace Collections { namespace Generic {
9
16template <typename Dict, typename KV>
17class ASPOSECPP_SHARED_CLASS BaseKVCollection : public IKVCollection<KV>
18{
19public:
22 BaseKVCollection(const typename Dict::Ptr& dict) : m_dict(dict) {}
23
24 // ICollection
27 virtual int get_Count() const override
28 {
29 return m_dict->get_Count();
30 }
34 virtual void CopyTo(ArrayPtr<KV> arr, int index) override
35 {
36 if (!arr)
37 throw ArgumentNullException();
38
39 if (index < 0)
40 throw ArgumentOutOfRangeException();
41
42 if (index + get_Count() > arr->get_Length())
43 throw ArgumentException();
44
45 SharedPtr<IEnumerator<KV>> e = this->GetEnumerator();
46 while(e->MoveNext())
47 (*arr)[index++] = e->get_Current();
48 }
50 using ICollection<KV>::CopyTo;
51
54 void SetTemplateWeakPtr(uint32_t argument) override
55 {
56 ASPOSE_UNUSED(argument);
57 CODEPORTING_DEBUG_ASSERT(!"BaseKVCollection doesn't own data structures so it can't be used to store Weak pointers");
58 }
59
60protected:
62 ~BaseKVCollection() override {}
63
65 typename Dict::Ptr m_dict;
66};
67
68}}} // namespace System::Collections::Generic
69
70#endif // _aspose_system_colllections_base_kv_collection_h_
Holds common code for collections of keys or values. Objects of this class should only be allocated u...
Definition: base_kv_collection.h:18
void SetTemplateWeakPtr(uint32_t argument) override
Enables compilation, but doesn't actually do anything as this structure doesn't own data.
Definition: base_kv_collection.h:54
BaseKVCollection(const typename Dict::Ptr &dict)
Creates collection.
Definition: base_kv_collection.h:22
virtual int get_Count() const override
Gets number of elements.
Definition: base_kv_collection.h:27
Dict::Ptr m_dict
Dictionary to wrap.
Definition: base_kv_collection.h:65
~BaseKVCollection() override
Destructor.
Definition: base_kv_collection.h:62
virtual void CopyTo(ArrayPtr< KV > arr, int index) override
Copies data to existing array elements.
Definition: base_kv_collection.h:34
Interface of collection of elements. Objects of this class should only be allocated using System::Mak...
Definition: icollection.h:20
Interface of container containing keys or values of the dictionary-like container....
Definition: ikvcollection.h:17
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