YARP
Yet Another Robot Platform
yarp::os::Value Class Reference

A single value (typically within a Bottle). More...

#include <yarp/os/Value.h>

+ Inheritance diagram for yarp::os::Value:

Public Member Functions

 Value ()
 Construct a list Value. More...
 
 Value (std::int32_t x, bool isVocab=false)
 Construct an integer Value. More...
 
 Value (yarp::conf::float64_t x)
 Construct a floating point Value. More...
 
 Value (const std::string &str, bool isVocab=false)
 Construct a string Value. More...
 
 Value (void *data, int length)
 Construct a binary data Value. More...
 
 Value (const Value &alt)
 Copy constructor. More...
 
const Valueoperator= (const Value &alt)
 Assignment operator. More...
 
virtual ~Value ()
 Destructor. More...
 
virtual bool isBool () const
 Checks if value is a boolean. More...
 
virtual bool isInt () const final
 Checks if value is an integer. More...
 
virtual bool isInt8 () const
 Checks if value is a 8-bit integer. More...
 
virtual bool isInt16 () const
 Checks if value is a 16-bit integer. More...
 
virtual bool isInt32 () const
 Checks if value is a 32-bit integer. More...
 
virtual bool isInt64 () const
 Checks if value is a 64-bit integer. More...
 
virtual bool isDouble () const final
 Checks if value is a floating point number. More...
 
virtual bool isFloat32 () const
 Checks if value is a 32-bit floating point number. More...
 
virtual bool isFloat64 () const
 Checks if value is a 64-bit floating point number. More...
 
virtual bool isString () const
 Checks if value is a string. More...
 
virtual bool isList () const
 Checks if value is a list. More...
 
virtual bool isDict () const
 Checks if value is a dictionary. More...
 
virtual bool isVocab () const
 Checks if value is a vocabulary identifier. More...
 
virtual bool isBlob () const
 Checks if value is a binary object. More...
 
virtual bool asBool () const
 Get boolean value. More...
 
virtual int asInt () const final
 Get integer value. More...
 
virtual std::int8_t asInt8 () const
 Get 8-bit integer value. More...
 
virtual std::int16_t asInt16 () const
 Get 16-bit integer value. More...
 
virtual std::int32_t asInt32 () const
 Get 32-bit integer value. More...
 
virtual std::int64_t asInt64 () const
 Get 64-bit integer value. More...
 
virtual double asDouble () const final
 Get floating point value. More...
 
virtual yarp::conf::float32_t asFloat32 () const
 Get 32-bit floating point value. More...
 
virtual yarp::conf::float64_t asFloat64 () const
 Get 64-bit floating point value. More...
 
virtual std::int32_t asVocab () const
 Get vocabulary identifier as an integer. More...
 
virtual std::string asString () const
 Get string value. More...
 
virtual BottleasList () const
 Get list value. More...
 
virtual PropertyasDict () const
 Get dictionary (hash table) value. More...
 
virtual SearchableasSearchable () const
 Get dictionary or list value. More...
 
virtual const char * asBlob () const
 Get binary data value. More...
 
virtual size_t asBlobLength () const
 Get binary data length. More...
 
bool read (ConnectionReader &connection) override
 Read this object from a network connection. More...
 
bool write (ConnectionWriter &connection) const override
 Write this object to a network connection. More...
 
bool check (const std::string &key) const override
 Check if there exists a property of the given name. More...
 
Valuefind (const std::string &key) const override
 Gets a value corresponding to a given keyword. More...
 
BottlefindGroup (const std::string &key) const override
 Gets a list corresponding to a given keyword. More...
 
bool operator== (const Value &alt) const
 Equality test. More...
 
bool operator!= (const Value &alt) const
 Inequality test. More...
 
void fromString (const char *str)
 Set value to correspond to a textual representation. More...
 
std::string toString () const override
 Return a standard text representation of the content of the object. More...
 
virtual Valuecreate () const
 Create a new value of the same type. More...
 
virtual Valueclone () const
 Create a copy of the value. More...
 
virtual std::int32_t getCode () const
 Get standard type code of value. More...
 
bool isNull () const override
 Checks if the object is invalid. More...
 
