This holds a value from the configuration. More...
#include <TsValue.h>
Public Types | |
typedef Value | self |
Self reference type. | |
Public Member Functions | |
Value () | |
Default constructors. | |
~Value () | |
Destructor. | |
ValueType | getType () const |
Get the type of value. | |
bool | hasValue () const |
Test if this is a valid value. | |
bool | operator! () const |
Operator form of hasValue . | |
operator detail::PseudoBool::Type () const | |
Logical form of hasValue for use in logical expressions. | |
ConstBuffer const & | getText () const |
Get the value text. | |
self & | setText (ConstBuffer const &text) |
Set the text for this value. | |
ConstBuffer const & | getName () const |
Get local name. | |
size_t | getIndex () const |
Get local index. | |
bool | isLiteral () const |
Test for a literal value. | |
bool | isContainer () const |
Test for value container. | |
Value | getParent () const |
Get the parent value. | |
bool | isRoot () const |
Test if this is the root value for the configuration. | |
size_t | childCount () const |
Get the number of child values. | |
Value | operator[] (size_t idx) const |
Child access by index. | |
Value | operator[] (ConstBuffer const &name) const |
Child access by name. | |
Value | operator[] (char const *name) const |
Child access by name. | |
Value | find (ConstBuffer const &path) |
Find a value. | |
Value | find (char const *path) |
Find a value. | |
Value | find (Path const &path) |
Find a value using a precondensed path. | |
self & | reset () |
Reset to default constructed state. | |
self & | setSourceLine (int line) |
Set source line. | |
self & | setSourceColumn (int col) |
Set source column. | |
self & | setSource (int line, int col) |
Set the source location. | |
int | getSourceLine () const |
Get source line. | |
int | getSourceColumn () const |
Get source column. | |
Creating child values. | |
These methods all take an optional name argument. This is required if These methods will fail if
| |
Rv< Value > | makeString (ConstBuffer const &text, ConstBuffer const &name=detail::NULL_BUFFER) |
Create a String value. | |
Rv< Value > | makeInteger (ConstBuffer const &text, ConstBuffer const &name=detail::NULL_BUFFER) |
Create an Integer value. | |
Rv< Value > | makeGroup (ConstBuffer const &name=detail::NULL_BUFFER) |
Create a Group value. | |
Rv< Value > | makeList (ConstBuffer const &name=detail::NULL_BUFFER) |
Create a List value. | |
Rv< Value > | makePath (Path const &path, ConstBuffer const &name=detail::NULL_BUFFER) |
Create a Path value. | |
Rv< Value > | makeChild (ValueType type, ConstBuffer const &name=detail::NULL_BUFFER) |
Create a child by type. | |
Protected Member Functions | |
Value (Configuration cfg, detail::ValueIndex vidx) | |
Construct from raw data. | |
detail::ValueItem * | item () |
Get raw item pointer. | |
detail::ValueItem const * | item () const |
Get constant raw item pointer. | |
Protected Attributes | |
Configuration | _config |
The configuration for this value. | |
detail::ValueIndex | _vidx |
Index of item. | |
Static Protected Attributes | |
static Buffer const | NULL_BUFFER |
Empty buffer to return on method failures. | |
Friends | |
class | Configuration |
This holds a value from the configuration.
Definition at line 420 of file TsValue.h.
typedef Value ts::config::Value::self |
ts::config::Value::Value | ( | ) | [inline] |
Default constructors.
Creates an NULL
instance.
Definition at line 653 of file TsValue.h.
Referenced by getParent(), makeChild(), and operator[]().
ts::config::Value::Value | ( | Configuration | cfg, | |
detail::ValueIndex | vidx | |||
) | [inline, protected] |
size_t ts::config::Value::childCount | ( | ) | const [inline] |
Get the number of child values.
Definition at line 684 of file TsValue.h.
References ts::config::detail::ValueItem::_children, and item().
Referenced by ts::config::Configuration::childCount().
Value ts::config::Value::find | ( | ConstBuffer const & | path | ) |
Find a value.
path | Path relative to this value. |
Definition at line 150 of file TsValue.cc.
References ts::ConstBuffer::_size, ts::config::Path::Parser::EOP, ts::config::Path::Parser::ERROR, ts::config::Path::Parser::INDEX, ts::config::Path::Parser::parse(), reset(), and ts::config::Path::Parser::TAG.
Referenced by ts::config::Configuration::find(), find(), and operator[]().
Value ts::config::Value::find | ( | char const * | path | ) | [inline] |
Find a value using a precondensed path.
path | Path relative to this value. |
Definition at line 165 of file TsValue.cc.
References ts::ConstBuffer::_ptr, ts::ConstBuffer::_size, and ts::config::Path::count().
size_t ts::config::Value::getIndex | ( | ) | const [inline] |
Get local index.
This gets the local index for the value. This is the index which, if used on the parent, would yield this value.
Definition at line 671 of file TsValue.h.
References ts::config::detail::ValueItem::_local_index, and item().
ConstBuffer const & ts::config::Value::getName | ( | ) | const [inline] |
Get local name.
This gets the local name of the value. That is the name by which it is known to its parent container.
Definition at line 667 of file TsValue.h.
References ts::config::detail::ValueItem::_name, item(), and ts::config::detail::NULL_CONST_BUFFER.
Value ts::config::Value::getParent | ( | ) | const [inline] |
Get the parent value.
Definition at line 678 of file TsValue.h.
References _config, ts::config::Configuration::_table, _vidx, hasValue(), and Value().
Referenced by ts::config::Builder::groupClose(), and ts::config::Builder::listClose().
int ts::config::Value::getSourceColumn | ( | ) | const [inline] |
Get source column.
Definition at line 693 of file TsValue.h.
References ts::config::detail::ValueItem::_srcColumn, and item().
int ts::config::Value::getSourceLine | ( | ) | const [inline] |
Get source line.
Definition at line 689 of file TsValue.h.
References ts::config::detail::ValueItem::_srcLine, and item().
ConstBuffer const & ts::config::Value::getText | ( | ) | const [inline] |
Get the value text.
Definition at line 659 of file TsValue.h.
References _config, ts::config::Configuration::_table, _vidx, hasValue(), and ts::config::detail::NULL_CONST_BUFFER.
Referenced by main().
ValueType ts::config::Value::getType | ( | ) | const [inline] |
Get the type of value.
Definition at line 658 of file TsValue.h.
References _config, ts::config::Configuration::_table, _vidx, and hasValue().
Referenced by isContainer(), isLiteral(), and operator[]().
bool ts::config::Value::hasValue | ( | ) | const [inline] |
Test if this is a valid value.
true
if this contains a value, false
otherwise. Definition at line 655 of file TsValue.h.
References _config, _vidx, and ts::config::detail::NULL_VALUE_INDEX.
Referenced by getParent(), getText(), getType(), isRoot(), item(), operator detail::PseudoBool::Type(), and operator!().
bool ts::config::Value::isContainer | ( | ) | const [inline] |
Test for value container.
true
if the value is a container (can have child values), false
otherwise. Definition at line 677 of file TsValue.h.
References getType(), ts::config::detail::IS_CONTAINER, and ts::config::detail::Type_Property.
bool ts::config::Value::isLiteral | ( | ) | const [inline] |
Test for a literal value.
true
if the value is a literal, false
if it is a container or invalid. Definition at line 676 of file TsValue.h.
References getType(), ts::config::detail::IS_LITERAL, and ts::config::detail::Type_Property.
bool ts::config::Value::isRoot | ( | ) | const [inline] |
Test if this is the root value for the configuration.
Definition at line 679 of file TsValue.h.
References _vidx, and hasValue().
detail::ValueItem * ts::config::Value::item | ( | ) | [inline, protected] |
Get raw item pointer.
NULL
if this value is invalid. Definition at line 681 of file TsValue.h.
References _config, ts::config::Configuration::_table, _vidx, and hasValue().
Referenced by childCount(), getIndex(), getName(), getSourceColumn(), getSourceLine(), item(), operator[](), setSource(), setSourceColumn(), setSourceLine(), and setText().
detail::ValueItem const * ts::config::Value::item | ( | ) | const [inline, protected] |
Rv< Value > ts::config::Value::makeChild | ( | ValueType | type, | |
ConstBuffer const & | name = detail::NULL_BUFFER | |||
) |
Create a child by type.
Client must fill in any other required elements.
type | Type of child. | |
name | Optional name of value. |
Definition at line 176 of file TsValue.cc.
References _config, ts::config::Configuration::_table, _vidx, ts::Rv< R >::errata(), ts::RvBase::isOK(), ts::config::detail::ValueTable::make(), ts::Rv< R >::result(), and Value().
Referenced by makeGroup(), makeInteger(), makeList(), makePath(), and makeString().
Rv< Value > ts::config::Value::makeGroup | ( | ConstBuffer const & | name = detail::NULL_BUFFER |
) |
Create a Group
value.
name | Optional name of value. |
Definition at line 185 of file TsValue.cc.
References ts::config::GroupValue, and makeChild().
Referenced by ts::config::Builder::groupOpen().
Rv< Value > ts::config::Value::makeInteger | ( | ConstBuffer const & | text, | |
ConstBuffer const & | name = detail::NULL_BUFFER | |||
) |
Create an Integer
value.
text | Text of number. | |
name | Optional name of value. |
Definition at line 202 of file TsValue.cc.
References ts::config::IntegerValue, ts::RvBase::isOK(), makeChild(), and ts::Rv< R >::result().
Referenced by ts::config::Builder::literalValue().
Rv< Value > ts::config::Value::makeList | ( | ConstBuffer const & | name = detail::NULL_BUFFER |
) |
Create a List
value.
name | Optional name of value. |
Definition at line 190 of file TsValue.cc.
References ts::config::ListValue, and makeChild().
Referenced by ts::config::Builder::listOpen().
Rv< Value > ts::config::Value::makePath | ( | Path const & | path, | |
ConstBuffer const & | name = detail::NULL_BUFFER | |||
) |
Create a Path
value.
path | Path. | |
name | Optional name of value. |
Definition at line 209 of file TsValue.cc.
References _config, ts::config::Configuration::_table, ts::RvBase::isOK(), makeChild(), ts::config::PathValue, and ts::Rv< R >::result().
Referenced by ts::config::Builder::pathClose().
Rv< Value > ts::config::Value::makeString | ( | ConstBuffer const & | text, | |
ConstBuffer const & | name = detail::NULL_BUFFER | |||
) |
Create a String
value.
text | String content. | |
name | Optional name of value. |
Definition at line 195 of file TsValue.cc.
References ts::RvBase::isOK(), makeChild(), ts::Rv< R >::result(), and ts::config::StringValue.
Referenced by ts::config::Builder::literalValue().
ts::config::Value::operator detail::PseudoBool::Type | ( | ) | const [inline] |
Logical form of hasValue
for use in logical expressions.
true
if this does not contain a value, the equivalent of false
if it does. Definition at line 656 of file TsValue.h.
References ts::config::detail::PseudoBool::FALSE, hasValue(), and ts::config::detail::PseudoBool::TRUE.
bool ts::config::Value::operator! | ( | ) | const [inline] |
Operator form of hasValue
.
true
if this does not contain a value, false
if it does. Definition at line 657 of file TsValue.h.
References hasValue().
Value ts::config::Value::operator[] | ( | ConstBuffer const & | name | ) | const |
Child access by name.
Void
value if there is no child with name. Definition at line 134 of file TsValue.cc.
References ts::config::detail::ValueItem::_children, _config, ts::config::Configuration::_table, _vidx, find(), ts::config::Configuration::getRoot(), getType(), item(), ts::config::PathValue, and Value().
Value ts::config::Value::operator[] | ( | char const * | name | ) | const [inline] |
Value ts::config::Value::operator[] | ( | size_t | idx | ) | const |
Child access by index.
Void
value if there is no child with name. idx | Index of child value. |
Definition at line 123 of file TsValue.cc.
References ts::config::detail::ValueItem::_children, _config, ts::config::Configuration::_table, _vidx, find(), ts::config::Configuration::getRoot(), getType(), item(), ts::config::PathValue, and Value().
Value & ts::config::Value::reset | ( | ) | [inline] |
Reset to default constructed state.
this
object. Definition at line 680 of file TsValue.h.
References _config, _vidx, Configuration, and ts::config::detail::NULL_VALUE_INDEX.
Referenced by find().
Value & ts::config::Value::setSource | ( | int | line, | |
int | col | |||
) | [inline] |
Set the source location.
line | Line in source stream. | |
col | Column in source stream. |
Definition at line 707 of file TsValue.h.
References ts::config::detail::ValueItem::_srcColumn, ts::config::detail::ValueItem::_srcLine, and item().
Referenced by ts::config::Builder::groupOpen(), and ts::config::Builder::listOpen().
Value & ts::config::Value::setSourceColumn | ( | int | col | ) | [inline] |
Set source column.
this
object. col | Column in source stream. |
Definition at line 702 of file TsValue.h.
References ts::config::detail::ValueItem::_srcColumn, and item().
Value & ts::config::Value::setSourceLine | ( | int | line | ) | [inline] |
Set source line.
this
object. line | Line in source stream. |
Definition at line 697 of file TsValue.h.
References ts::config::detail::ValueItem::_srcLine, and item().
Value & ts::config::Value::setText | ( | ConstBuffer const & | text | ) | [inline] |
Set the text for this value.
Definition at line 662 of file TsValue.h.
References ts::config::detail::ValueItem::_text, and item().
friend class Configuration [friend] |
Configuration ts::config::Value::_config [protected] |
The configuration for this value.
Definition at line 615 of file TsValue.h.
Referenced by getParent(), getText(), getType(), hasValue(), item(), makeChild(), makePath(), operator[](), and reset().
detail::ValueIndex ts::config::Value::_vidx [protected] |
Index of item.
Definition at line 616 of file TsValue.h.
Referenced by getParent(), getText(), getType(), hasValue(), isRoot(), item(), makeChild(), operator[](), and reset().
Buffer const ts::config::Value::NULL_BUFFER [static, protected] |