/* 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, see <http://www.gnu.org/licenses/>.
 */

_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 GLIBMM_API ValueArray
{
  _CLASS_BOXEDTYPE(ValueArray, GValueArray, NONE, g_value_array_copy, g_value_array_free, GLIBMM_API)
  _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
