HDK
|
#include <paramlist.h>
Public Member Functions | |
ParamValueList () | |
reference | grow () |
iterator | find (string_view name, TypeDesc type=TypeDesc::UNKNOWN, bool casesensitive=true) |
iterator | find (ustring name, TypeDesc type=TypeDesc::UNKNOWN, bool casesensitive=true) |
const_iterator | find (string_view name, TypeDesc type=TypeDesc::UNKNOWN, bool casesensitive=true) const |
const_iterator | find (ustring name, TypeDesc type=TypeDesc::UNKNOWN, bool casesensitive=true) const |
ParamValue * | find_pv (string_view name, TypeDesc type=TypeDesc::UNKNOWN, bool casesensitive=true) |
const ParamValue * | find_pv (string_view name, TypeDesc type=TypeDesc::UNKNOWN, bool casesensitive=true) const |
int | get_int (string_view name, int defaultval=0, bool casesensitive=false, bool convert=true) const |
float | get_float (string_view name, float defaultval=0, bool casesensitive=false, bool convert=true) const |
string_view | get_string (string_view name, string_view defaultval=string_view(), bool casesensitive=false, bool convert=true) const |
ustring | get_ustring (string_view name, string_view defaultval=string_view(), bool casesensitive=false, bool convert=true) const |
void | remove (string_view name, TypeDesc type=TypeDesc::UNKNOWN, bool casesensitive=true) |
Remove the named parameter, if it is in the list. More... | |
bool | contains (string_view name, TypeDesc type=TypeDesc::UNKNOWN, bool casesensitive=true) const |
Does the list contain the named attribute? More... | |
void | add_or_replace (const ParamValue &pv, bool casesensitive=true) |
void | add_or_replace (ParamValue &&pv, bool casesensitive=true) |
void | attribute (string_view name, TypeDesc type, int nvalues, const void *value) |
Add (or replace) a value in the list. More... | |
void | attribute (string_view name, TypeDesc type, const void *value) |
void | attribute (string_view name, TypeDesc type, string_view value) |
Set directly from string – parse if type is non-string. More... | |
void | attribute (string_view name, int value) |
void | attribute (string_view name, unsigned int value) |
void | attribute (string_view name, float value) |
void | attribute (string_view name, string_view value) |
TypeDesc | getattributetype (string_view name, bool casesensitive=false) const |
bool | getattribute (string_view name, TypeDesc type, void *value, bool casesensitive=false) const |
bool | getattribute (string_view name, std::string &value, bool casesensitive=false) const |
Shortcut for retrieving a single string via getattribute. More... | |
bool | getattribute_indexed (string_view name, int index, TypeDesc type, void *value, bool casesensitive=false) const |
bool | getattribute_indexed (string_view name, int index, std::string &value, bool casesensitive=false) const |
Shortcut for retrieving a single string via getattribute. More... | |
void | sort (bool casesensitive=true) |
void | merge (const ParamValueList &other, bool override=false) |
void | free () |
ParamValue & | operator[] (int index) |
const ParamValue & | operator[] (int index) const |
AttrDelegate< const ParamValueList > | operator[] (string_view name) const |
AttrDelegate< ParamValueList > | operator[] (string_view name) |
A list of ParamValue entries, that can be iterated over or searched. It's really just a std::vector<ParamValue>, but with a few more handy methods.
Definition at line 237 of file paramlist.h.
|
inline |
Definition at line 239 of file paramlist.h.
void ParamValueList::add_or_replace | ( | const ParamValue & | pv, |
bool | casesensitive = true |
||
) |
void ParamValueList::add_or_replace | ( | ParamValue && | pv, |
bool | casesensitive = true |
||
) |
|
inline |
Add (or replace) a value in the list.
Definition at line 315 of file paramlist.h.
|
inline |
Definition at line 322 of file paramlist.h.
|
inline |
Set directly from string – parse if type is non-string.
Definition at line 328 of file paramlist.h.
|
inline |
Definition at line 335 of file paramlist.h.
|
inline |
Definition at line 339 of file paramlist.h.
|
inline |
Definition at line 343 of file paramlist.h.
|
inline |
Definition at line 347 of file paramlist.h.
bool ParamValueList::contains | ( | string_view | name, |
TypeDesc | type = TypeDesc::UNKNOWN , |
||
bool | casesensitive = true |
||
) | const |
Does the list contain the named attribute?
iterator ParamValueList::find | ( | string_view | name, |
TypeDesc | type = TypeDesc::UNKNOWN , |
||
bool | casesensitive = true |
||
) |
Find the first entry with matching name, and if type != UNKNOWN, then also with matching type. The name search is case sensitive if casesensitive == true.
iterator ParamValueList::find | ( | ustring | name, |
TypeDesc | type = TypeDesc::UNKNOWN , |
||
bool | casesensitive = true |
||
) |
const_iterator ParamValueList::find | ( | string_view | name, |
TypeDesc | type = TypeDesc::UNKNOWN , |
||
bool | casesensitive = true |
||
) | const |
const_iterator ParamValueList::find | ( | ustring | name, |
TypeDesc | type = TypeDesc::UNKNOWN , |
||
bool | casesensitive = true |
||
) | const |
|
inline |
Search for the first entry with matching name, etc., and return a pointer to it, or nullptr if it is not found.
Definition at line 263 of file paramlist.h.
|
inline |
Definition at line 269 of file paramlist.h.
|
inline |
Even more radical than clear, free ALL memory associated with the list itself.
Definition at line 401 of file paramlist.h.
float ParamValueList::get_float | ( | string_view | name, |
float | defaultval = 0 , |
||
bool | casesensitive = false , |
||
bool | convert = true |
||
) | const |
Case insensitive search for a float, with default if not found. Automatically will return a float even if the data is really double or half. It will retrive from a string, but only if the string is entirely a valid float format.
int ParamValueList::get_int | ( | string_view | name, |
int | defaultval = 0 , |
||
bool | casesensitive = false , |
||
bool | convert = true |
||
) | const |
Case insensitive search for an integer, with default if not found. Automatically will return an int even if the data is really unsigned, short, or byte, but not float. It will retrive from a string, but only if the string is entirely a valid int format.
string_view ParamValueList::get_string | ( | string_view | name, |
string_view | defaultval = string_view() , |
||
bool | casesensitive = false , |
||
bool | convert = true |
||
) | const |
Simple way to get a string attribute, with default provided. If the value is another type, it will be turned into a string.
ustring ParamValueList::get_ustring | ( | string_view | name, |
string_view | defaultval = string_view() , |
||
bool | casesensitive = false , |
||
bool | convert = true |
||
) | const |
bool ParamValueList::getattribute | ( | string_view | name, |
TypeDesc | type, | ||
void * | value, | ||
bool | casesensitive = false |
||
) | const |
Retrieve from list: If found its data type is reasonably convertible to type
, copy/convert the value into val[...] and return true. Otherwise, return false and don't modify what val points to.
bool ParamValueList::getattribute | ( | string_view | name, |
std::string & | value, | ||
bool | casesensitive = false |
||
) | const |
Shortcut for retrieving a single string via getattribute.
bool ParamValueList::getattribute_indexed | ( | string_view | name, |
int | index, | ||
TypeDesc | type, | ||
void * | value, | ||
bool | casesensitive = false |
||
) | const |
Retrieve from list: If found its data type is reasonably convertible to type
, copy/convert the value into val[...] and return true. Otherwise, return false and don't modify what val points to.
bool ParamValueList::getattribute_indexed | ( | string_view | name, |
int | index, | ||
std::string & | value, | ||
bool | casesensitive = false |
||
) | const |
Shortcut for retrieving a single string via getattribute.
|
inline |
Search list for named item, return its type or TypeUnknown if not found.
Definition at line 355 of file paramlist.h.
|
inline |
Add space for one more ParamValue to the list, and return a reference to its slot.
Definition at line 243 of file paramlist.h.
void ParamValueList::merge | ( | const ParamValueList & | other, |
bool | override = false |
||
) |
Merge items from PVL other
into *this
. Note how this differs from operator=
: assignment completely replaces the list with the contents of another. But merge() adds the other items without erasing any items already in this list.
other | The ParamValueList whose entries will be merged into this one. |
override | If true, other attributes will replace any identically-named attributes already in this list. If false, only attributes whose names are not already in this list will be appended. |
|
inline |
Array indexing by integer will return a reference to the ParamValue in that position of the list.
Definition at line 409 of file paramlist.h.
|
inline |
Definition at line 413 of file paramlist.h.
|
inline |
Array indexing by string will create a "Delegate" that enables a convenient shorthand for adding and retrieving values from the list:
Definition at line 433 of file paramlist.h.
|
inline |
Definition at line 437 of file paramlist.h.
void ParamValueList::remove | ( | string_view | name, |
TypeDesc | type = TypeDesc::UNKNOWN , |
||
bool | casesensitive = true |
||
) |
Remove the named parameter, if it is in the list.
void ParamValueList::sort | ( | bool | casesensitive = true | ) |
Sort alphabetically, optionally case-insensitively, locale- independently, and with all the "un-namespaced" items appearing first, followed by items with "prefixed namespaces" (e.g. "z" comes before "foo:a").