Geogram Version 1.10.1
A programming library of geometric algorithms
Loading...
Searching...
No Matches
GEOCSG::ArgList Class Reference

A parsed argument list in a .csg file. More...

#include <geogram/mesh/mesh_CSG_utils.h>

Public Types

typedef std::pair< std::string, ValueArg
 

Public Member Functions

 ArgList ()
 Constructs an empty ArgList.
 
void clear ()
 Removes all the arguments in this arglist.
 
index_t size () const
 Gets the number of arguments.
 
const std::string & ith_arg_name (index_t i) const
 Gets the name of an argument.
 
const Valueith_arg_val (index_t i) const
 Gets the value of an argument.
 
bool has_arg (const std::string &name, index_t pos_fallback=NO_INDEX, Value::Type type=Value::NONE) const
 Tests whether this arglist has an argument.
 
void add_arg (const std::string &name, const Value &value)
 
const Valueget_arg_value (const std::string &name, index_t pos_fallback=NO_INDEX) const
 Gets an argument value.
 
double get_arg (const std::string &name, double default_val, index_t pos_fallback=NO_INDEX) const
 Gets an argument of type double.
 
int get_arg (const std::string &name, int default_val, index_t pos_fallback=NO_INDEX) const
 Gets an argument of type int.
 
bool get_arg (const std::string &name, bool default_val, index_t pos_fallback=NO_INDEX) const
 Gets an argument of type bool.
 
vec2 get_arg (const std::string &name, vec2 default_val, index_t pos_fallback=NO_INDEX) const
 Gets an argument of type vec2.
 
vec3 get_arg (const std::string &name, vec3 default_val, index_t pos_fallback=NO_INDEX) const
 Gets an argument of type vec3.
 
vec4 get_arg (const std::string &name, vec4 default_val, index_t pos_fallback=NO_INDEX) const
 Gets an argument of type vec4.
 
mat4 get_arg (const std::string &name, const mat4 &default_val, index_t pos_fallback=NO_INDEX) const
 Gets an argument of type mat4.
 
std::string get_arg (const std::string &name, const std::string &default_val, index_t pos_fallback=NO_INDEX) const
 Gets an argument of type string.
 
std::string get_arg (const std::string &name, const char *default_val, index_t pos_fallback=NO_INDEX) const
 Gets an argument of type string.
 

Static Protected Member Functions

static std::string unnamed_arg_name (index_t i)
 Gets the internal name used for an unnamed argument.
 

Detailed Description

A parsed argument list in a .csg file.

Stores name-value pairs.

Definition at line 84 of file mesh_CSG_utils.h.

Member Typedef Documentation

◆ Arg

typedef std::pair<std::string, Value> GEOCSG::ArgList::Arg

Definition at line 86 of file mesh_CSG_utils.h.

Member Function Documentation

◆ clear()

void GEOCSG::ArgList::clear ( )
inline

Removes all the arguments in this arglist.

Definition at line 96 of file mesh_CSG_utils.h.

◆ get_arg() [1/9]

bool GEOCSG::ArgList::get_arg ( const std::string &  name,
bool  default_val,
index_t  pos_fallback = NO_INDEX 
) const

Gets an argument of type bool.

Parameters
[in]namethe name of the argument
[in]default_valdefault argument value
[in]pos_fallbacka position fallback to be used if the arglist has no argument with name, or NO_INDEX if no positional fallback is specified
Return values
thevalue of the argument if present in the argument list by name or by positional fallback

p default_val otherwise

fires a std::logic_error exception if argument exists but has incorrect type

◆ get_arg() [2/9]

std::string GEOCSG::ArgList::get_arg ( const std::string &  name,
const char *  default_val,
index_t  pos_fallback = NO_INDEX 
) const
inline

Gets an argument of type string.

Parameters
[in]namethe name of the argument
[in]default_valdefault argument value, as a const char*
[in]pos_fallbacka position fallback to be used if the arglist has no argument with name, or NO_INDEX if no positional fallback is specified
Return values
thevalue of the argument if present in the argument list by name or by positional fallback

p default_val otherwise

fires a std::logic_error exception if argument exists but has incorrect type

Definition at line 317 of file mesh_CSG_utils.h.

◆ get_arg() [3/9]

mat4 GEOCSG::ArgList::get_arg ( const std::string &  name,
const mat4 default_val,
index_t  pos_fallback = NO_INDEX 
) const

Gets an argument of type mat4.

Parameters
[in]namethe name of the argument
[in]default_valdefault argument value
[in]pos_fallbacka position fallback to be used if the arglist has no argument with name, or NO_INDEX if no positional fallback is specified
Return values
thevalue of the argument if present in the argument list by name or by positional fallback

p default_val otherwise

fires a std::logic_error exception if argument exists but has incorrect type

◆ get_arg() [4/9]

std::string GEOCSG::ArgList::get_arg ( const std::string &  name,
const std::string &  default_val,
index_t  pos_fallback = NO_INDEX 
) const

Gets an argument of type string.

Parameters
[in]namethe name of the argument
[in]default_valdefault argument value
[in]pos_fallbacka position fallback to be used if the arglist has no argument with name, or NO_INDEX if no positional fallback is specified
Return values
thevalue of the argument if present in the argument list by name or by positional fallback

