Graphite  Version 3
An experimental 3D geometry processing program
OGF::ArgList Class Reference

Represents a list of name-value pairs. More...

#include <OGF/gom/types/arg_list.h>

Public Member Functions

 ArgList ()
 ArgList constructor.
 
 ArgList (const ArgList &rhs)
 ArgList copy-constructor. More...
 
ArgListoperator= (const ArgList &rhs)
 ArgList assignment operator. More...
 
index_t nb_args () const
 Gets the number of arguments. More...
 
bool has_unnamed_args () const
 Tests whether this ArgList has unnamed args. More...
 
bool has_arg (const std::string &name) const
 Tests whether an argument of a given name exists in this ArgList. More...
 
index_t find_arg_index (const std::string &name) const
 Finds argument index by name. More...
 
void delete_ith_arg (index_t index)
 Deletes an argument by index. More...
 
const std::string & ith_arg_name (index_t i) const
 Gets argument name by index. More...
 
template<class T >
ith_arg_value (index_t i) const
 Gets argument value by index. More...
 
const Anyith_arg_value (index_t i) const
 Gets argument value by index, stored as an Any. More...
 
Anyith_arg_value (index_t i)
 Gets argument value by index, stored as an Any. More...
 
const Anyarg_value (const std::string &name) const
 Gets argument value by name, stored as an Any. More...
 
Anyarg_value (const std::string &name)
 Gets argument value by name, stored as an Any. More...
 
MetaTypeith_arg_type (index_t i) const
 Gets the type of an argument by index. More...
 
Anycreate_arg (const std::string &name)
 Creates an uninitialized argument. More...
 
Anycreate_unnamed_arg ()
 Creates an uninitialized unnamed argument. More...
 
template<class T >
void create_arg (const std::string &name, const T &value)
 Creates an argument. More...
 
void create_arg (const std::string &name, const char *value)
 Creates an argument from a string litteral. More...
 
void create_arg (const std::string &name, const Any &value)
 Creates an argument from an Any. More...
 
template<class T >
void set_arg (const std::string &name, const T &value)
 Sets an argument. More...
 
void set_arg (const std::string &name, const char *value)
 Sets an argument from a string litteral. More...
 
void set_arg (const std::string &name, const Any &value)
 Sets an argument from an Any. More...
 
template<class T >
void set_ith_arg (index_t i, const T &value)
 Sets an argument by index. More...
 
void set_ith_arg (index_t i, const char *value)
 Sets an argument by index. More...
 
std::string get_arg (const std::string &name) const
 Gets a string representation of an argument. More...
 
template<class T >
get_arg (const std::string &name) const
 Gets an argument by name. More...
 
MetaTypeget_arg_type (const std::string &name) const
 Gets the type of an argument. More...
 
void clear ()
 Removes all the arguments from this ArgList.
 
void append (const ArgList &rhs, bool overwrite=true)
 Appends all the arguments from an ArgList to this one. More...
 
void append_ith_arg (const ArgList &rhs, index_t i, bool overwrite=true)
 Appends an argument from an ArgList to this one. More...
 
void serialize (std::ostream &out) const
 
void arg_type_error (index_t i, const std::string &expected_typeid_name) const
 Displays an error message for invalid argument type. More...
 

Static Public Member Functions

template<class T >
static bool get_name (const Any &argval, T &name)
 Converts a pointer to Object into a string using its name attribute if target type is a xxxName. More...
 
static bool get_object_name (const Any &object, Any &name)
 Gets the name of an object. More...
 

Detailed Description

Represents a list of name-value pairs.

Definition at line 65 of file arg_list.h.

Constructor & Destructor Documentation

◆ ArgList()

OGF::ArgList::ArgList ( const ArgList rhs)
inline

ArgList copy-constructor.

Parameters
[in]rhsa const reference to the ArgList to be copied

Definition at line 81 of file arg_list.h.

Member Function Documentation

◆ append()

void OGF::ArgList::append ( const ArgList rhs,
bool  overwrite = true 
)

Appends all the arguments from an ArgList to this one.

Parameters
[in]rhsa const reference to the ArgList to be appened
[in]overwriteif true, arguments in rhs that have the same names as arguments in this ArgList overwrite the previous values, else the previous values remain unchanged

◆ append_ith_arg()

void OGF::ArgList::append_ith_arg ( const ArgList rhs,
index_t  i,
bool  overwrite = true 
)

Appends an argument from an ArgList to this one.

Parameters
[in]rhsa const reference to the ArgList to be appened
[in]ithe index of the argument to append
[in]overwriteif true, the argument in rhs that have the same name as the argument in this ArgList overwrites the previous values, else the previous value remain unchanged
Precondition
i < rhs.nb_args()

◆ arg_type_error()

void OGF::ArgList::arg_type_error ( index_t  i,
const std::string &  expected_typeid_name 
) const