virtual bool isLeaf () const
 
virtual bool check (const std::string &key) const=0
 Check if there exists a property of the given name. More...
 
virtual bool check (const std::string &key, const std::string &comment) const
 Check if there exists a property of the given name. More...
 
virtual bool check (const std::string &key, Value *&result, const std::string &comment="") const
 Gets a value corresponding to a given keyword. More...
 
virtual Value check (const std::string &key, const Value &fallback, const std::string &comment="") const
 Gets a value corresponding to a given keyword. More...
 
virtual BottlefindGroup (const std::string &key) const=0
 Gets a list corresponding to a given keyword. More...
 
BottlefindGroup (const std::string &key, const std::string &comment) const
 Gets a list corresponding to a given keyword. More...
 
- Public Member Functions inherited from yarp::os::Portable
virtual Type getType () const
 
- Public Member Functions inherited from yarp::os::PortReader
virtual ~PortReader ()
 Destructor. More...
 
virtual Type getReadType () const
 
- Public Member Functions inherited from yarp::os::PortWriter
virtual ~PortWriter ()
 Destructor. More...
 
virtual void onCompletion () const
 This is called when the port has finished all writing operations. More...
 
virtual void onCommencement () const
 This is called when the port is about to begin writing operations. More...
 
virtual yarp::os::Type getWriteType () const
 
- Public Member Functions inherited from yarp::os::Searchable
 Searchable ()
 Default constructor. More...
 
 Searchable (const Searchable &rhs)=default
 Copy constructor. More...
 
 Searchable (Searchable &&rhs) noexcept=default
 Move constructor. More...
 
virtual ~Searchable ()
 Destructor. More...
 
Searchableoperator= (const Searchable &rhs)=default
 Copy assignment operator. More...
 
Searchableoperator= (Searchable &&rhs) noexcept=default
 Move assignment operator. More...
 
virtual bool check (const std::string &key, const std::string &comment) const
 Check if there exists a property of the given name. More...
 
BottlefindGroup (const std::string &key, const std::string &comment) const
 Gets a list corresponding to a given keyword. More...
 
virtual bool check (const std::string &key, Value *&result, const std::string &comment="") const
 Gets a value corresponding to a given keyword. More...
 
virtual Value check (const std::string &key, const Value &fallback, const std::string &comment="") const
 Gets a value corresponding to a given keyword. More...
 

Static Public Member Functions

static ValuemakeInt (int x)
 Create an integer Value. More...
 
static ValuemakeInt8 (std::int8_t x)
 Create a 8-bit integer Value. More...
 
static ValuemakeInt16 (std::int16_t x)
 Create a 16-bit integer Value. More...
 
static ValuemakeInt32 (std::int32_t x)
 Create a 32-bit integer Value. More...
 
static ValuemakeInt64 (std::int64_t x)
 Create a 64-bit integer Value. More...
 
static ValuemakeDouble (double x)
 Create a floating point Value. More...
 
static ValuemakeFloat32 (yarp::conf::float32_t x)
 Create a 32-bit floating point Value. More...
 
static ValuemakeFloat64 (yarp::conf::float64_t x)
 Create a 64-bit floating point Value. More...
 
static ValuemakeString (const std::string &str)
 Create a string Value. More...
 
static ValuemakeVocab (std::int32_t v)
 Create a vocabulary identifier Value. More...
 
static ValuemakeVocab (const std::string &str)
 Create a vocabulary identifier Value. More...
 
static ValuemakeBlob (void *data, int length)
 Create a Value containing binary data. More...
 
static ValuemakeList ()
 Create a list Value. More...
 
static ValuemakeList (const char *txt)
 Create a list Value and initialize it. More...
 
static ValuemakeValue (const std::string &txt)
 Create a Value from a text description. More...
 
static ValuegetNullValue ()
 Return an invalid, "null" Value. More...
 
- 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. More...
 

Detailed Description

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.

Examples
bottle/main.cpp, dev/motortest/motortest.cpp, framerate/main.cpp, os/browse_bottle/browse_bottle.cpp, os/database/database.cpp, os/image_process/image_process.cpp, and os/image_source/image_source.cpp.

