summaryrefslogtreecommitdiff
path: root/glib/src/valuearray.hg
blob: c1b5638539275caeba44fc18eae53fb72eb11db1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/* Copyright (C) 2002-2009 The gtkmm Development Team
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

_CONFIGINCLUDE(glibmmconfig.h)

_DEFS(glibmm,glib)

#include <glib-object.h>
#include <glibmm/value.h>
#include <sigc++/functors/slot.h>

#m4 _PUSH(SECTION_CC_PRE_INCLUDES)
#undef G_DISABLE_DEPRECATED
#define GLIB_DISABLE_DEPRECATION_WARNINGS 1
#m4 _POP()

_IS_DEPRECATED // This whole file is deprecated.

namespace Glib
{

/** A container structure to maintain an array of generic values.
 * The prime purpose of a ValueArray is for it to be used as an object property
 * that holds an array of values. A ValueArray wraps an array of ValueBase
 * elements.
 *
 * @newin{2,22}
 *
 * @deprecated Use std::vector<Glib::ValueBase*> or std::vector< Glib::Value<> >
 *             instead of Glib::ValueArray.
 */
class ValueArray
{
  _CLASS_BOXEDTYPE(ValueArray, GValueArray, NONE, g_value_array_copy, g_value_array_free)
  _IGNORE(g_value_array_copy, g_value_array_free)
  _CUSTOM_DEFAULT_CTOR

public:
  /** For example,
   *  int on_compare(const Glib::ValueBase& v1, const Glib::ValueBase& v2);.
   *  The compare function should return -1 if v1 < v2, 0 if v1 == v2, and 1 if
   *  v1 > v2.
   */
  using SlotCompare = sigc::slot<int, const Glib::ValueBase&, const Glib::ValueBase&>;

  /** Default constructor.  Constructs a new array with no pre-allocation.
   */
  ValueArray();

  /** Constructs a new array with pre-allocation.
   */
  ValueArray(guint n_preallocated);

  /** Return the value at @a index contained in the value array.
   * @param index Index of the value of interest.
   * @param value An uninitialized ValueBase in which to store the result.  If
   * the get is successful, @a value will be valid, otherwise it will remain
   * uninitialized.
   * @return whether the get was successful or not.
   */
  bool get_nth(guint index, Glib::ValueBase& value);
  _IGNORE(g_value_array_get_nth)

  _WRAP_METHOD_DOCS_ONLY(g_value_array_append)
  Glib::ValueArray& append(const Glib::ValueBase& value);

  _WRAP_METHOD_DOCS_ONLY(g_value_array_prepend)
  Glib::ValueArray& prepend(const Glib::ValueBase& value);

  _WRAP_METHOD_DOCS_ONLY(g_value_array_insert)
  Glib::ValueArray& insert(guint index, const Glib::ValueBase& value);

  _WRAP_METHOD_DOCS_ONLY(g_value_array_remove)
  Glib::ValueArray& remove(guint index);

  _WRAP_METHOD_DOCS_ONLY(g_value_array_sort)
  Glib::ValueArray& sort(const SlotCompare& compare_func);
  _IGNORE(g_value_array_sort_with_data)
};

} //namespace Glib