Displays an error message for invalid argument type.

Parameters
[in]ithe index of the concerned argument.
[in]expected_typeid_namethe typeid name that corresponds to the expected type (that we did not have).

◆ arg_value() [1/2]

Any& OGF::ArgList::arg_value ( const std::string &  name)
inline

Gets argument value by name, stored as an Any.

Parameters
[in]namethe name of the argument
Returns
a modifiable reference to the argument value at index i, wrapped in an Any.

Definition at line 235 of file arg_list.h.

◆ arg_value() [2/2]

const Any& OGF::ArgList::arg_value ( const std::string &  name) const
inline

Gets argument value by name, stored as an Any.

Parameters
[in]namethe name of the argument
Returns
a const reference to the argument value at index i, wrapped in an Any.
Precondition
has_arg(name)

Definition at line 222 of file arg_list.h.

◆ create_arg() [1/4]

Any& OGF::ArgList::create_arg ( const std::string &  name)
inline

Creates an uninitialized argument.

Parameters
[in]namea const reference to the name of the argument.
Returns
a reference to the Any that will store the argument.
Precondition
!has_arg(name)

Definition at line 259 of file arg_list.h.

◆ create_arg() [2/4]

void OGF::ArgList::create_arg ( const std::string &  name,
const Any value 
)
inline

Creates an argument from an Any.

Parameters
[in]namea const reference to the name of the argument
[in]valuean Any with the value
Precondition
!has_arg(name)

Definition at line 310 of file arg_list.h.

◆ create_arg() [3/4]

void OGF::ArgList::create_arg ( const std::string &  name,
const char *  value 
)
inline

Creates an argument from a string litteral.

Parameters
[in]namea const reference to the name of the argument
[in]valuea const pointer to a string
Precondition
!has_arg(name)

Definition at line 298 of file arg_list.h.

◆ create_arg() [4/4]

template<class T >
void OGF::ArgList::create_arg ( const std::string &  name,
const T &  value 
)
inline

Creates an argument.

Parameters
[in]namea const reference to the name of the argument
[in]valuea const reference to the value of the argument
Template Parameters
Tthe type of the argument
Precondition
!has_arg(name)

Definition at line 283 of file arg_list.h.

◆ create_unnamed_arg()

Any& OGF::ArgList::create_unnamed_arg ( )
inline

Creates an uninitialized unnamed argument.

Returns
a reference to the Any that will store the argument.
Precondition
nb_args() == 0 || has_unnamed_args()

Definition at line 271 of file arg_list.h.

◆ delete_ith_arg()

void OGF::ArgList::delete_ith_arg ( index_t  index)
inline

Deletes an argument by index.

Parameters
[in]indexthe index of the argument to be deleted
Precondition
i < nb_args()

Definition at line 147 of file arg_list.h.

◆ find_arg_index()

index_t OGF::ArgList::find_arg_index ( const std::string &  name) const

Finds argument index by name.

Parameters
[in]namea const reference to the name
Returns
the index of the argument with name name if it exists or index_t(-1) if there is no such argument

◆ get_arg() [1/2]

std::string OGF::ArgList::get_arg ( const std::string &  name) const
inline

Gets a string representation of an argument.

Parameters
[in]namethe name of the argument
Returns
the string representation of the argument
Precondition
has_arg(name)

Definition at line 396 of file arg_list.h.

◆ get_arg() [2/2]

template<class T >
T OGF::ArgList::get_arg ( const std::string &  name) const
inline

Gets an argument by name.

If the stored argument is of type T, then it is retreived directly, else it is converted using a temporary string representation.

Parameters
[in]namethe name of the argument
Returns
the value of the argument
Precondition
has_arg(name)
Template Parameters
Tthe type of the argument

Definition at line 412 of file arg_list.h.

◆ get_arg_type()

MetaType* OGF::ArgList::get_arg_type ( const std::string &  name) const
inline

Gets the type of an argument.

Parameters
[in]namethe name of the argument
Returns
a pointer to the type of the argument
Precondition
has_arg(name)

Definition at line 431 of file arg_list.h.

◆ get_name()

template<class T >
static bool OGF::ArgList::get_name ( const Any argval,
T &  name 
)
inlinestatic

Converts a pointer to Object into a string using its name attribute if target type is a xxxName.

Used by the mechanism that lets one pass Object* to functions that take ObjectNames

Parameters
[in]argvalthe stored value
[out]namethe name to be read
Return values
trueif argval is a pointer to Object that has a name attribute and name's type is a xxxName
falseotherwise

Definition at line 492 of file arg_list.h.

◆ get_object_name()

static bool OGF::ArgList::get_object_name ( const Any object,
Any name 
)
static

Gets the name of an object.

Used by the mechanism that lets one pass Object* to functions that take ObjectNames