Definition at line 46 of file Value.h.

Constructor & Destructor Documentation

◆ Value() [1/6]

Value::Value ( )
explicit

Construct a list Value.

Definition at line 21 of file Value.cpp.

◆ Value() [2/6]

Value::Value ( std::int32_t  x,
bool  isVocab = false 
)
explicit

Construct an integer Value.

Parameters
xthe integer
isVocabset this to true if the integer should be interpreted as a vocabulary identifier

Definition at line 28 of file Value.cpp.

◆ Value() [3/6]

Value::Value ( yarp::conf::float64_t  x)
explicit

Construct a floating point Value.

Parameters
xthe number

Definition at line 40 of file Value.cpp.

◆ Value() [4/6]

Value::Value ( const std::string &  str,
bool  isVocab = false 
)
explicit

Construct a string Value.

Parameters
strthe string
isVocabset this to true if the string should be interpreted as a vocabulary identifier

Definition at line 48 of file Value.cpp.

◆ Value() [5/6]

Value::Value ( void *  data,
int  length 
)

Construct a binary data Value.

Parameters
datathe data to copy
lengththe size of the data in bytes

Definition at line 60 of file Value.cpp.

◆ Value() [6/6]

Value::Value ( const Value alt)

Copy constructor.

Parameters
altthe value to copy

Definition at line 68 of file Value.cpp.

◆ ~Value()

Value::~Value ( )
virtual

Destructor.

Definition at line 109 of file Value.cpp.

Member Function Documentation

◆ asBlob()

const char * Value::asBlob ( ) const
virtual

Get binary data value.

Returns
pointer to binary data if value is indeed binary data. Otherwise returns nullptr

Reimplemented in yarp::os::impl::StoreBlob, and yarp::os::impl::Storable.

Definition at line 264 of file Value.cpp.

◆ asBlobLength()

size_t Value::asBlobLength ( ) const
virtual

Get binary data length.

Returns
length of binary data if value is indeed binary data. Otherwise returns 0

Reimplemented in yarp::os::impl::StoreBlob, and yarp::os::impl::Storable.

Definition at line 270 of file Value.cpp.

◆ asBool()

bool Value::asBool ( ) const
virtual

Get boolean value.

Returns
boolean value if value is indeed a boolean. If it is another type, the appropriate cast value is returned. Otherwise returns false.

Reimplemented in yarp::os::impl::StoreVocab, yarp::os::impl::StoreInt64, yarp::os::impl::StoreInt32, yarp::os::impl::StoreInt16, yarp::os::impl::StoreInt8, and yarp::os::impl::Storable.

Definition at line 189 of file Value.cpp.

◆ asDict()

Property * Value::asDict ( ) const
virtual

Get dictionary (hash table) value.

Returns
pointer to dictionary if value is indeed of the right type. Otherwise returns nullptr

Reimplemented in yarp::os::impl::StoreDict, and yarp::os::impl::Storable.

Definition at line 249 of file Value.cpp.

◆ asDouble()

virtual double yarp::os::Value::asDouble ( ) const
inlinefinalvirtual

Get floating point value.

Returns
floating point value if value is indeed a floating point. If it is another numeric type, the appropriate cast value is returned. Otherwise returns 0.
Warning
Unsafe, sizeof(double) is platform dependent. Use asFloat64 instead.

Definition at line 281 of file Value.h.

◆ asFloat32()

yarp::conf::float32_t Value::asFloat32 ( ) const
virtual

Get 32-bit floating point value.

Returns
floating point value if value is indeed a 32-bit floating point. If it is another numeric type, the appropriate cast value is returned. Otherwise returns 0.
Warning
This method performs casts if the Value is not a Float32 value, therefore it might lead to unexpected behaviours if the type is not properly checked.

Reimplemented in yarp::os::impl::StoreVocab, yarp::os::impl::StoreFloat64, yarp::os::impl::StoreFloat32, yarp::os::impl::StoreInt64, yarp::os::impl::StoreInt32, yarp::os::impl::StoreInt16, yarp::os::impl::StoreInt8, and yarp::os::impl::Storable.

Definition at line 219 of file Value.cpp.

◆ asFloat64()

