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);
78 /// The operator to access the element with the specified index key.<br />
79 /// If an element with the key does not exist, then it is created.<br />
81 /// <param name="key">The key whose value to access.</param>
82 /// <returns>A value for the element with the specified key.</returns>
83 /// <since_tizen> 3 </since_tizen>
84 public PropertyValue this[int key]
88 return ValueOfIndex(key);
97 /// Retrieves the number of elements in the map.
99 /// <returns>The number of elements in the map.</returns>
100 /// <since_tizen> 3 </since_tizen>
103 uint ret = Interop.PropertyMap.Property_Map_Count(swigCPtr);
104 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
109 /// Returns whether the map is empty.
111 /// <returns>Returns true if empty, false otherwise.</returns>
112 /// <since_tizen> 3 </since_tizen>
115 bool ret = Interop.PropertyMap.Property_Map_Empty(swigCPtr);
116 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
121 /// Inserts the key-value pair in the map, with the key type as string.<br />
122 /// Does not check for duplicates.<br />
124 /// <param name="key">The key to insert.</param>
125 /// <param name="value">The value to insert.</param>
126 /// <since_tizen> 3 </since_tizen>
127 public void Insert(string key, PropertyValue value)
129 Interop.PropertyMap.Property_Map_Insert__SWIG_0(swigCPtr, key, PropertyValue.getCPtr(value));
130 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
134 /// Inserts the key-value pair in the map, with the key type as index.<br />
135 /// Does not check for duplicates.<br />
137 /// <param name="key">The key to insert.</param>
138 /// <param name="value">The value to insert.</param>
139 /// <since_tizen> 3 </since_tizen>
140 public void Insert(int key, PropertyValue value)
142 Interop.PropertyMap.Property_Map_Insert__SWIG_2(swigCPtr, key, PropertyValue.getCPtr(value));
143 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
147 /// Inserts the key-value pair in the map, with the key type as string.<br />
148 /// Does not check for duplicates.<br />
150 /// <param name="key">The key to insert.</param>
151 /// <param name="value">The value to insert.</param>
152 /// <returns>Returns a reference to this object.</returns>
153 /// <since_tizen> 3 </since_tizen>
154 public PropertyMap Add(string key, PropertyValue value)
156 PropertyMap ret = new PropertyMap(Interop.PropertyMap.Property_Map_Add__SWIG_0(swigCPtr, key, PropertyValue.getCPtr(value)), false);
157 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
162 /// Inserts the key-value pair in the map, with the key type as string.<br />
163 /// Does not check for duplicates.<br />
165 /// <param name="key">The key to insert.</param>
166 /// <param name="value">The value to insert.</param>
167 /// <returns>Returns a reference to this object.</returns>
168 /// <since_tizen> 3 </since_tizen>
169 public PropertyMap Add(int key, PropertyValue value)
171 PropertyMap ret = new PropertyMap(Interop.PropertyMap.Property_Map_Add__SWIG_2(swigCPtr, key, PropertyValue.getCPtr(value)), false);
172 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
177 /// Inserts the keyvalue to the map.<br />
178 /// Does not check for duplicates.<br />
180 /// <param name="keyValue">The keyvalue to insert.</param>
181 /// <returns>Returns a reference to this object.</returns>
182 public PropertyMap Add(KeyValue keyValue)
184 PropertyMap ret = new PropertyMap();
185 if ( keyValue.KeyInt != null )
187 ret = new PropertyMap(Interop.PropertyMap.Property_Map_Add__SWIG_2(swigCPtr, (int)keyValue.KeyInt, PropertyValue.getCPtr(keyValue.TrueValue)), false);
189 else if ( keyValue.KeyString != null )
191 ret = new PropertyMap(Interop.PropertyMap.Property_Map_Add__SWIG_0(swigCPtr, keyValue.KeyString, PropertyValue.getCPtr(keyValue.TrueValue)), false);
193 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
199 /// Retrieves the value at the specified position.
201 /// <param name="position">The specified position.</param>
202 /// <returns>A reference to the value at the specified position.</returns>
203 /// <since_tizen> 3 </since_tizen>
204 public PropertyValue GetValue(uint position)
206 PropertyValue ret = new PropertyValue(Interop.PropertyMap.Property_Map_GetValue(swigCPtr, position), false);
207 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
212 /// Retrieves the key at the specified position.
214 /// <param name="position">The specified position.</param>
215 /// <returns>A copy of the key at the specified position.</returns>
216 /// <since_tizen> 3 </since_tizen>
217 public PropertyKey GetKeyAt(uint position)
219 PropertyKey ret = new PropertyKey(Interop.PropertyMap.Property_Map_GetKeyAt(swigCPtr, position), true);
220 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
225 /// Finds the value for the specified key if it exists.
227 /// <param name="key">The key to find.</param>
228 /// <returns>The value if it exists, an empty object otherwise.</returns>
229 /// <since_tizen> 3 </since_tizen>
230 public PropertyValue Find(int key)
232 global::System.IntPtr cPtr = Interop.PropertyMap.Property_Map_Find__SWIG_2(swigCPtr, key);
233 PropertyValue ret = (cPtr == global::System.IntPtr.Zero) ? null : new PropertyValue(cPtr, false);
234 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
239 /// Finds the value for the specified keys if either exist.
241 /// <param name="indexKey">The index key to find.</param>
242 /// <param name="stringKey">The string key to find.</param>
243 /// <returns>The value if it exists, an empty object otherwise.</returns>
244 /// <since_tizen> 3 </since_tizen>
245 public PropertyValue Find(int indexKey, string stringKey)
247 global::System.IntPtr cPtr = Interop.PropertyMap.Property_Map_Find__SWIG_3(swigCPtr, indexKey, stringKey);
248 PropertyValue ret = (cPtr == global::System.IntPtr.Zero) ? null : new PropertyValue(cPtr, false);
249 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
256 /// <since_tizen> 3 </since_tizen>
259 Interop.PropertyMap.Property_Map_Clear(swigCPtr);
260 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
264 /// Merges values from the map 'from' to the current.<br />
265 /// Any values in 'from' will overwrite the values in the current map.<br />
267 /// <param name="from">The map to merge from.</param>
268 /// <since_tizen> 3 </since_tizen>
269 public void Merge(PropertyMap from)
271 Interop.PropertyMap.Property_Map_Merge(swigCPtr, PropertyMap.getCPtr(from));
272 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
276 /// Retrieves the element with the specified string key.
278 /// <param name="key">The key whose value to retrieve.</param>
279 /// <returns>The value for the element with the specified key.</returns>
280 internal PropertyValue ValueOfIndex(string key)
282 PropertyValue ret = new PropertyValue(Interop.PropertyMap.Property_Map_ValueOfIndex__SWIG_0(swigCPtr, key), false);
283 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
288 /// Retrieves the element with the specified index key.
290 /// <param name="key">The key whose value to retrieve.</param>
291 /// <returns>The value for the element with the specified key.</returns>
292 internal PropertyValue ValueOfIndex(int key)
294 PropertyValue ret = new PropertyValue(Interop.PropertyMap.Property_Map_ValueOfIndex__SWIG_2(swigCPtr, key), false);
295 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
299 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(PropertyMap obj)
301 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
304 internal void SetValue(int key, PropertyValue value)
306 Interop.PropertyMap.Property_Map_SetValue_IntKey(swigCPtr, key, PropertyValue.getCPtr(value));
307 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
310 internal void SetValue(string key, PropertyValue value)
312 Interop.PropertyMap.Property_Map_SetValue_StringKey(swigCPtr, key, PropertyValue.getCPtr(value));
313 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
319 /// <since_tizen> 3 </since_tizen>
320 protected override void Dispose(DisposeTypes type)
327 //Release your own unmanaged resources here.
328 //You should not access any managed member here except static instance.
329 //because the execution order of Finalizes is non-deterministic.
331 if (swigCPtr.Handle != global::System.IntPtr.Zero)
336 Interop.PropertyMap.delete_Property_Map(swigCPtr);
338 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);