gconfmm 2.28.3
Gnome::Conf::Value Class Reference

Wrapper for primitive types. More...

#include <gconfmm/value.h>

Collaboration diagram for Gnome::Conf::Value:

Public Member Functions

 Value (GConfValue* castitem, bool make_a_copy=false)
 
 Value (const Value& src)
 
Valueoperator= (const Value& src)
 
 ~Value ()
 
GConfValue* gobj ()
 
const GConfValue* gobj () const
 
GConfValue* gobj_copy () const
 Provides access to the underlying C instance. The caller is responsible for freeing it. Use when directly setting fields in structs.
 
 Value (ValueType type=VALUE_INVALID)
 Create a Value.
 
void set (gint val)
 Set the integer value of a Value whose type is VALUE_INT.
 
void set (gdouble val)
 Set the float value of a Value whose type is VALUE_FLOAT.
 
void set (bool val)
 Set the boolean value of a Value whose type is VALUE_BOOL.
 
void set (const Schema& sc)
 Set the Schema of a Value whose type is VALUE_SCHEMA.
 
void set_car (const Value& car)
 Set the car (in a pair, the first element) of a Value whose type is VALUE_PAIR.
 
void set_cdr (const Value& cdr)
 Set the cdr (in a pair, the second element) of a Value whose type is VALUE_PAIR.
 
void set (const Glib::ustring& val)
 Set the string of a Value whose type is VALUE_STRING.
 
void set_list_type (ValueType type)
 Sets the type of the elements of a Value with type VALUE_LIST.
 
void set_int_list (const SListHandle_ValueInt& list)
 Sets the Value to contain a list of integers.
 
void set_bool_list (const SListHandle_ValueBool& list)
 Sets the Value to contain a list of bools.
 
void set_float_list (const SListHandle_ValueFloat& list)
 Sets the Value to contain a list of doubles.
 
void set_string_list (const SListHandle_ValueString& list)
 Sets the Value to contain a list of strings.
 
void set_schema_list (const SListHandle_ValueSchema& list)
 Sets the Value to contain a list of Schema.
 
ValueType get_type () const
 Get the type of the Value.
 
ValueType get_list_type () const
 Get the type of the list elements of the Value.
 
int get_int () const
 Get the integer that the Value contains.
 
bool get_bool () const
 Get the boolean that the Value contains.
 
double get_float () const
 Get the double that the Value contains.
 
Glib::ustring get_string () const
 Get the string that the Value contains.
 
Schema get_schema () const
 Get a copy of the Schema of the value.
 
Value get_car () const
 Get a copy of the car of a VALUE_PAIR Value.
 
Value get_cdr () const
 Get a copy of the cdr of a VALUE_PAIR Value.
 
SListHandle_ValueFloat get_float_list () const
 Gets a list of doubles from the Value.
 
SListHandle_ValueInt get_int_list () const
 Retrieves the list of integers from the Value.
 
SListHandle_ValueBool get_bool_list () const
 Retrieves the list of booleans from the Value.
 
SListHandle_ValueString get_string_list () const
 Retrieves the list of strings from the Value.
 
SListHandle_ValueSchema get_schema_list () const
 Retrieves the list of Schemas from the Value.
 
Glib::ustring to_string () const
 Convert the Value to a string.
 

Protected Attributes

GConfValue* gobject_
 

Related Symbols

(Note that these are not member symbols.)

Gnome::Conf::Value wrap (GConfValue* object, bool take_copy=false)
 A Glib::wrap() method for this object.
 

Detailed Description

Wrapper for primitive types.

This class wraps the primitive types that are passed to and from instances of Gnome::Conf::Client. It has an associated ValueType, which is specified at creation time, but can be changed with assignment. If the type is VALUE_INVALID then the effect of the set and get methods is undefined. Using a default-constructed Value without using any of the set methods produces undefined behaviour.

Compound Values of type VALUE_PAIR and VALUE_LIST can only have elements whose types are neither VALUE_PAIR or VALUE_LIST - they can only have primitive types.

The Value class has copy-by-value semantics - all arguments to the set methods are copied.

Note that while the type is named VALUE_FLOAT, the accessors for floating-point values use double, not float, to preserve accuracy.

Constructor & Destructor Documentation

◆ Value() [1/3]

Gnome::Conf::Value::Value ( GConfValue * castitem,
bool make_a_copy = false )
explicit

◆ Value() [2/3]

Gnome::Conf::Value::Value ( const Value& src)

◆ ~Value()

Gnome::Conf::Value::~Value ( )

◆ Value() [3/3]

Gnome::Conf::Value::Value ( ValueType type = VALUE_INVALID)

Create a Value.

You should call a set() method before using the Value.

Parameters
typeThe type of the produced value.

Member Function Documentation

◆ get_bool()

bool Gnome::Conf::Value::get_bool ( ) const

Get the boolean that the Value contains.

◆ get_bool_list()

SListHandle_ValueBool Gnome::Conf::Value::get_bool_list ( ) const

Retrieves the list of booleans from the Value.

See also
get_float_list