yarp::conf::float64_t Value::asFloat64 ( ) const
virtual

Get 64-bit floating point value.

Returns
floating point value if value is indeed a 64-bit floating point. If it is another numeric type, the appropriate cast value is returned. Otherwise returns 0.
Warning
This method performs casts if the Value is not a Float32 value, therefore it might lead to unexpected behaviours if the type is not properly checked.

Reimplemented in yarp::os::impl::StoreVocab, yarp::os::impl::StoreFloat64, yarp::os::impl::StoreFloat32, yarp::os::impl::StoreInt64, yarp::os::impl::StoreInt32, yarp::os::impl::StoreInt16, yarp::os::impl::StoreInt8, and yarp::os::impl::Storable.

Definition at line 225 of file Value.cpp.

◆ asInt()

virtual int yarp::os::Value::asInt ( ) const
inlinefinalvirtual

Get integer value.

Returns
integer value if value is indeed an integer. If it is another numeric type, the appropriate cast value is returned. Otherwise returns 0.
Warning
Unsafe, sizeof(int) is platform dependent. Use asInt32 instead.

Definition at line 224 of file Value.h.

◆ asInt16()

std::int16_t Value::asInt16 ( ) const
virtual

Get 16-bit integer value.

Returns
16-bit integer value if value is indeed an integer. If it is another numeric type, the appropriate cast value is returned. Otherwise returns 0.
Warning
This method performs casts if the Value is not a Float32 value, therefore it might lead to unexpected behaviours if the type is not properly checked.

Reimplemented in yarp::os::impl::StoreFloat64, yarp::os::impl::StoreFloat32, yarp::os::impl::StoreInt64, yarp::os::impl::StoreInt32, yarp::os::impl::StoreInt16, yarp::os::impl::StoreInt8, and yarp::os::impl::Storable.

Definition at line 201 of file Value.cpp.

◆ asInt32()

std::int32_t Value::asInt32 ( ) const
virtual

Get 32-bit integer value.

Returns
32-bit integer value if value is indeed an integer. If it is another numeric type, the appropriate cast value is returned. Otherwise returns 0.
Warning
This method performs casts if the Value is not a Float32 value, therefore it might lead to unexpected behaviours if the type is not properly checked.

Reimplemented in yarp::os::impl::StoreVocab, yarp::os::impl::StoreFloat64, yarp::os::impl::StoreFloat32, yarp::os::impl::StoreInt64, yarp::os::impl::StoreInt32, yarp::os::impl::StoreInt16, yarp::os::impl::StoreInt8, and yarp::os::impl::Storable.

Examples
bottle/main.cpp, and property/main.cpp.

Definition at line 207 of file Value.cpp.

◆ asInt64()

std::int64_t Value::asInt64 ( ) const
virtual

Get 64-bit integer value.

Returns
64-bit integer value if value is indeed an integer. If it is another numeric type, the appropriate cast value is returned. Otherwise returns 0.
Warning
This method performs casts if the Value is not a Float32 value, therefore it might lead to unexpected behaviours if the type is not properly checked.

Reimplemented in yarp::os::impl::StoreVocab, yarp::os::impl::StoreFloat64, yarp::os::impl::StoreFloat32, yarp::os::impl::StoreInt64, yarp::os::impl::StoreInt32, yarp::os::impl::StoreInt16, yarp::os::impl::StoreInt8, and yarp::os::impl::Storable.

Definition at line 213 of file Value.cpp.

◆ asInt8()

std::int8_t Value::asInt8 ( ) const
virtual

Get 8-bit integer value.

Returns
8-bit integer value if value is indeed an integer. If it is another numeric type, the appropriate cast value is returned. Otherwise returns 0.
Warning
This method performs casts if the Value is not a Float32 value, therefore it might lead to unexpected behaviours if the type is not properly checked.

Reimplemented in yarp::os::impl::StoreFloat64, yarp::os::impl::StoreFloat32, yarp::os::impl::StoreInt64, yarp::os::impl::StoreInt32, yarp::os::impl::StoreInt16, yarp::os::impl::StoreInt8, and yarp::os::impl::Storable.

Definition at line 195 of file Value.cpp.

◆ asList()