Parameters
[in]objectan Any with a pointer to the object
[out]namean Any with the name of the object
Return values
trueif object has a pointer to an Object that has a name property
falseotherwise

◆ has_arg()

bool OGF::ArgList::has_arg ( const std::string &  name) const
inline

Tests whether an argument of a given name exists in this ArgList.

Parameters
[in]namea const reference to the name of the argument
Return values
trueif this ArgList has an argument with name name
falseotherwise

Definition at line 129 of file arg_list.h.

◆ has_unnamed_args()

bool OGF::ArgList::has_unnamed_args ( ) const
inline

Tests whether this ArgList has unnamed args.

Return values
trueif this ArgList has unnamed args
falseotherwise

Definition at line 108 of file arg_list.h.

◆ ith_arg_name()

const std::string& OGF::ArgList::ith_arg_name ( index_t  i) const
inline

Gets argument name by index.

Parameters
[in]ithe index of the argument
Returns
a const reference to the name of argument at index i
Precondition
i < nb_args()

Definition at line 160 of file arg_list.h.

◆ ith_arg_type()

MetaType* OGF::ArgList::ith_arg_type ( index_t  i) const
inline

Gets the type of an argument by index.

Parameters
[in]ithe index of the argument
Returns
a pointer to the type of the argument
Precondition
i < nb_args()

Definition at line 248 of file arg_list.h.

◆ ith_arg_value() [1/3]

Any& OGF::ArgList::ith_arg_value ( index_t  i)
inline

Gets argument value by index, stored as an Any.

Parameters
[in]ithe index of the argument
Returns
a modifiable reference to the argument value at index i, wrapped in an Any.
Precondition
i < nb_args()

Definition at line 209 of file arg_list.h.

◆ ith_arg_value() [2/3]

template<class T >
T OGF::ArgList::ith_arg_value ( index_t  i) const
inline

Gets argument value by index.

If the stored argument is of type T, then it is retreived directly, else it is converted using a temporary string representation.

Parameters
[in]ithe index of the argument
Returns
the value of argument at index i
Template Parameters
Tthe type of the argument to be retreived
Precondition
i < nb_args()

Definition at line 176 of file arg_list.h.

◆ ith_arg_value() [3/3]

const Any& OGF::ArgList::ith_arg_value ( index_t  i) const
inline

Gets argument value by index, stored as an Any.

Parameters
[in]ithe index of the argument
Returns
a const reference to the argument value at index i, wrapped in an Any.
Precondition
i < nb_args()

Definition at line 196 of file arg_list.h.

◆ nb_args()

index_t OGF::ArgList::nb_args ( ) const
inline

Gets the number of arguments.

Returns
the number of arguments in this ArgList

Definition at line 99 of file arg_list.h.

◆ operator=()

ArgList& OGF::ArgList::operator= ( const ArgList rhs)
inline

ArgList assignment operator.

Parameters
[in]rhsa const reference to the ArgList to be copied

Definition at line 89 of file arg_list.h.

◆ set_arg() [1/3]

void OGF::ArgList::set_arg ( const std::string &  name,
const Any value 
)
inline

Sets an argument from an Any.

If the argument already exists, then its value is replaced with the new value, else a new argument is created.

Parameters
[in]namea const reference to the name of the argument
[in]valuethe value as an Any.

Definition at line 359 of file arg_list.h.

◆ set_arg() [2/3]

void OGF::ArgList::set_arg ( const std::string &  name,
const char *  value 
)
inline

Sets an argument from a string litteral.

If the argument already exists, then its value is replaced with the new value, else a new argument is created.

Parameters
[in]namea const reference to the name of the argument
[in]valuea const pointer to a string

Definition at line 346 of file arg_list.h.

◆ set_arg() [3/3]

template<class T >
void OGF::ArgList::set_arg ( const std::string &  name,
const T &  value 
)
inline

Sets an argument.

If the argument already exists, then its value is replaced with the new value, else a new argument is created.

Parameters
[in]namea const reference to the name of the argument
[in]valuea const reference to the value of the argument
Template Parameters
Tthe type of the argument

Definition at line 327 of file arg_list.h.

◆ set_ith_arg() [1/2]

void OGF::ArgList::set_ith_arg ( index_t  i,
const char *  value 
)
inline

Sets an argument by index.

The name of the argument is kept.

Parameters
[in]ithe index of the argument
[in]valuethe value of the argument as a string litteral

Definition at line 386 of file arg_list.h.

◆ set_ith_arg() [2/2]

template<class T >
void OGF::ArgList::set_ith_arg ( index_t  i,
const T &  value 
)
inline

Sets an argument by index.

The name of the argument is kept.

Parameters
[in]ithe index of the argument
[in]valuea const reference to the value of the argument
Template Parameters
Tthe type of the argument

Definition at line 375 of file arg_list.h.


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