glibmm 2.66.5
Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | Related Functions | List of all members
Glib::ValueArray Class Reference

A container structure to maintain an array of generic values. More...

#include <glibmm/valuearray.h>

Public Types

using SlotCompare = sigc::slot< int, const Glib::ValueBase &, const Glib::ValueBase & >
 For example, int on_compare(const Glib::ValueBase& v1, const Glib::ValueBase& v2);. More...
 

Public Member Functions

 ValueArray (GValueArray * gobject, bool make_a_copy=true)
 
 ValueArray (const ValueArray & other)
 
ValueArrayoperator= (const ValueArray & other)
 
 ValueArray (ValueArray && other) noexcept
 
ValueArrayoperator= (ValueArray && other) noexcept
 
 ~ValueArray () noexcept
 
void swap (ValueArray & other) noexcept
 
GValueArray * gobj ()
 Provides access to the underlying C instance. More...
 
const GValueArray * gobj () const
 Provides access to the underlying C instance. More...
 
GValueArray * gobj_copy () const
 Provides access to the underlying C instance. The caller is responsible for freeing it. Use when directly setting fields in structs. More...
 
 ValueArray ()
 Default constructor. More...
 
 ValueArray (guint n_preallocated)
 Constructs a new array with pre-allocation. More...
 
bool get_nth (guint index, Glib::ValueBase & value)
 Return the value at index contained in the value array. More...
 
Glib::ValueArrayappend (const Glib::ValueBase & value)
 Insert a copy of value as last element of value_array. More...
 
Glib::ValueArrayprepend (const Glib::ValueBase & value)
 Insert a copy of value as first element of value_array. More...
 
Glib::ValueArrayinsert (guint index, const Glib::ValueBase & value)
 Insert a copy of value at specified position into value_array. More...
 
Glib::ValueArrayremove (guint index)
 Remove the value at position index from value_array. More...
 
Glib::ValueArraysort (const SlotCompare & compare_func)
 Sort value_array using compare_func to compare the elements according to the semantics of CompareFunc. More...
 

Static Public Member Functions

static GType get_type ()
 Get the GType for this class, for use with the underlying GObject type system. More...
 

Protected Attributes

GValueArray * gobject_
 

Related Functions

(Note that these are not member functions.)

void swap (ValueArray & lhs, ValueArray & rhs) noexcept
 
Glib::ValueArray wrap (GValueArray * object, bool take_copy=false)
 A Glib::wrap() method for this object. More...
 

Detailed Description

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.

Since glibmm 2.22:
Deprecated:
Use std::vector<Glib::ValueBase*> or std::vector< Glib::Value<> > instead of Glib::ValueArray.

Member Typedef Documentation

◆ SlotCompare

using Glib::ValueArray::SlotCompare = sigc::slot<int, const Glib::ValueBase&, const Glib::ValueBase&>

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.

Constructor & Destructor Documentation

◆ ValueArray() [1/5]

Glib::ValueArray::ValueArray ( GValueArray *  gobject,
bool  make_a_copy = true 
)
explicit

◆ ValueArray() [2/5]

Glib::ValueArray::ValueArray ( const ValueArray other)

◆ ValueArray() [3/5]

Glib::ValueArray::ValueArray ( ValueArray &&  other)
noexcept

◆ ~ValueArray()

Glib::ValueArray::~ValueArray ( )
noexcept

◆ ValueArray() [4/5]

Glib::ValueArray::ValueArray ( )

Default constructor.

Constructs a new array with no pre-allocation.

◆ ValueArray() [5/5]

Glib::ValueArray::ValueArray ( guint  n_preallocated)

Constructs a new array with pre-allocation.

Member Function Documentation

◆ append()

Glib::ValueArray & Glib::ValueArray::append ( const Glib::ValueBase value)

Insert a copy of value as last element of value_array.

If value is nullptr, an uninitialized value is appended.

Deprecated: 2.32: Use Array and Glib::array_append_val() instead.

Parameters
valueValue to copy into ValueArray, or nullptr.
Returns
The ValueArray passed in as value_array.

◆ get_nth()

bool Glib::ValueArray::get_nth ( guint  index,
Glib::ValueBase value 
)

Return the value at index contained in the value array.

Parameters
indexIndex of the value of interest.
valueAn uninitialized ValueBase in which to store the result. If the get is successful, value will be valid, otherwise it will remain uninitialized.
Returns
whether the get was successful or not.

◆ get_type()

static GType Glib::ValueArray::get_type ( )
static

Get the GType for this class, for use with the underlying GObject type system.

◆ gobj() [1/2]

GValueArray * Glib::ValueArray::gobj ( )
inline

Provides access to the underlying C instance.

◆ gobj() [2/2]

const GValueArray * Glib::ValueArray::gobj ( ) const
inline

Provides access to the underlying C instance.

◆ gobj_copy()

GValueArray * Glib::ValueArray::gobj_copy ( ) const

Provides access to the underlying C instance. The caller is responsible for freeing it. Use when directly setting fields in structs.

◆ insert()

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

Insert a copy of value at specified position into value_array.

If value is nullptr, an uninitialized value is inserted.

Deprecated: 2.32: Use Array and Glib::array_insert_val() instead.

Parameters
indexInsertion position, must be <= value_array->;n_values.
valueValue to copy into ValueArray, or nullptr.
Returns
The ValueArray passed in as value_array.

◆ operator=() [1/2]

ValueArray & Glib::ValueArray::operator= ( const ValueArray other)

◆ operator=() [2/2]

ValueArray & Glib::ValueArray::operator= ( ValueArray &&  other)
noexcept

◆ prepend()

Glib::ValueArray & Glib::ValueArray::prepend ( const Glib::ValueBase value)

Insert a copy of value as first element of value_array.

If value is nullptr, an uninitialized value is prepended.

Deprecated: 2.32: Use Array and Glib::array_prepend_val() instead.

Parameters
valueValue to copy into ValueArray, or nullptr.
Returns
The ValueArray passed in as value_array.

◆ remove()

Glib::ValueArray & Glib::ValueArray::remove ( guint  index)

Remove the value at position index from value_array.

Deprecated: 2.32: Use Array and g_array_remove_index() instead.

Parameters
indexPosition of value to remove, which must be less than value_array->n_values.
Returns
The ValueArray passed in as value_array.

◆ sort()

Glib::ValueArray & Glib::ValueArray::sort ( const SlotCompare compare_func)

Sort value_array using compare_func to compare the elements according to the semantics of CompareFunc.

The current implementation uses the same sorting algorithm as standard C qsort() function.

Deprecated: 2.32: Use Array and g_array_sort().

Parameters
compare_funcFunction to compare elements.
Returns
The ValueArray passed in as value_array.

◆ swap()

void Glib::ValueArray::swap ( ValueArray other)
noexcept

Friends And Related Function Documentation

◆ swap()

void swap ( ValueArray lhs,
ValueArray rhs 
)
related
Parameters
lhsThe left-hand side
rhsThe right-hand side

◆ wrap()

Glib::ValueArray wrap ( GValueArray *  object,
bool  take_copy = false 
)
related

A Glib::wrap() method for this object.

Parameters
objectThe C instance.
take_copyFalse if the result should take ownership of the C instance. True if it should take a new copy or ref.
Returns
A C++ instance that wraps this C instance.

Member Data Documentation

◆ gobject_

GValueArray* Glib::ValueArray::gobject_
protected