Bottle * Value::asList ( ) const
virtual

Get list value.

Returns
pointer to list if value is indeed a list. Otherwise returns nullptr

Reimplemented in yarp::os::impl::StoreList, and yarp::os::impl::Storable.

Examples
bottle/main.cpp.

Definition at line 243 of file Value.cpp.

◆ asSearchable()

Searchable * Value::asSearchable ( ) const
virtual

Get dictionary or list value.

Returns
pointer to dictionary or list value if present. Otherwise returns nullptr

Reimplemented in yarp::os::impl::Storable.

Definition at line 255 of file Value.cpp.

◆ asString()

std::string Value::asString ( ) const
virtual

Get string value.

Returns
string value if value is indeed a string. Otherwise returns empty string.

Reimplemented in yarp::os::impl::StoreString, yarp::os::impl::StoreVocab, and yarp::os::impl::Storable.

Examples
bottle/main.cpp, framerate/main.cpp, and property/main.cpp.

Definition at line 237 of file Value.cpp.

◆ asVocab()

int Value::asVocab ( ) const
virtual

Get vocabulary identifier as an integer.

Returns
integer value of vocabulary identifier.

Reimplemented in yarp::os::impl::StoreString, yarp::os::impl::StoreVocab, yarp::os::impl::StoreInt64, yarp::os::impl::StoreInt32, yarp::os::impl::StoreInt16, yarp::os::impl::StoreInt8, and yarp::os::impl::Storable.

Definition at line 231 of file Value.cpp.

◆ check() [1/5]

bool Value::check ( const std::string &  key) const
overridevirtual

Check if there exists a property of the given name.

Parameters
keythe name to check for
Returns
true iff a property of the given name exists, even if it doesn't have a value associated with it

Implements yarp::os::Searchable.

Definition at line 324 of file Value.cpp.

◆ check() [2/5]

virtual bool yarp::os::Searchable::check

Check if there exists a property of the given name.

Parameters
keythe name to check for
Returns
true iff a property of the given name exists, even if it doesn't have a value associated with it

◆ check() [3/5]

bool yarp::os::Searchable::check

Check if there exists a property of the given name.

Parameters
keythe name to check for
commentHuman-readable explanation
Returns
true iff a property of the given name exists, even if it doesn't have a value associated with it

Definition at line 121 of file Searchable.cpp.

◆ check() [4/5]

yarp::os::Value yarp::os::Searchable::check

Gets a value corresponding to a given keyword.

Parameters
keyThe keyword to look for
fallbackA default value to return if nothing found
commentOptional human-readable explanation
Returns
A value corresponding to a given keyword, or the default if nothing is found. See the find() method for interpreting the value found.

Definition at line 198 of file Searchable.cpp.

◆ check() [5/5]

bool yarp::os::Searchable::check

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.

Property p;
p.fromString("(width 10) (height 15) (help)");
p.check("help") // this is true
p.check("width") // this is true
p.check("foo") // this is false
Value *v;
p.check("help", v) // this is false, there is no value associated
p.check("width", v) // this is true, and v->asInt32() is 10
Parameters
keyThe keyword to look for
resultA pointer to store the address of the result in
commentOptional human-readable explanation
Returns
True if there is a value corresponding to a given keyword, false otherwise. See the find() method for interpreting the value found.

Definition at line 184 of file Searchable.cpp.

◆ clone()

Value * Value::clone ( ) const
virtual

Create a copy of the value.

Returns
the new value, which will equal this.

Reimplemented in yarp::os::impl::Storable.

Definition at line 371 of file Value.cpp.

◆ create()

Value * Value::create ( ) const
virtual

Create a new value of the same type.

Returns
the new value.

Reimplemented in yarp::os::impl::Storable.

Definition at line 365 of file Value.cpp.

◆ find()

Value & Value::find ( const std::string &  key) const
overridevirtual

Gets a value corresponding to a given keyword.

Parameters
keyThe keyword to look for
Returns
A value corresponding to a given keyword. If there is no such value, then the isNull() method called on the result will be true. Otherwise, the value can be read by calling result.asInt32(), result.asString(), etc. as appropriate.

Implements yarp::os::Searchable.

