A single value (typically within a Bottle). More...
#include <yarp/os/Value.h>
Public Member Functions | |
Value () | |
Construct a list Value. | |
Value (std::int32_t x, bool isVocab32=false) | |
Construct an integer Value. | |
Value (yarp::conf::float64_t x) | |
Construct a floating point Value. | |
Value (const std::string &str, bool isVocab32=false) | |
Construct a string Value. | |
Value (void *data, int length) | |
Construct a binary data Value. | |
Value (const Value &alt) | |
Copy constructor. | |
const Value & | operator= (const Value &alt) |
Assignment operator. | |
~Value () override | |
Destructor. | |
virtual bool | isBool () const |
Checks if value is a boolean. | |
virtual bool | isInt8 () const |
Checks if value is a 8-bit integer. | |
virtual bool | isInt16 () const |
Checks if value is a 16-bit integer. | |
virtual bool | isInt32 () const |
Checks if value is a 32-bit integer. | |
virtual bool | isInt64 () const |
Checks if value is a 64-bit integer. | |
virtual bool | isFloat32 () const |
Checks if value is a 32-bit floating point number. | |
virtual bool | isFloat64 () const |
Checks if value is a 64-bit floating point number. | |
virtual bool | isString () const |
Checks if value is a string. | |
virtual bool | isList () const |
Checks if value is a list. | |
virtual bool | isDict () const |
Checks if value is a dictionary. | |
virtual bool | isVocab32 () const |
Checks if value is a vocabulary identifier. | |
virtual bool | isBlob () const |
Checks if value is a binary object. | |
virtual bool | asBool () const |
Get boolean value. | |
virtual std::int8_t | asInt8 () const |
Get 8-bit integer value. | |
virtual std::int16_t | asInt16 () const |
Get 16-bit integer value. | |
virtual std::int32_t | asInt32 () const |
Get 32-bit integer value. | |
virtual std::int64_t | asInt64 () const |
Get 64-bit integer value. | |
virtual yarp::conf::float32_t | asFloat32 () const |
Get 32-bit floating point value. | |
virtual yarp::conf::float64_t | asFloat64 () const |
Get 64-bit floating point value. | |
virtual yarp::conf::vocab32_t | asVocab32 () const |
Get vocabulary identifier as an integer. | |
virtual std::string | asString () const |
Get string value. | |
virtual Bottle * | asList () const |
Get list value. | |
virtual Property * | asDict () const |
Get dictionary (hash table) value. | |
virtual Searchable * | asSearchable () const |
Get dictionary or list value. | |
virtual const char * | asBlob () const |
Get binary data value. | |
virtual size_t | asBlobLength () const |
Get binary data length. | |
bool | read (ConnectionReader &connection) override |
Read this object from a network connection. | |
bool | write (ConnectionWriter &connection) const override |
Write this object to a network connection. | |
bool | check (const std::string &key) const override |
Check if there exists a property of the given name. | |
Value & | find (const std::string &key) const override |
Gets a value corresponding to a given keyword. | |
Bottle & | findGroup (const std::string &key) const override |
Gets a list corresponding to a given keyword. | |
bool | operator== (const Value &alt) const |
Equality test. | |
bool | operator!= (const Value &alt) const |
Inequality test. | |
void | fromString (const char *str) |
Set value to correspond to a textual representation. | |
std::string | toString () const override |
Return a standard text representation of the content of the object. | |
virtual Value * | create () const |
Create a new value of the same type. | |
virtual Value * | clone () const |
Create a copy of the value. | |
virtual std::int32_t | getCode () const |
Get standard type code of value. | |
bool | isNull () const override |
Checks if the object is invalid. | |
virtual bool | isLeaf () const |
virtual bool | check (const std::string &key) const=0 |
Check if there exists a property of the given name. | |
virtual bool | check (const std::string &key, const std::string &comment) const |
Check if there exists a property of the given name. | |
virtual bool | check (const std::string &key, Value *&result, const std::string &comment="") const |
Gets a value corresponding to a given keyword. | |
virtual Value | check (const std::string &key, const Value &fallback, const std::string &comment="") const |
Gets a value corresponding to a given keyword. | |
virtual Bottle & | findGroup (const std::string &key) const=0 |
Gets a list corresponding to a given keyword. | |
Bottle & | findGroup (const std::string &key, const std::string &comment) const |
Gets a list corresponding to a given keyword. | |
Public Member Functions inherited from yarp::os::Portable | |
virtual Type | getType () const |
Public Member Functions inherited from yarp::os::PortReader | |
virtual | ~PortReader () |
Destructor. | |
virtual Type | getReadType () const |
Public Member Functions inherited from yarp::os::PortWriter | |
virtual | ~PortWriter () |
Destructor. | |
virtual void | onCompletion () const |
This is called when the port has finished all writing operations. | |
virtual void | onCommencement () const |
This is called when the port is about to begin writing operations. | |
virtual yarp::os::Type | getWriteType () const |
Public Member Functions inherited from yarp::os::Searchable | |
Searchable () | |
Default constructor. | |
Searchable (const Searchable &rhs)=default | |
Copy constructor. | |
Searchable (Searchable &&rhs) noexcept=default | |
Move constructor. | |
virtual | ~Searchable () |
Destructor. | |
Searchable & | operator= (const Searchable &rhs)=default |
Copy assignment operator. | |
Searchable & | operator= (Searchable &&rhs) noexcept=default |
Move assignment operator. | |
Bottle & | findGroup (const std::string &key, const std::string &comment) const |
Gets a list corresponding to a given keyword. | |
Static Public Member Functions | |
static Value * | makeInt8 (std::int8_t x) |
Create a 8-bit integer Value. | |
static Value * | makeInt16 (std::int16_t x) |
Create a 16-bit integer Value. | |
static Value * | makeInt32 (std::int32_t x) |
Create a 32-bit integer Value. | |
static Value * | makeInt64 (std::int64_t x) |
Create a 64-bit integer Value. | |
static Value * | makeFloat32 (yarp::conf::float32_t x) |
Create a 32-bit floating point Value. | |
static Value * | makeFloat64 (yarp::conf::float64_t x) |
Create a 64-bit floating point Value. | |
static Value * | makeString (const std::string &str) |
Create a string Value. | |
static Value * | makeVocab32 (yarp::conf::vocab32_t v) |
Create a vocabulary identifier Value. | |
static Value * | makeVocab32 (char a, char b=0, char c=0, char d=0) |
Create a vocabulary identifier Value. | |
static Value * | makeVocab32 (const std::string &str) |
Create a vocabulary identifier Value If the string is longer than 4 characters, only the first 4 are used. | |
static Value * | makeBlob (void *data, int length) |
Create a Value containing binary data. | |
static Value * | makeList () |
Create a list Value. | |
static Value * | makeList (const char *txt) |
Create a list Value and initialize it. | |
static Value * | makeValue (const std::string &txt) |
Create a Value from a text description. | |
static Value & | getNullValue () |
Return an invalid, "null" Value. | |
Static Public Member Functions inherited from yarp::os::Portable | |
static bool | copyPortable (const PortWriter &writer, PortReader &reader) |
Copy one portable to another, via writing and reading. | |
A single value (typically within a Bottle).
Values can be integers, strings, doubles (floating-point numbers), lists, vocabulary, or blobs (unformatted binary data). This set is carefully chosen to have good text and binary representations both for network transmission and human viewing/generation. Lists are represented as a nested Bottle object. Value objects are Searchable - but you won't find anything in them unless they are actually a list.
|
explicit |
Get binary data value.
Reimplemented in yarp::os::impl::Storable, and yarp::os::impl::StoreBlob.
|
virtual |
Get binary data length.
Reimplemented in yarp::os::impl::Storable, and yarp::os::impl::StoreBlob.
|
virtual |
Get boolean value.
Reimplemented in yarp::os::impl::Storable, yarp::os::impl::StoreInt8, yarp::os::impl::StoreInt16, yarp::os::impl::StoreInt32, yarp::os::impl::StoreInt64, and yarp::os::impl::StoreVocab32.
|
virtual |
Get dictionary (hash table) value.
Reimplemented in yarp::os::impl::Storable, and yarp::os::impl::StoreDict.
|
virtual |
Get 32-bit floating point value.
Reimplemented in yarp::os::impl::Storable, yarp::os::impl::StoreInt8, yarp::os::impl::StoreInt16, yarp::os::impl::StoreInt32, yarp::os::impl::StoreInt64, yarp::os::impl::StoreFloat32, yarp::os::impl::StoreFloat64, and yarp::os::impl::StoreVocab32.
|
virtual |
Get 64-bit floating point value.
Reimplemented in yarp::os::impl::Storable, yarp::os::impl::StoreInt8, yarp::os::impl::StoreInt16, yarp::os::impl::StoreInt32, yarp::os::impl::StoreInt64, yarp::os::impl::StoreFloat32, yarp::os::impl::StoreFloat64, and yarp::os::impl::StoreVocab32.
|
virtual |
Get 16-bit integer value.
Reimplemented in yarp::os::impl::Storable, yarp::os::impl::StoreInt8, yarp::os::impl::StoreInt16, yarp::os::impl::StoreInt32, yarp::os::impl::StoreInt64, yarp::os::impl::StoreFloat32, and yarp::os::impl::StoreFloat64.
|
virtual |
Get 32-bit integer value.
Reimplemented in yarp::os::impl::Storable, yarp::os::impl::StoreInt8, yarp::os::impl::StoreInt16, yarp::os::impl::StoreInt32, yarp::os::impl::StoreInt64, yarp::os::impl::StoreFloat32, yarp::os::impl::StoreFloat64, and yarp::os::impl::StoreVocab32.
|
virtual |
Get 64-bit integer value.
Reimplemented in yarp::os::impl::Storable, yarp::os::impl::StoreInt8, yarp::os::impl::StoreInt16, yarp::os::impl::StoreInt32, yarp::os::impl::StoreInt64, yarp::os::impl::StoreFloat32, yarp::os::impl::StoreFloat64, and yarp::os::impl::StoreVocab32.
|
virtual |
Get 8-bit integer value.
Reimplemented in yarp::os::impl::Storable, yarp::os::impl::StoreInt8, yarp::os::impl::StoreInt16, yarp::os::impl::StoreInt32, yarp::os::impl::StoreInt64, yarp::os::impl::StoreFloat32, and yarp::os::impl::StoreFloat64.
|
virtual |
Get list value.
Reimplemented in yarp::os::impl::Storable, and yarp::os::impl::StoreList.
|
virtual |
Get dictionary or list value.
Reimplemented in yarp::os::impl::Storable.
|
virtual |
Get string value.
Reimplemented in yarp::os::impl::Storable, yarp::os::impl::StoreVocab32, and yarp::os::impl::StoreString.
|
virtual |
Get vocabulary identifier as an integer.
Reimplemented in yarp::os::impl::Storable, yarp::os::impl::StoreInt8, yarp::os::impl::StoreInt16, yarp::os::impl::StoreInt32, yarp::os::impl::StoreInt64, yarp::os::impl::StoreVocab32, and yarp::os::impl::StoreString.
Check if there exists a property of the given name.
key | the name to check for |
Implements yarp::os::Searchable.
Check if there exists a property of the given name.
key | the name to check for |
Implements yarp::os::Searchable.
|
virtual |
Check if there exists a property of the given name.
key | the name to check for |
comment | Human-readable explanation |
Reimplemented from yarp::os::Searchable.
Definition at line 79 of file Searchable.cpp.
|
virtual |
Gets a value corresponding to a given keyword.
key | The keyword to look for |
fallback | A default value to return if nothing found |
comment | Optional human-readable explanation |
Reimplemented from yarp::os::Searchable.
Definition at line 156 of file Searchable.cpp.
|
virtual |
Gets a value corresponding to a given keyword.
If a property does not exist, this returns false and does not modify the result pointer. If a property exists but does not have a value, this again returns false and does not modify the result pointer.
key | The keyword to look for |
result | A pointer to store the address of the result in |
comment | Optional human-readable explanation |
Reimplemented from yarp::os::Searchable.
Definition at line 142 of file Searchable.cpp.
|
virtual |
Create a copy of the value.
Reimplemented in yarp::os::impl::Storable.
|
virtual |
Create a new value of the same type.
Reimplemented in yarp::os::impl::Storable.
Gets a value corresponding to a given keyword.
key | The keyword to look for |
Implements yarp::os::Searchable.
Gets a list corresponding to a given keyword.
key | The keyword to look for |
Implements yarp::os::Searchable.
Gets a list corresponding to a given keyword.
key | The keyword to look for |
Implements yarp::os::Searchable.
yarp::os::Bottle & yarp::os::Searchable::findGroup | ( | const std::string & | key, |
const std::string & | comment | ||
) | const |
Gets a list corresponding to a given keyword.
key | The keyword to look for |
comment | Human-readable explanation |
Definition at line 115 of file Searchable.cpp.
|
virtual |
Get standard type code of value.
Reimplemented in yarp::os::impl::StoreNull, yarp::os::impl::StoreInt8, yarp::os::impl::StoreInt16, yarp::os::impl::StoreInt32, yarp::os::impl::StoreInt64, yarp::os::impl::StoreFloat32, yarp::os::impl::StoreFloat64, yarp::os::impl::StoreVocab32, yarp::os::impl::StoreString, yarp::os::impl::StoreBlob, yarp::os::impl::StoreList, and yarp::os::impl::StoreDict.
|
static |
|
virtual |
Checks if value is a binary object.
If so, asBlob() and asBlobLength() will return it.
Reimplemented in yarp::os::impl::Storable, and yarp::os::impl::StoreBlob.
|
virtual |
Checks if value is a boolean.
If so, asBool() will return that boolean.
Reimplemented in yarp::os::impl::Storable, and yarp::os::impl::StoreVocab32.
|
virtual |
Checks if value is a dictionary.
If so, asDict() will return that dictionary.
Reimplemented in yarp::os::impl::Storable, and yarp::os::impl::StoreDict.
|
virtual |
Checks if value is a 32-bit floating point number.
If so, asFloat32() will return that number.
Reimplemented in yarp::os::impl::Storable, and yarp::os::impl::StoreFloat32.
|
virtual |
Checks if value is a 64-bit floating point number.
If so, asFloat64() will return that number.
Reimplemented in yarp::os::impl::Storable, and yarp::os::impl::StoreFloat64.
|
virtual |
Checks if value is a 16-bit integer.
If so, asInt16() will return that integer.
Reimplemented in yarp::os::impl::Storable, and yarp::os::impl::StoreInt16.
|
virtual |
Checks if value is a 32-bit integer.
If so, asInt32() will return that integer.
Reimplemented in yarp::os::impl::Storable, and yarp::os::impl::StoreInt32.
|
virtual |
Checks if value is a 64-bit integer.
If so, asInt64() will return that integer.
Reimplemented in yarp::os::impl::Storable, and yarp::os::impl::StoreInt64.
|
virtual |
Checks if value is a 8-bit integer.
If so, asInt8() will return that integer.
Reimplemented in yarp::os::impl::Storable, and yarp::os::impl::StoreInt8.
|
virtual |
Reimplemented in yarp::os::impl::Storable.
|
virtual |
Checks if value is a list.
If so, asList() will return that list.
Reimplemented in yarp::os::impl::Storable, and yarp::os::impl::StoreList.
|
overridevirtual |
Checks if the object is invalid.
Reimplemented from yarp::os::Searchable.
|
virtual |
Checks if value is a string.
If so, asString() will return that string.
Reimplemented in yarp::os::impl::Storable, and yarp::os::impl::StoreString.
|
virtual |
Checks if value is a vocabulary identifier.
If so, asVocab32() will return it.
Reimplemented in yarp::os::impl::Storable, and yarp::os::impl::StoreVocab32.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
overridevirtual |
Read this object from a network connection.
Override this for your particular class.
reader | an interface to the network connection for reading |
Implements yarp::os::Portable.
|
overridevirtual |
Return a standard text representation of the content of the object.
The representation is readable by the Bottle and Property classes.
Implements yarp::os::Searchable.
|
overridevirtual |
Write this object to a network connection.
Override this for your particular class. Be aware that depending on the nature of the connections a port has, and what protocol they use, and how efficient the YARP implementation is, this method may be called once, twice, or many times, as the result of a single call to Port::write
writer | an interface to the network connection for writing |
Implements yarp::os::Portable.