1 /******************************************************************************
3 * Copyright (C) 2012-2014 Icinga Development Team (http://www.icinga.org) *
5 * This program is free software; you can redistribute it and/or *
6 * modify it under the terms of the GNU General Public License *
7 * as published by the Free Software Foundation; either version 2 *
8 * of the License, or (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the Free Software Foundation *
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
18 ******************************************************************************/
23 #include "base/i2-base.hpp"
24 #include "base/value.hpp"
31 * An array of Value items.
35 class I2_BASE_API Array : public Object
38 DECLARE_PTR_TYPEDEFS(Array);
41 * An iterator that can be used to iterate over array elements.
43 typedef std::vector<Value>::iterator Iterator;
45 typedef std::vector<Value>::size_type SizeType;
47 Value Get(unsigned int index) const;
48 void Set(unsigned int index, const Value& value);
49 void Add(const Value& value);
54 size_t GetLength(void) const;
55 bool Contains(const String& value) const;
57 void Insert(unsigned int index, const Value& value);
58 void Remove(unsigned int index);
59 void Remove(Iterator it);
61 void Resize(size_t new_size);
64 void CopyTo(const Array::Ptr& dest) const;
65 Array::Ptr ShallowClone(void) const;
67 static Array::Ptr FromJson(cJSON *json);
68 cJSON *ToJson(void) const;
71 std::vector<Value> m_Data; /**< The data for the array. */
74 inline Array::Iterator range_begin(Array::Ptr x)
79 inline Array::Iterator range_end(Array::Ptr x)
90 struct range_mutable_iterator<icinga::Array::Ptr>
92 typedef icinga::Array::Iterator type;
96 struct range_const_iterator<icinga::Array::Ptr>
98 typedef icinga::Array::Iterator type;