Examples
bottle/main.cpp.

Definition at line 330 of file Value.cpp.

◆ findGroup() [1/3]

Bottle & Value::findGroup ( const std::string &  key) const
overridevirtual

Gets a list corresponding to a given keyword.

Parameters
keyThe keyword to look for
Returns
A list corresponding to a given keyword. If there is no such list, then the isNull() method called on the result will be true. Otherwise, the elements of the list can be read through result.get(index) where result.get(0) is the keyword, and result.get(i) for i>=1 are the "real" elements of the list.

Implements yarp::os::Searchable.

Definition at line 336 of file Value.cpp.

◆ findGroup() [2/3]

virtual Bottle& yarp::os::Searchable::findGroup

Gets a list corresponding to a given keyword.

Parameters
keyThe keyword to look for
Returns
A list corresponding to a given keyword. If there is no such list, then the isNull() method called on the result will be true. Otherwise, the elements of the list can be read through result.get(index) where result.get(0) is the keyword, and result.get(i) for i>=1 are the "real" elements of the list.

◆ findGroup() [3/3]

yarp::os::Bottle & yarp::os::Searchable::findGroup

Gets a list corresponding to a given keyword.

Parameters
keyThe keyword to look for
commentHuman-readable explanation
Returns
A list corresponding to a given keyword. If there is no such list, then the isNull() method called on the result will be true. Otherwise, the elements of the list can be read through result.get(index) where result.get(0) is the keyword, and result.get(i) for i>=1 are the "real" elements of the list.

Definition at line 157 of file Searchable.cpp.

◆ fromString()

void Value::fromString ( const char *  str)

Set value to correspond to a textual representation.

For example if str="10" then the value will be an integer, if str="(1 2 3)" the value will be a list.

Parameters
strthe textual representation.

Definition at line 354 of file Value.cpp.

◆ getCode()

◆ getNullValue()

Value & Value::getNullValue ( )
static

Return an invalid, "null" Value.

Returns
an invalid "null" Value

Definition at line 475 of file Value.cpp.

◆ isBlob()

bool Value::isBlob ( ) const
virtual

Checks if value is a binary object.

If so, asBlob() and asBlobLength() will return it.

Returns
true iff value is a binary object.

Reimplemented in yarp::os::impl::StoreBlob, and yarp::os::impl::Storable.

Definition at line 183 of file Value.cpp.

◆ isBool()

bool Value::isBool ( ) const
virtual

Checks if value is a boolean.

If so, asBool() will return that boolean.

Returns
true iff value is a boolean

Reimplemented in yarp::os::impl::StoreVocab, and yarp::os::impl::Storable.

Definition at line 117 of file Value.cpp.

◆ isDict()

bool Value::isDict ( ) const
virtual

Checks if value is a dictionary.

If so, asDict() will return that dictionary.

Returns
true iff value is a dictionary

Reimplemented in yarp::os::impl::StoreDict, and yarp::os::impl::Storable.

Definition at line 171 of file Value.cpp.

◆ isDouble()

virtual bool yarp::os::Value::isDouble ( ) const
inlinefinalvirtual

Checks if value is a floating point number.

If so, asDouble() will return that number.

Returns
true iff value is a floating point number
Warning
Unsafe, sizeof(double) is platform dependent. Use isFloat64 instead.

Definition at line 156 of file Value.h.

◆ isFloat32()

bool Value::isFloat32 ( ) const
virtual

Checks if value is a 32-bit floating point number.

If so, asFloat32() will return that number.

Returns
true iff value is a 32-bit floating point number

Reimplemented in yarp::os::impl::StoreFloat32, and yarp::os::impl::Storable.

Definition at line 147 of file Value.cpp.

◆ isFloat64()

bool Value::isFloat64 ( ) const
virtual

Checks if value is a 64-bit floating point number.

If so, asFloat64() will return that number.

Returns
true iff value is a 64-bit floating point number

Reimplemented in yarp::os::impl::StoreFloat64, and yarp::os::impl::Storable.

Definition at line 153 of file Value.cpp.

◆ isInt()

virtual bool yarp::os::Value::isInt ( ) const
inlinefinalvirtual