◆ get_car()

Value Gnome::Conf::Value::get_car ( ) const

Get a copy of the car of a VALUE_PAIR Value.

◆ get_cdr()

Value Gnome::Conf::Value::get_cdr ( ) const

Get a copy of the cdr of a VALUE_PAIR Value.

◆ get_float()

double Gnome::Conf::Value::get_float ( ) const

Get the double that the Value contains.

◆ get_float_list()

SListHandle_ValueFloat Gnome::Conf::Value::get_float_list ( ) const

Gets a list of doubles from the Value.

Typical usage is

std::vector<double> foo = value.get_float_list();

.

Returns
: an STL-compatible container with doubles as its value type. Assign to an std::vector, list or deque for proper use.

◆ get_int()

int Gnome::Conf::Value::get_int ( ) const

Get the integer that the Value contains.

◆ get_int_list()

SListHandle_ValueInt Gnome::Conf::Value::get_int_list ( ) const

Retrieves the list of integers from the Value.

See also
get_float_list

◆ get_list_type()

ValueType Gnome::Conf::Value::get_list_type ( ) const

Get the type of the list elements of the Value.

Do not call this method on non-list Values.

Returns
the type of the list elements.

◆ get_schema()

Schema Gnome::Conf::Value::get_schema ( ) const

Get a copy of the Schema of the value.

◆ get_schema_list()

SListHandle_ValueSchema Gnome::Conf::Value::get_schema_list ( ) const

Retrieves the list of Schemas from the Value.

@See get_float_list

◆ get_string()

Glib::ustring Gnome::Conf::Value::get_string ( ) const

Get the string that the Value contains.

◆ get_string_list()

SListHandle_ValueString Gnome::Conf::Value::get_string_list ( ) const

Retrieves the list of strings from the Value.

See also
get_float_list

◆ get_type()

ValueType Gnome::Conf::Value::get_type ( ) const

Get the type of the Value.

Returns
the type of the Value

◆ gobj() [1/2]

GConfValue * Gnome::Conf::Value::gobj ( )
inline

◆ gobj() [2/2]

const GConfValue * Gnome::Conf::Value::gobj ( ) const
inline

◆ gobj_copy()

GConfValue * Gnome::Conf::Value::gobj_copy ( ) const

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

◆ operator=()

Value& Gnome::Conf::Value::operator= ( const Value& src)

◆ set() [1/5]

void Gnome::Conf::Value::set ( bool val)

Set the boolean value of a Value whose type is VALUE_BOOL.

◆ set() [2/5]

void Gnome::Conf::Value::set ( const Glib::ustring & val)

Set the string of a Value whose type is VALUE_STRING.

◆ set() [3/5]

void Gnome::Conf::Value::set ( const Schema& sc)

Set the Schema of a Value whose type is VALUE_SCHEMA.

◆ set() [4/5]

void Gnome::Conf::Value::set ( gdouble val)

Set the float value of a Value whose type is VALUE_FLOAT.

Parameters
valthe double this Value will be se to.

◆ set() [5/5]

void Gnome::Conf::Value::set ( gint val)

Set the integer value of a Value whose type is VALUE_INT.

◆ set_bool_list()

void Gnome::Conf::Value::set_bool_list ( const SListHandle_ValueBool & list)

Sets the Value to contain a list of bools.

See also
set_int_list

◆ set_car()

void Gnome::Conf::Value::set_car ( const Value& car)

Set the car (in a pair, the first element) of a Value whose type is VALUE_PAIR.

◆ set_cdr()

void Gnome::Conf::Value::set_cdr ( const Value& cdr)

Set the cdr (in a pair, the second element) of a Value whose type is VALUE_PAIR.

◆ set_float_list()

void Gnome::Conf::Value::set_float_list ( const SListHandle_ValueFloat & list)

Sets the Value to contain a list of doubles.

See also
set_int_list

◆ set_int_list()

void Gnome::Conf::Value::set_int_list ( const SListHandle_ValueInt & list)

Sets the Value to contain a list of integers.

set_list_type(VALUE_INT) must have been called prior this call.

Parameters
listan STL-compatible container whose value_type is int

◆ set_list_type()

void Gnome::Conf::Value::set_list_type ( ValueType type)

Sets the type of the elements of a Value with type VALUE_LIST.

◆ set_schema_list()

void Gnome::Conf::Value::set_schema_list ( const SListHandle_ValueSchema & list)

Sets the Value to contain a list of Schema.

See also
set_int_list

◆ set_string_list()

void Gnome::Conf::Value::set_string_list ( const SListHandle_ValueString & list)

Sets the Value to contain a list of strings.

See also
set_int_list

◆ to_string()

Glib::ustring Gnome::Conf::Value::to_string ( ) const

Convert the Value to a string.

The string is not machine-parseable. Do not depend on the format of the string.

Friends And Related Symbol Documentation

◆ wrap()

Gnome::Conf::Value wrap ( GConfValue * 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_

GConfValue* Gnome::Conf::Value::gobject_
protected

The documentation for this class was generated from the following file: