HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ParamValueList Class Reference

#include <paramlist.h>

+ Inheritance diagram for ParamValueList:

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
 
ParamValuefind_pv (string_view name, TypeDesc type=TypeDesc::UNKNOWN, bool casesensitive=true)
 
const ParamValuefind_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)
 
void attribute (string_view name, ustring 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 ()
 
ParamValueoperator[] (int index)
 
const ParamValueoperator[] (int index) const
 
AttrDelegate< const
ParamValueList
operator[] (string_view name) const
 
AttrDelegate< ParamValueListoperator[] (string_view name)
 

Detailed Description

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 290 of file paramlist.h.

Constructor & Destructor Documentation

ParamValueList::ParamValueList ( )
inline

Definition at line 292 of file paramlist.h.

Member Function Documentation

void ParamValueList::add_or_replace ( const ParamValue pv,
bool  casesensitive = true 
)
void ParamValueList::add_or_replace ( ParamValue &&  pv,
bool  casesensitive = true 
)
void ParamValueList::attribute ( string_view  name,
TypeDesc  type,
int  nvalues,
const void value 
)
inline

Add (or replace) a value in the list.

Definition at line 368 of file paramlist.h.

void ParamValueList::attribute ( string_view  name,
TypeDesc  type,
const void value 
)
inline

Definition at line 375 of file paramlist.h.

void ParamValueList::attribute ( string_view  name,
TypeDesc  type,
string_view  value 
)
inline

Set directly from string – parse if type is non-string.

Definition at line 381 of file paramlist.h.

void ParamValueList::attribute ( string_view  name,
int  value 
)
inline

Definition at line 388 of file paramlist.h.

void ParamValueList::attribute ( string_view  name,
unsigned int  value 
)
inline

Definition at line 392 of file paramlist.h.

void ParamValueList::attribute ( string_view  name,
float  value 
)
inline

Definition at line 396 of file paramlist.h.

void ParamValueList::attribute ( string_view  name,
string_view  value 
)
inline

Definition at line 400 of file paramlist.h.

void ParamValueList::attribute ( string_view  name,
ustring  value 
)
inline

Definition at line 406 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
ParamValue* ParamValueList::find_pv ( string_view  name,
TypeDesc  type = TypeDesc::UNKNOWN,
bool  casesensitive = true 
)
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 316 of file paramlist.h.

const ParamValue* ParamValueList::find_pv ( string_view  name,
TypeDesc  type = TypeDesc::UNKNOWN,
bool  casesensitive = true 
) const
inline

Definition at line 322 of file paramlist.h.

void ParamValueList::free ( )
inline

Even more radical than clear, free ALL memory associated with the list itself.

Definition at line 460 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 retrieve 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 retrieve 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.

TypeDesc ParamValueList::getattributetype ( string_view  name,
bool  casesensitive = false 
) const
inline

Search list for named item, return its type or TypeUnknown if not found.

Definition at line 414 of file paramlist.h.

reference ParamValueList::grow ( )
inline

Add space for one more ParamValue to the list, and return a reference to its slot.

Definition at line 296 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.

Parameters
otherThe ParamValueList whose entries will be merged into this one.
overrideIf 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.
ParamValue& ParamValueList::operator[] ( int  index)
inline

Array indexing by integer will return a reference to the ParamValue in that position of the list.

Definition at line 468 of file paramlist.h.

const ParamValue& ParamValueList::operator[] ( int  index) const
inline

Definition at line 472 of file paramlist.h.

AttrDelegate<const ParamValueList> ParamValueList::operator[] ( string_view  name) const
inline

Array indexing by string will create a "Delegate" that enables a convenient shorthand for adding and retrieving values from the list:

  1. Assigning to the delegate adds a ParamValue to the list: ParamValueList list; list["foo"] = 42; // adds integer list["bar"] = 39.8f; // adds float list["baz"] = "hello"; // adds string Be very careful, the attribute's type will be implied by the C++ type of what you assign.
  2. The delegate supports a get<T>() that retrieves an item of type T: int i = list["foo"].get<int>(); std::string s = list["baz"].get<std::string>();

Definition at line 492 of file paramlist.h.

AttrDelegate<ParamValueList> ParamValueList::operator[] ( string_view  name)
inline

Definition at line 496 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").


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