CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
idictionary.h
1
2#ifndef _aspose_system_collections_idictionary_h_
3#define _aspose_system_collections_idictionary_h_
4
5#include <system/collections/ikvcollection.h>
6#include <system/collections/keyvalue_pair.h>
7#include <system/array.h>
8
9namespace System {
10namespace Collections {
11namespace Generic {
12
19template<typename TKey, typename TValue>
20class ASPOSECPP_SHARED_CLASS IDictionary : public ICollection<KeyValuePair<TKey, TValue>>
21{
25 using BaseTypesInfo = System::BaseTypesInfo<ICollection<KeyValuePair<TKey, TValue>>>;
27 RTTI_INFO_TEMPLATE_CLASS(ThisType, BaseTypesInfo);
28
29public:
34
39
43 virtual void Add(const TKey& key, const TValue& value) = 0;
47 virtual bool ContainsKey(const TKey& key) const = 0;
51 virtual bool Remove(const TKey& key) = 0;
56 virtual bool TryGetValue(const TKey& key, TValue& value) const = 0;
57
61 virtual TValue idx_get(const TKey& key) const = 0;
65 virtual void idx_set(const TKey& key, TValue value) = 0;
66
69 virtual SharedPtr<ICollection<TKey>> get_Keys() const { return get_KeysInternal(); }
72 virtual SharedPtr<ICollection<TValue>> get_Values() const { return get_ValuesInternal(); }
73
76 bool get_IsFixedSize() const { return false; }
77
78 // ICollection interface
81 bool get_IsSynchronized() const { return false; }
83 using BaseType::get_Count;
87 virtual void CopyTo(ArrayPtr<KeyValuePair<TKey, TValue>> arr, int index) override
88 {
89 if (!arr)
90 throw ArgumentNullException();
91
92 if (index < 0)
93 throw ArgumentOutOfRangeException();
94
95 if (index + get_Count() > arr->get_Length())
96 throw ArgumentException();
97
98 SharedPtr<IEnumerator<KeyValuePair<TKey, TValue>>> e = this->GetEnumerator();
99 while (e->MoveNext())
100 (*arr)[index++] = e->get_Current();
101 }
102
104 virtual TValue GetValueOrDefault(const TKey& key) const
105 {
106 ASPOSE_UNUSED(key);
107 throw System::NotImplementedException();
108 }
109
111 virtual TValue GetValueOrDefault(const TKey& key, const TValue& defaultValue) const
112 {
113 ASPOSE_UNUSED(key);
114 ASPOSE_UNUSED(defaultValue);
115 throw System::NotImplementedException();
116 }
117
119 virtual TValue GetValueOrNull(const TKey& key) const
120 {
121 ASPOSE_UNUSED(key);
122 throw System::NotImplementedException();
123 }
124
125protected:
127 ~IDictionary() override {}
128
130 virtual SharedPtr<ICollection<TKey>> get_KeysInternal() const { throw System::NotImplementedException(ASPOSE_CURRENT_FUNCTION); };
132 virtual SharedPtr<ICollection<TValue>> get_ValuesInternal() const { throw System::NotImplementedException(ASPOSE_CURRENT_FUNCTION); };
133};
134
135} // namespace Generic
136} // namespace Collections
137} // namespace System
138
139#endif // _aspose_system_collections_idictionary_h_
Interface of collection of elements. Objects of this class should only be allocated using System::Mak...
Definition: icollection.h:20
Interface for dictionary-alike containers. Objects of this class should only be allocated using Syste...
Definition: idictionary.h:21
KeyValuePair< TKey, TValue > KeyValuePairType
Key value pair type.
Definition: idictionary.h:33
~IDictionary() override
Destructor.
Definition: idictionary.h:127
virtual void CopyTo(ArrayPtr< KeyValuePair< TKey, TValue > > arr, int index) override
Copies dictionary contents into existing array elements.
Definition: idictionary.h:87
virtual void idx_set(const TKey &key, TValue value)=0
Setter function.
virtual TValue GetValueOrDefault(const TKey &key, const TValue &defaultValue) const
Returns value if found; or defaultValue otherwise.
Definition: idictionary.h:111
virtual bool ContainsKey(const TKey &key) const =0
Checks if container contains key.
virtual SharedPtr< ICollection< TValue > > get_Values() const
Accesses value collection.
Definition: idictionary.h:72
virtual void Add(const TKey &key, const TValue &value)=0
Adds key-value pair into container.
bool get_IsSynchronized() const
Checks if container is thread-safe.
Definition: idictionary.h:81
virtual SharedPtr< ICollection< TKey > > get_Keys() const
Accesses key collection.
Definition: idictionary.h:69
virtual bool Remove(const TKey &key)=0
Removes key from container.
virtual TValue idx_get(const TKey &key) const =0
Getter function.
virtual TValue GetValueOrNull(const TKey &key) const
Returns value if found; or null otherwise, make sense only for reference types.
Definition: idictionary.h:119
virtual SharedPtr< ICollection< TValue > > get_ValuesInternal() const
Implementation of get_Values() method.
Definition: idictionary.h:132
ICollection< KeyValuePair< TKey, TValue > > BaseType
Base interface type.
Definition: idictionary.h:31
bool get_IsFixedSize() const
Checks if collection size is fixed.
Definition: idictionary.h:76
virtual bool TryGetValue(const TKey &key, TValue &value) const =0
Looks for value and retreives it if found.
virtual SharedPtr< ICollection< TKey > > get_KeysInternal() const
Implementation of get_Keys() method.
Definition: idictionary.h:130
virtual TValue GetValueOrDefault(const TKey &key) const
Returns value if found; or Value() otherwise.
Definition: idictionary.h:104
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
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