2 * Copyright(c) 2019 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 /// A map of property values, the key type could be string or Property::Index.
23 /// <since_tizen> 3 </since_tizen>
24 public class PropertyMap : Disposable
29 /// <since_tizen> 3 </since_tizen>
30 protected bool swigCMemOwn;
31 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
36 /// <since_tizen> 3 </since_tizen>
37 public PropertyMap() : this(Interop.PropertyMap.new_Property_Map__SWIG_0(), true)
39 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
43 /// The copy constructor.
45 /// <param name="other">The map to copy from.</param>
46 /// <since_tizen> 3 </since_tizen>
47 public PropertyMap(PropertyMap other) : this(Interop.PropertyMap.new_Property_Map__SWIG_1(PropertyMap.getCPtr(other)), true)
49 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
52 internal PropertyMap(global::System.IntPtr cPtr, bool cMemoryOwn)
54 swigCMemOwn = cMemoryOwn;
55 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
59 /// The operator to access the element with the specified string key.<br />
60 /// If an element with the key does not exist, then it is created.<br />
62 /// <param name="key">The key whose value to access.</param>
63 /// <returns>A value for the element with the specified key.</returns>
64 /// <since_tizen> 3 </since_tizen>
65 public PropertyValue this[string key]
69 return ValueOfIndex(key);
74 /// The operator to access the element with the specified index key.<br />
75 /// If an element with the key does not exist, then it is created.<br />
77 /// <param name="key">The key whose value to access.</param>
78 /// <returns>A value for the element with the specified key.</returns>
79 /// <since_tizen> 3 </since_tizen>
80 public PropertyValue this[int key]
84 return ValueOfIndex(key);
89 /// Retrieves the number of elements in the map.
91 /// <returns>The number of elements in the map.</returns>
92 /// <since_tizen> 3 </since_tizen>
95 uint ret = Interop.PropertyMap.Property_Map_Count(swigCPtr);
96 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
101 /// Returns whether the map is empty.
103 /// <returns>Returns true if empty, false otherwise.</returns>
104 /// <since_tizen> 3 </since_tizen>
107 bool ret = Interop.PropertyMap.Property_Map_Empty(swigCPtr);
108 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
113 /// Inserts the key-value pair in the map, with the key type as string.<br />
114 /// Does not check for duplicates.<br />
116 /// <param name="key">The key to insert.</param>
117 /// <param name="value">The value to insert.</param>
118 /// <since_tizen> 3 </since_tizen>
119 public void Insert(string key, PropertyValue value)
121 Interop.PropertyMap.Property_Map_Insert__SWIG_0(swigCPtr, key, PropertyValue.getCPtr(value));
122 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
126 /// Inserts the key-value pair in the map, with the key type as index.<br />
127 /// Does not check for duplicates.<br />
129 /// <param name="key">The key to insert.</param>
130 /// <param name="value">The value to insert.</param>
131 /// <since_tizen> 3 </since_tizen>
132 public void Insert(int key, PropertyValue value)
134 Interop.PropertyMap.Property_Map_Insert__SWIG_2(swigCPtr, key, PropertyValue.getCPtr(value));
135 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
139 /// Inserts the key-value pair in the map, with the key type as string.<br />
140 /// Does not check for duplicates.<br />
142 /// <param name="key">The key to insert.</param>
143 /// <param name="value">The value to insert.</param>
144 /// <returns>Returns a reference to this object.</returns>
145 /// <since_tizen> 3 </since_tizen>
146 public PropertyMap Add(string key, PropertyValue value)
148 PropertyMap ret = new PropertyMap(Interop.PropertyMap.Property_Map_Add__SWIG_0(swigCPtr, key, PropertyValue.getCPtr(value)), false);
149 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
154 /// Inserts the key-value pair in the map, with the key type as string.<br />
155 /// Does not check for duplicates.<br />
157 /// <param name="key">The key to insert.</param>
158 /// <param name="value">The value to insert.</param>
159 /// <returns>Returns a reference to this object.</returns>
160 /// <since_tizen> 3 </since_tizen>
161 public PropertyMap Add(int key, PropertyValue value)
163 PropertyMap ret = new PropertyMap(Interop.PropertyMap.Property_Map_Add__SWIG_2(swigCPtr, key, PropertyValue.getCPtr(value)), false);
164 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
169 /// Inserts the keyvalue to the map.<br />
170 /// Does not check for duplicates.<br />
172 /// <param name="keyValue">The keyvalue to insert.</param>
173 /// <returns>Returns a reference to this object.</returns>
174 public PropertyMap Add(KeyValue keyValue)
176 PropertyMap ret = new PropertyMap();
177 if ( keyValue.KeyInt != null )
179 ret = new PropertyMap(Interop.PropertyMap.Property_Map_Add__SWIG_2(swigCPtr, (int)keyValue.KeyInt, PropertyValue.getCPtr(keyValue.TrueValue)), false);
181 else if ( keyValue.KeyString != null )
183 ret = new PropertyMap(Interop.PropertyMap.Property_Map_Add__SWIG_0(swigCPtr, keyValue.KeyString, PropertyValue.getCPtr(keyValue.TrueValue)), false);
185 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
191 /// Retrieves the value at the specified position.
193 /// <param name="position">The specified position.</param>
194 /// <returns>A reference to the value at the specified position.</returns>
195 /// <since_tizen> 3 </since_tizen>
196 public PropertyValue GetValue(uint position)
198 PropertyValue ret = new PropertyValue(Interop.PropertyMap.Property_Map_GetValue(swigCPtr, position), false);
199 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
204 /// Retrieves the key at the specified position.
206 /// <param name="position">The specified position.</param>
207 /// <returns>A copy of the key at the specified position.</returns>
208 /// <since_tizen> 3 </since_tizen>
209 public PropertyKey GetKeyAt(uint position)
211 PropertyKey ret = new PropertyKey(Interop.PropertyMap.Property_Map_GetKeyAt(swigCPtr, position), true);
212 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
217 /// Finds the value for the specified key if it exists.
219 /// <param name="key">The key to find.</param>
220 /// <returns>The value if it exists, an empty object otherwise.</returns>
221 /// <since_tizen> 3 </since_tizen>
222 public PropertyValue Find(int key)
224 global::System.IntPtr cPtr = Interop.PropertyMap.Property_Map_Find__SWIG_2(swigCPtr, key);
225 PropertyValue ret = (cPtr == global::System.IntPtr.Zero) ? null : new PropertyValue(cPtr, false);
226 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
231 /// Finds the value for the specified keys if either exist.
233 /// <param name="indexKey">The index key to find.</param>
234 /// <param name="stringKey">The string key to find.</param>
235 /// <returns>The value if it exists, an empty object otherwise.</returns>
236 /// <since_tizen> 3 </since_tizen>
237 public PropertyValue Find(int indexKey, string stringKey)
239 global::System.IntPtr cPtr = Interop.PropertyMap.Property_Map_Find__SWIG_3(swigCPtr, indexKey, stringKey);
240 PropertyValue ret = (cPtr == global::System.IntPtr.Zero) ? null : new PropertyValue(cPtr, false);
241 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
248 /// <since_tizen> 3 </since_tizen>
251 Interop.PropertyMap.Property_Map_Clear(swigCPtr);
252 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
256 /// Merges values from the map 'from' to the current.<br />
257 /// Any values in 'from' will overwrite the values in the current map.<br />
259 /// <param name="from">The map to merge from.</param>
260 /// <since_tizen> 3 </since_tizen>
261 public void Merge(PropertyMap from)
263 Interop.PropertyMap.Property_Map_Merge(swigCPtr, PropertyMap.getCPtr(from));
264 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
268 /// Retrieves the element with the specified string key.
270 /// <param name="key">The key whose value to retrieve.</param>
271 /// <returns>The value for the element with the specified key.</returns>
272 internal PropertyValue ValueOfIndex(string key)
274 PropertyValue ret = new PropertyValue(Interop.PropertyMap.Property_Map_ValueOfIndex__SWIG_0(swigCPtr, key), false);
275 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
280 /// Retrieves the element with the specified index key.
282 /// <param name="key">The key whose value to retrieve.</param>
283 /// <returns>The value for the element with the specified key.</returns>
284 internal PropertyValue ValueOfIndex(int key)
286 PropertyValue ret = new PropertyValue(Interop.PropertyMap.Property_Map_ValueOfIndex__SWIG_2(swigCPtr, key), false);
287 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
291 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(PropertyMap obj)
293 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
299 /// <since_tizen> 3 </since_tizen>
300 protected override void Dispose(DisposeTypes type)
307 //Release your own unmanaged resources here.
308 //You should not access any managed member here except static instance.
309 //because the execution order of Finalizes is non-deterministic.
311 if (swigCPtr.Handle != global::System.IntPtr.Zero)
316 Interop.PropertyMap.delete_Property_Map(swigCPtr);
318 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);