p default_val otherwise

fires a std::logic_error exception if argument exists but has incorrect type

◆ get_arg() [5/9]

double GEOCSG::ArgList::get_arg ( const std::string &  name,
double  default_val,
index_t  pos_fallback = NO_INDEX 
) const

Gets an argument of type double.

Parameters
[in]namethe name of the argument
[in]default_valdefault argument value
[in]pos_fallbacka position fallback to be used if the arglist has no argument with name, or NO_INDEX if no positional fallback is specified
Return values
thevalue of the argument if present in the argument list by name or by positional fallback

p default_val otherwise

fires a std::logic_error exception if argument exists but has incorrect type

◆ get_arg() [6/9]

int GEOCSG::ArgList::get_arg ( const std::string &  name,
int  default_val,
index_t  pos_fallback = NO_INDEX 
) const

Gets an argument of type int.

Parameters
[in]namethe name of the argument
[in]default_valdefault argument value
[in]pos_fallbacka position fallback to be used if the arglist has no argument with name, or NO_INDEX if no positional fallback is specified
Return values
thevalue of the argument if present in the argument list by name or by positional fallback

p default_val otherwise

fires a std::logic_error exception if argument exists but has incorrect type

◆ get_arg() [7/9]

vec2 GEOCSG::ArgList::get_arg ( const std::string &  name,
vec2  default_val,
index_t  pos_fallback = NO_INDEX 
) const

Gets an argument of type vec2.

Parameters
[in]namethe name of the argument
[in]default_valdefault argument value
[in]pos_fallbacka position fallback to be used if the arglist has no argument with name, or NO_INDEX if no positional fallback is specified
Return values
thevalue of the argument if present in the argument list by name or by positional fallback

p default_val otherwise

fires a std::logic_error exception if argument exists but has incorrect type

◆ get_arg() [8/9]

vec3 GEOCSG::ArgList::get_arg ( const std::string &  name,
vec3  default_val,
index_t  pos_fallback = NO_INDEX 
) const

Gets an argument of type vec3.

Parameters
[in]namethe name of the argument
[in]default_valdefault argument value
[in]pos_fallbacka position fallback to be used if the arglist has no argument with name, or NO_INDEX if no positional fallback is specified
Return values
thevalue of the argument if present in the argument list by name or by positional fallback

p default_val otherwise

fires a std::logic_error exception if argument exists but has incorrect type

◆ get_arg() [9/9]

vec4 GEOCSG::ArgList::get_arg ( const std::string &  name,
vec4  default_val,
index_t  pos_fallback = NO_INDEX 
) const

Gets an argument of type vec4.

Parameters
[in]namethe name of the argument
[in]default_valdefault argument value
[in]pos_fallbacka position fallback to be used if the arglist has no argument with name, or NO_INDEX if no positional fallback is specified
Return values
thevalue of the argument if present in the argument list by name or by positional fallback

p default_val otherwise

fires a std::logic_error exception if argument exists but has incorrect type

◆ get_arg_value()

const Value & GEOCSG::ArgList::get_arg_value ( const std::string &  name,
index_t  pos_fallback = NO_INDEX 
) const

Gets an argument value.

Parameters
[in]namethe name of the argument
[in]pos_fallbacka position fallback to be used if the arglist has no argument with name, or NO_INDEX if no positional fallback is specified

fires an assertion failure if name is not bound and pos_fallback is NO_INDEX or greater and equal to size()

◆ has_arg()

bool GEOCSG::ArgList::has_arg ( const std::string &  name,
index_t  pos_fallback = NO_INDEX,
Value::Type  type = Value::NONE 
) const

Tests whether this arglist has an argument.

Parameters
[in]namethe name of the argument
[in]pos_fallbacka position fallback to be used if the arglist has no argument with name, or NO_INDEX if no positional fallback is specified
[in]typerequired type for the argument, or NONE if any type matches
Return values
trueif an argument with name exists or pos_fallback is different from NO_INDEX and smaller than size()
falseotherwise

◆ ith_arg_name()

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

Gets the name of an argument.

Parameters
[in]ithe index of the argument, in 0..size()-1
Returns
the name of the i th argument

Definition at line 113 of file mesh_CSG_utils.h.

◆ ith_arg_val()

const Value & GEOCSG::ArgList::ith_arg_val ( index_t  i) const
inline

Gets the value of an argument.

Parameters
[in]ithe index of the argument, in 0..size()-1
Returns
the value of the argument as a const reference to a Value

Definition at line 123 of file mesh_CSG_utils.h.

◆ size()

index_t GEOCSG::ArgList::size ( ) const
inline

Gets the number of arguments.

Returns
the number of arguments in this arglist

Definition at line 104 of file mesh_CSG_utils.h.

◆ unnamed_arg_name()

static std::string GEOCSG::ArgList::unnamed_arg_name ( index_t  i)
inlinestaticprotected

Gets the internal name used for an unnamed argument.

Parameters
[in]ithe index for the i-th unnamed argument
Returns
the internal name of the i-th unnamed argument as a string

Definition at line 330 of file mesh_CSG_utils.h.


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