/* * Copyright(c) 2021 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ using System.ComponentModel; namespace Tizen.NUI { /// /// An array of property values. /// /// 3 public class PropertyArray : Disposable { /// /// The constructor. /// /// 3 public PropertyArray() : this(Interop.Property.NewPropertyArray(), true) { if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } internal PropertyArray(PropertyArray other) : this(Interop.Property.NewPropertyArray(PropertyArray.getCPtr(other)), true) { if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } internal PropertyArray(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn) { } /// /// The operator to access an element. /// /// The element index to access. No bounds checking is performed. /// The reference to the element. /// 3 public PropertyValue this[uint index] { get { return ValueOfIndex(index); } } /// /// Retrieves the number of elements in the array. /// /// The number of elements in the array. /// 3 public uint Size() { uint ret = Interop.Property.ArraySize(SwigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } /// /// Retrieves the number of elements in the array. /// /// The number of elements in the array. /// 3 public uint Count() { uint ret = Interop.Property.ArrayCount(SwigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } /// /// Returns whether the array is empty. /// /// Returns true if empty, false otherwise. /// 3 public bool Empty() { bool ret = Interop.Property.ArrayEmpty(SwigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } /// /// Clears the array. /// /// 3 public void Clear() { Interop.Property.ArrayClear(SwigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } /// /// Increases the capacity of the array. /// /// The size to reserve. /// 3 public void Reserve(uint size) { Interop.Property.ArrayReserve(SwigCPtr, size); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } /// /// Resizes to size. /// /// The size to resize /// 3 public void Resize(uint size) { Interop.Property.ArrayResize(SwigCPtr, size); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } /// /// Retrieves the capacity of the array. /// /// The allocated capacity of the array. /// 3 public uint Capacity() { uint ret = Interop.Property.ArrayCapacity(SwigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } /// /// Adds an element to the array. /// /// The value to add at the end of the array. /// 3 public void PushBack(PropertyValue value) { Interop.Property.ArrayPushBack(SwigCPtr, PropertyValue.getCPtr(value)); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } /// /// Adds an keyvalue to the array. /// This function should be first /// /// The value to add at the end of the array. /// Thrown when value is null. public PropertyArray Add(KeyValue value) { if (null == value) { throw new global::System.ArgumentNullException(nameof(value)); } PropertyArray ret = new PropertyArray(Interop.Property.ArrayAdd(SwigCPtr, PropertyValue.getCPtr(value.TrueValue)), false); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } /// /// Adds an element to the array. /// /// The value to add at the end of the array. /// 3 public PropertyArray Add(PropertyValue value) { PropertyArray ret = new PropertyArray(Interop.Property.ArrayAdd(SwigCPtr, PropertyValue.getCPtr(value)), false); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } /// /// Accesses an element. /// /// The element index to access. No bounds checking is performed. /// The reference to the element. /// 3 public PropertyValue GetElementAt(uint index) { PropertyValue ret = new PropertyValue(Interop.Property.ArrayGetElementAt(SwigCPtr, index), false); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } /// This will not be public opened. [EditorBrowsable(EditorBrowsableState.Never)] protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr) { Interop.Property.DeletePropertyArray(swigCPtr); } /// /// Retrieves the value of elements in the array. /// /// The element index to retrieve. /// The reference to the element. private PropertyValue ValueOfIndex(uint index) { PropertyValue ret = new PropertyValue(Interop.Property.ArrayValueOfIndex(SwigCPtr, index), false); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } } }