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 isVocab32=false)
 Construct an integer Value. More...
 
 Value (yarp::conf::float64_t x)
 Construct a floating point Value. More...
 
 Value (const std::string &str, bool isVocab32=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...
 
 ~Value () override
 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 isVocab32 () const
 Checks if value is a vocabulary identifier. 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 yarp::conf::vocab32_t asVocab32 () const
 Get vocabulary identifier as an integer. More...
 
virtual yarp::conf::vocab32_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 ValuemakeVocab32 (yarp::conf::vocab32_t v)
 Create a vocabulary identifier Value. More...
 
static ValuemakeVocab32 (char a, char b=0, char c=0, char d=0)
 Create a vocabulary identifier Value. More...
 
static ValuemakeVocab32 (const std::string &str)
 Create a vocabulary identifier Value If the string is longer than 4 characters, only the first 4 are used. More...
 
static ValuemakeVocab (yarp::conf::vocab32_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
dev/motortest/motortest.cpp, os/browse_bottle/browse_bottle.cpp, and os/database/database.cpp.

Definition at line 44 of file Value.h.

Constructor & Destructor Documentation

◆ Value() [1/6]

Value::Value ( )
explicit

Construct a list Value.

Definition at line 18 of file Value.cpp.

◆ Value() [2/6]

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

Construct an integer Value.

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

Definition at line 25 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 37 of file Value.cpp.

◆ Value() [4/6]

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

Construct a string Value.

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

Definition at line 45 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 57 of file Value.cpp.

◆ Value() [6/6]

Value::Value ( const Value alt)

Copy constructor.

Parameters
altthe value to copy

Definition at line 65 of file Value.cpp.

◆ ~Value()

Value::~Value ( )
override

Destructor.

Definition at line 106 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 261 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 267 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::StoreVocab32, yarp::os::impl::StoreInt64, yarp::os::impl::StoreInt32, yarp::os::impl::StoreInt16, yarp::os::impl::StoreInt8, and yarp::os::impl::Storable.

Definition at line 186 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 246 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.
Deprecated:
Since YARP 3.5. Use asFloat64 instead.

Definition at line 298 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::StoreVocab32, 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 216 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::StoreVocab32, 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 222 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.
Deprecated:
Since YARP 3.5. Use asInt32 instead.

Definition at line 238 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 198 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::StoreVocab32, 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 204 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::StoreVocab32, 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 210 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 192 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.

Definition at line 240 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 252 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::StoreVocab32, and yarp::os::impl::Storable.

Definition at line 234 of file Value.cpp.

◆ asVocab()

virtual yarp::conf::vocab32_t yarp::os::Value::asVocab ( ) const
inlinevirtual

Get vocabulary identifier as an integer.

Returns
integer value of vocabulary identifier.
Deprecated:
Since YARP 3.5. Use asVocab32 instead.

Definition at line 339 of file Value.h.

◆ asVocab32()

yarp::conf::vocab32_t Value::asVocab32 ( ) const
virtual

Get vocabulary identifier as an integer.

Returns
integer value of vocabulary identifier.

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

Definition at line 228 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 321 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 118 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 195 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
Value()
Construct a list Value.
Definition: Value.cpp:18
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 181 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 368 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 362 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.

Definition at line 327 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 333 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 154 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 351 of file Value.cpp.

◆ getCode()

◆ getNullValue()

Value & Value::getNullValue ( )
static

Return an invalid, "null" Value.

Returns
an invalid "null" Value

Definition at line 466 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 180 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::StoreVocab32, and yarp::os::impl::Storable.

Definition at line 114 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 168 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 154 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 144 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 150 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 114 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 126 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 132 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 138 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 120 of file Value.cpp.

◆ isLeaf()

bool Value::isLeaf ( ) const
virtual

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

Definition at line 386 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 162 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 380 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 156 of file Value.cpp.

◆ isVocab()

virtual bool yarp::os::Value::isVocab ( ) const
inlinevirtual

Checks if value is a vocabulary identifier.

If so, asVocab() will return it.

Returns
true iff value is a vocabulary identifier
Deprecated:
since YARP 3.5. Use isVocab32 instead.

Definition at line 207 of file Value.h.

◆ isVocab32()

bool Value::isVocab32 ( ) const
virtual

Checks if value is a vocabulary identifier.

If so, asVocab32() will return it.

Returns
true iff value is a vocabulary identifier

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

Definition at line 174 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 433 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.
Deprecated:
Since YARP 3.5. Use makeFloat64 instead.

Definition at line 500 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 411 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 416 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.
Deprecated:
Since YARP 3.5. Use makeInt32 instead.

Definition at line 457 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 396 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 401 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 406 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 391 of file Value.cpp.

◆ makeList() [1/2]

Value * Value::makeList ( )
static

Create a list Value.

Returns
a list Value

Definition at line 440 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 446 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 421 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 456 of file Value.cpp.

◆ makeVocab() [1/2]

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

Create a vocabulary identifier Value.

Parameters
strthe value to take on
Returns
a vocabulary identifier Value
Deprecated:
Since YARP 3.5. Use makeVocab32 instead.

Definition at line 578 of file Value.h.

◆ makeVocab() [2/2]

static Value* yarp::os::Value::makeVocab ( yarp::conf::vocab32_t  v)
inlinestatic

Create a vocabulary identifier Value.

Parameters
vthe value to take on
Returns
a vocabulary identifier Value
Deprecated:
Since YARP 3.5. Use makeVocab32 instead.

Definition at line 566 of file Value.h.

◆ makeVocab32() [1/3]

static Value* yarp::os::Value::makeVocab32 ( char  a,
char  b = 0,
char  c = 0,
char  d = 0 
)
inlinestatic

Create a vocabulary identifier Value.

Parameters
afirst character of the vocab
bsecond character of the vocab
cthird character of the vocab
dfourth character of the vocab
Returns
a vocabulary identifier Value

Definition at line 542 of file Value.h.

◆ makeVocab32() [2/3]

static Value* yarp::os::Value::makeVocab32 ( const std::string &  str)
inlinestatic

Create a vocabulary identifier Value If the string is longer than 4 characters, only the first 4 are used.

Parameters
strthe value to take on
Returns
a vocabulary identifier Value

Definition at line 553 of file Value.h.

◆ makeVocab32() [3/3]

Value * Value::makeVocab32 ( yarp::conf::vocab32_t  v)
static

Create a vocabulary identifier Value.

Parameters
vthe value to take on
Returns
a vocabulary identifier Value

Definition at line 427 of file Value.cpp.

◆ 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 346 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 74 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 339 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 273 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.

Definition at line 356 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 309 of file Value.cpp.


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