Checks if value is an integer.

If so, asInt() will return that integer.

Returns
true iff value is an integer
Warning
Unsafe, sizeof(int) is platform dependent. Use isInt32 instead.

Definition at line 116 of file Value.h.

◆ isInt16()

bool Value::isInt16 ( ) const
virtual

Checks if value is a 16-bit integer.

If so, asInt16() will return that integer.

Returns
true iff value is a 16-bit integer

Reimplemented in yarp::os::impl::StoreInt16, and yarp::os::impl::Storable.

Definition at line 129 of file Value.cpp.

◆ isInt32()

bool Value::isInt32 ( ) const
virtual

Checks if value is a 32-bit integer.

If so, asInt32() will return that integer.

Returns
true iff value is a 32-bit integer

Reimplemented in yarp::os::impl::StoreInt32, and yarp::os::impl::Storable.

Definition at line 135 of file Value.cpp.

◆ isInt64()

bool Value::isInt64 ( ) const
virtual

Checks if value is a 64-bit integer.

If so, asInt64() will return that integer.

Returns
true iff value is a 64-bit integer

Reimplemented in yarp::os::impl::StoreInt64, and yarp::os::impl::Storable.

Definition at line 141 of file Value.cpp.

◆ isInt8()

bool Value::isInt8 ( ) const
virtual

Checks if value is a 8-bit integer.

If so, asInt8() will return that integer.

Returns
true iff value is a 8-bit integer

Reimplemented in yarp::os::impl::StoreInt8, and yarp::os::impl::Storable.

Definition at line 123 of file Value.cpp.

◆ isLeaf()

bool Value::isLeaf ( ) const
virtual

Reimplemented in yarp::os::impl::Storable.

Definition at line 389 of file Value.cpp.

◆ isList()

bool Value::isList ( ) const
virtual

Checks if value is a list.

If so, asList() will return that list.

Returns
true iff value is a list

Reimplemented in yarp::os::impl::StoreList, and yarp::os::impl::Storable.

Definition at line 165 of file Value.cpp.

◆ isNull()

bool Value::isNull ( ) const
overridevirtual

Checks if the object is invalid.

Returns
True if the object is invalid or "null".

Reimplemented from yarp::os::Searchable.

Definition at line 383 of file Value.cpp.

◆ isString()

bool Value::isString ( ) const
virtual

Checks if value is a string.

If so, asString() will return that string.

Returns
true iff value is a string

Reimplemented in yarp::os::impl::StoreString, and yarp::os::impl::Storable.

Definition at line 159 of file Value.cpp.

◆ isVocab()

bool Value::isVocab ( ) const
virtual

Checks if value is a vocabulary identifier.

If so, asVocab() will return it.

Returns
true iff value is a vocabulary identifier

Reimplemented in yarp::os::impl::StoreVocab, and yarp::os::impl::Storable.

Definition at line 177 of file Value.cpp.

◆ makeBlob()

Value * Value::makeBlob ( void *  data,
int  length 
)
static

Create a Value containing binary data.

Parameters
datathe data (will be copied)
lengththe size of the data in bytes
Returns
a Value containing binary data

Definition at line 442 of file Value.cpp.

◆ makeDouble()

static Value* yarp::os::Value::makeDouble ( double  x)
inlinestatic

Create a floating point Value.

Parameters
xthe value to take on
Returns
a floating point Value
Warning
Unsafe, sizeof(double) is platform dependent. Use makeFloat64 instead.

Definition at line 464 of file Value.h.

◆ makeFloat32()

Value * Value::makeFloat32 ( yarp::conf::float32_t  x)
static

Create a 32-bit floating point Value.

Parameters
xthe value to take on
Returns
a 32-bit floating point Value

Definition at line 414 of file Value.cpp.

◆ makeFloat64()

Value * Value::makeFloat64 ( yarp::conf::float64_t  x)
static

Create a 64-bit floating point Value.

Parameters
xthe value to take on
Returns
a 64-bit floating point Value

Definition at line 419 of file Value.cpp.

◆ makeInt()

static Value* yarp::os::Value::makeInt ( int  x)
inlinestatic

Create an integer Value.

Parameters
xthe value to take on
Returns
an integer Value
Warning
Unsafe, sizeof(int) is platform dependent. Use makeInt instead.

Definition at line 424 of file Value.h.

◆ makeInt16()

Value * Value::makeInt16 ( std::int16_t  x)
static

Create a 16-bit integer Value.

Parameters
xthe value to take on
Returns
a 16-bit integer Value

Definition at line 399 of file Value.cpp.

◆ makeInt32()

Value * Value::makeInt32 ( std::int32_t  x)
static

Create a 32-bit integer Value.

Parameters
xthe value to take on
Returns
a 32-bit integer Value

Definition at line 404 of file Value.cpp.

◆ makeInt64()

Value * Value::makeInt64 ( std::int64_t  x)
static

Create a 64-bit integer Value.

Parameters
xthe value to take on
Returns
a 64-bit integer Value

Definition at line 409 of file Value.cpp.

◆ makeInt8()

Value * Value::makeInt8 ( std::int8_t  x)
static

Create a 8-bit integer Value.

Parameters
xthe value to take on
Returns
a 8-bit integer Value

Definition at line 394 of file Value.cpp.

◆ makeList() [1/2]

Value * Value::makeList ( )
static

Create a list Value.

Returns
a list Value
Examples
bottle/main.cpp.

Definition at line 449 of file Value.cpp.

◆ makeList() [2/2]

Value * Value::makeList ( const char *  txt)
static

Create a list Value and initialize it.

Parameters
txtthe list in text form, e.g. "1 2.0 (4 5) xyz"
Returns
a list Value

Definition at line 455 of file Value.cpp.

◆ makeString()

Value * Value::makeString ( const std::string &  str)
static

Create a string Value.

Parameters
strthe value to take on
Returns
a string Value

Definition at line 424 of file Value.cpp.

◆ makeValue()

Value * Value::makeValue ( const std::string &  txt)
static

Create a Value from a text description.

Parameters
txtthe description. E.g. "10" will create an integer, "(5 6 7)" will create a list.
Returns
the Value to which the text description corresponds

Definition at line 465 of file Value.cpp.

◆ makeVocab() [1/2]

Value * Value::makeVocab ( const std::string &  str)
static

Create a vocabulary identifier Value.

Parameters
strthe value to take on
Returns
a vocabulary identifier Value

Definition at line 436 of file Value.cpp.

◆ makeVocab() [2/2]

static Value* yarp::os::Value::makeVocab ( std::int32_t  v)
static

Create a vocabulary identifier Value.

Parameters
vthe value to take on
Returns
a vocabulary identifier Value

◆ operator!=()

bool Value::operator!= ( const Value alt) const

Inequality test.

Parameters
altthe value to compare against
Returns
true iff the values are not equal

Definition at line 349 of file Value.cpp.

◆ operator=()

const Value & Value::operator= ( const Value alt)

Assignment operator.

Parameters
altthe value to copy
Returns
this object itself

Definition at line 77 of file Value.cpp.

◆ operator==()

bool Value::operator== ( const Value alt) const

Equality test.

Parameters
altthe value to compare against
Returns
true iff the values are equal

Definition at line 342 of file Value.cpp.

◆ read()

bool Value::read ( ConnectionReader reader)
overridevirtual

Read this object from a network connection.

Override this for your particular class.

Parameters
readeran interface to the network connection for reading
Returns
true iff the object is successfully read

Implements yarp::os::Portable.

Definition at line 276 of file Value.cpp.

◆ toString()

std::string Value::toString ( ) const
overridevirtual

Return a standard text representation of the content of the object.

The representation is readable by the Bottle and Property classes.

Returns
A standard text representation of the content of the object.

Implements yarp::os::Searchable.

Examples
bottle/main.cpp.

Definition at line 359 of file Value.cpp.

◆ write()

bool Value::write ( ConnectionWriter writer) const
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

Parameters
writeran interface to the network connection for writing
Returns
true iff the object is successfully written

Implements yarp::os::Portable.

Definition at line 312 of file Value.cpp.


The documentation for this class was generated from the following files:
yarp::os::Value::Value
Value()
Construct a list Value.
Definition: Value.cpp:21