YARP  2.3.68+225-20170329.5+gitb0d3289
Yet Another Robot Platform
yarp::os::impl::Storable Class Referenceabstract

A single item in a Bottle. More...

#include <yarp/os/impl/BottleImpl.h>

+ Inheritance diagram for yarp::os::impl::Storable:

Public Member Functions

virtual bool isBool () const
 Checks if value is a boolean. More...
 
virtual bool isInt () const
 Checks if value is an integer (32 bit or smaller). More...
 
virtual bool isInt64 () const
 Checks if value is a 64-bit integer or smaller. More...
 
virtual bool isString () const
 Checks if value is a string. More...
 
virtual bool isDouble () const
 Checks if value is a floating point number. 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 isNull () const
 Checks if the object is invalid. More...
 
virtual bool asBool () const
 Get boolean value. More...
 
virtual int asInt () const
 Get integer value. More...
 
virtual YARP_INT64 asInt64 () const
 Get 64-bit integer value. More...
 
virtual int asVocab () const
 Get vocabulary identifier as an integer. More...
 
virtual double asDouble () const
 Get floating point value. More...
 
virtual yarp::os::ConstString asString () const
 Get string value. More...
 
virtual SearchableasSearchable () const
 Get dictionary or list value. More...
 
virtual yarp::os::BottleasList () const
 Get list value. More...
 
virtual yarp::os::PropertyasDict () const
 Get dictionary (hash table) value. More...
 
virtual const char * asBlob () const
 Get binary data value. More...
 
virtual size_t asBlobLength () const
 Get binary data length. More...
 
virtual bool read (ConnectionReader &connection)
 Read this object from a network connection. More...
 
virtual bool write (ConnectionWriter &connection)
 Write this object to a network connection. More...
 
virtual bool readRaw (ConnectionReader &connection)=0
 
virtual bool writeRaw (ConnectionWriter &connection)=0
 
virtual bool check (const yarp::os::ConstString &key) const
 Check if there exists a property of the given name. More...
 
virtual yarp::os::Valuefind (const yarp::os::ConstString &key) const
 Gets a value corresponding to a given keyword. More...
 
virtual yarp::os::BottlefindGroup (const yarp::os::ConstString &key) const
 Gets a list corresponding to a given keyword. More...
 
bool operator== (const yarp::os::Value &alt) const
 
virtual yarp::os::Valuecreate () const
 Create a new value of the same type. More...
 
virtual yarp::os::Valueclone () const
 Create a copy of the value. More...
 
virtual ~Storable ()
 Destructor. More...
 
virtual void fromString (const ConstString &src)=0
 Initialize from a string representation, assuming that any syntax around this representation such as braces or parentheses has already been consumed. More...
 
virtual void fromStringNested (const ConstString &src)
 Initialize from a string representation. More...
 
virtual yarp::os::ConstString toString () const =0
 Return a standard text representation of the content of the object. More...
 
virtual ConstString toStringNested () const
 Create string representation, including any syntax that should wrap it such as braces or parentheses. More...
 
virtual StorablecreateStorable () const =0
 Factory method. More...
 
virtual StorablecloneStorable () const
 Typed synonym for clone() More...
 
virtual void copy (const Storable &alt)=0
 Become a copy of the passed item. More...
 
virtual int subCode () const
 Return a code describing this item, used in serializing bottles. More...
 
virtual bool isLeaf () const
 
- Public Member Functions inherited from yarp::os::Value
 Value ()
 Construct a list Value. More...
 
 Value (int x, bool isVocab=false)
 Construct an integer Value. More...
 
 Value (double x)
 Construct a floating point Value. More...
 
 Value (const ConstString &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...
 
bool operator== (const Value &alt) const
 Equality test. More...
 
bool operator!= (const Value &alt) const
 Inequality test. More...
 
bool operator== (const char *alt) const
 
bool operator!= (const char *alt) const
 
void fromString (const char *str)
 Set value to correspond to a textual representation. More...
 
ConstString toString () const
 Return a standard text representation of the content of the object. More...
 
virtual int getCode () const
 Get standard type code of value. More...
 
- Public Member Functions inherited from yarp::os::Portable
virtual Type getType ()
 
- Public Member Functions inherited from yarp::os::PortReader
virtual ~PortReader ()
 Destructor. More...
 
virtual Type getReadType ()
 
- Public Member Functions inherited from yarp::os::PortWriter
virtual ~PortWriter ()
 Destructor. More...
 
virtual void onCompletion ()
 This is called when the port has finished all writing operations. More...
 
virtual void onCommencement ()
 This is called when the port is about to begin writing operations. More...
 
virtual Type getWriteType ()
 
- Public Member Functions inherited from yarp::os::Searchable
 Searchable ()
 Default constructor. More...
 
virtual ~Searchable ()
 Destructor. More...
 
virtual bool check (const ConstString &key, const ConstString &comment) const
 Check if there exists a property of the given name. More...
 
BottlefindGroup (const ConstString &key, const ConstString &comment) const
 Gets a list corresponding to a given keyword. More...
 
virtual bool check (const ConstString &key, Value *&result, const ConstString &comment="") const
 Gets a value corresponding to a given keyword. More...
 
virtual Value check (const ConstString &key, const Value &fallback, const ConstString &comment="") const
 Gets a value corresponding to a given keyword. More...
 

Static Public Member Functions

static StorablecreateByCode (int id)
 
- Static Public Member Functions inherited from yarp::os::Value
static ValuemakeInt (int x)
 Create an integer Value. More...
 
static ValuemakeDouble (double x)
 Create a floating point Value. More...
 
static ValuemakeString (const ConstString &str)
 Create a string Value. More...
 
static ValuemakeVocab (int v)
 Create a vocabulary identifier Value. More...
 
static ValuemakeVocab (const ConstString &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 ConstString &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 (PortWriter &writer, PortReader &reader)
 Copy one portable to another, via writing and reading. More...
 

Detailed Description

A single item in a Bottle.

This extends the public yarp::os::Value interface with some implementation-specific details.

Definition at line 46 of file BottleImpl.h.

Constructor & Destructor Documentation

◆ ~Storable()

Storable::~Storable ( )
virtual

Destructor.

Definition at line 352 of file BottleImpl.cpp.

Member Function Documentation

◆ asBlob()

virtual const char* yarp::os::impl::Storable::asBlob ( ) const
inlinevirtual

Get binary data value.

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

Reimplemented from yarp::os::Value.

Reimplemented in yarp::os::impl::StoreBlob.

Definition at line 74 of file BottleImpl.h.

◆ asBlobLength()

virtual size_t yarp::os::impl::Storable::asBlobLength ( ) const
inlinevirtual

Get binary data length.

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

Reimplemented from yarp::os::Value.

Reimplemented in yarp::os::impl::StoreBlob.

Definition at line 78 of file BottleImpl.h.

◆ asBool()

virtual bool yarp::os::impl::Storable::asBool ( ) const
inlinevirtual

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 from yarp::os::Value.

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

Definition at line 59 of file BottleImpl.h.

◆ asDict()

virtual yarp::os::Property* yarp::os::impl::Storable::asDict ( ) const
inlinevirtual

Get dictionary (hash table) value.

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

Reimplemented from yarp::os::Value.

Reimplemented in yarp::os::impl::StoreDict.

Definition at line 73 of file BottleImpl.h.

◆ asDouble()

virtual double yarp::os::impl::Storable::asDouble ( ) const
inlinevirtual

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.

Reimplemented from yarp::os::Value.

Reimplemented in yarp::os::impl::StoreDouble, yarp::os::impl::StoreVocab, yarp::os::impl::StoreInt64, and yarp::os::impl::StoreInt.

Definition at line 63 of file BottleImpl.h.

◆ asInt()

virtual int yarp::os::impl::Storable::asInt ( ) const
inlinevirtual

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.

Reimplemented from yarp::os::Value.

Reimplemented in yarp::os::impl::StoreDouble, yarp::os::impl::StoreVocab, yarp::os::impl::StoreInt64, and yarp::os::impl::StoreInt.

Definition at line 60 of file BottleImpl.h.

◆ asInt64()

virtual YARP_INT64 yarp::os::impl::Storable::asInt64 ( ) const
inlinevirtual

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.

Reimplemented from yarp::os::Value.

Reimplemented in yarp::os::impl::StoreDouble, yarp::os::impl::StoreVocab, yarp::os::impl::StoreInt64, and yarp::os::impl::StoreInt.

Definition at line 61 of file BottleImpl.h.

◆ asList()

virtual yarp::os::Bottle* yarp::os::impl::Storable::asList ( ) const
inlinevirtual

Get list value.

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

Reimplemented from yarp::os::Value.

Reimplemented in yarp::os::impl::StoreList.

Definition at line 72 of file BottleImpl.h.

◆ asSearchable()

virtual Searchable* yarp::os::impl::Storable::asSearchable ( ) const
inlinevirtual

Get dictionary or list value.

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

Reimplemented from yarp::os::Value.

Definition at line 65 of file BottleImpl.h.

◆ asString()

virtual yarp::os::ConstString yarp::os::impl::Storable::asString ( ) const
inlinevirtual

Get string value.

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

Reimplemented from yarp::os::Value.

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

Definition at line 64 of file BottleImpl.h.

◆ asVocab()

virtual int yarp::os::impl::Storable::asVocab ( ) const
inlinevirtual

Get vocabulary identifier as an integer.

Returns
integer value of vocabulary identifier.

Reimplemented from yarp::os::Value.

Reimplemented in yarp::os::impl::StoreString, yarp::os::impl::StoreVocab, yarp::os::impl::StoreInt64, and yarp::os::impl::StoreInt.

Definition at line 62 of file BottleImpl.h.

◆ check()

bool Storable::check ( const yarp::os::ConstString key) const
virtual

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

Reimplemented from yarp::os::Value.

Definition at line 1339 of file BottleImpl.cpp.

◆ clone()

virtual yarp::os::Value* yarp::os::impl::Storable::clone ( ) const
inlinevirtual

Create a copy of the value.

Returns
the new value, which will equal this.

Reimplemented from yarp::os::Value.

Definition at line 94 of file BottleImpl.h.

◆ cloneStorable()

virtual Storable* yarp::os::impl::Storable::cloneStorable ( ) const
inlinevirtual

Typed synonym for clone()

Definition at line 127 of file BottleImpl.h.

◆ copy()

◆ create()

virtual yarp::os::Value* yarp::os::impl::Storable::create ( ) const
inlinevirtual

Create a new value of the same type.

Returns
the new value.

Reimplemented from yarp::os::Value.

Definition at line 93 of file BottleImpl.h.

◆ createByCode()

Storable * Storable::createByCode ( int  id)
static

Definition at line 356 of file BottleImpl.cpp.

◆ createStorable()

◆ find()

Value & Storable::find ( const yarp::os::ConstString key) const
virtual

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.asInt(), result.asString(), etc. as appropriate.

Reimplemented from yarp::os::Value.

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

Definition at line 1327 of file BottleImpl.cpp.

◆ findGroup()

Bottle & Storable::findGroup ( const yarp::os::ConstString key) const
virtual

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.

Reimplemented from yarp::os::Value.

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

Definition at line 1333 of file BottleImpl.cpp.

◆ fromString()

virtual void yarp::os::impl::Storable::fromString ( const ConstString src)
pure virtual

Initialize from a string representation, assuming that any syntax around this representation such as braces or parentheses has already been consumed.

Implemented in yarp::os::impl::StoreDict, yarp::os::impl::StoreList, yarp::os::impl::StoreDouble, yarp::os::impl::StoreBlob, yarp::os::impl::StoreString, yarp::os::impl::StoreVocab, yarp::os::impl::StoreInt64, yarp::os::impl::StoreInt, and yarp::os::impl::StoreNull.

◆ fromStringNested()

virtual void yarp::os::impl::Storable::fromStringNested ( const ConstString src)
inlinevirtual

Initialize from a string representation.

This should consume any syntax around that representation such as braces or parentheses.

Reimplemented in yarp::os::impl::StoreDict, yarp::os::impl::StoreList, yarp::os::impl::StoreBlob, yarp::os::impl::StoreString, and yarp::os::impl::StoreVocab.

Definition at line 112 of file BottleImpl.h.

◆ isBlob()

virtual bool yarp::os::impl::Storable::isBlob ( ) const
inlinevirtual

Checks if value is a binary object.

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

Returns
true iff value is a binary object.

Reimplemented from yarp::os::Value.

Reimplemented in yarp::os::impl::StoreBlob.

Definition at line 57 of file BottleImpl.h.

◆ isBool()

virtual bool yarp::os::impl::Storable::isBool ( ) const
inlinevirtual

Checks if value is a boolean.

If so, asBool() will return that boolean.

Returns
true iff value is a boolean

Reimplemented from yarp::os::Value.

Reimplemented in yarp::os::impl::StoreVocab.

Definition at line 49 of file BottleImpl.h.

◆ isDict()

virtual bool yarp::os::impl::Storable::isDict ( ) const
inlinevirtual

Checks if value is a dictionary.

If so, asDict() will return that dictionary.

Returns
true iff value is a dictionary

Reimplemented from yarp::os::Value.

Reimplemented in yarp::os::impl::StoreDict.

Definition at line 55 of file BottleImpl.h.

◆ isDouble()

virtual bool yarp::os::impl::Storable::isDouble ( ) const
inlinevirtual

Checks if value is a floating point number.

If so, asDouble() will return that number.

Returns
true iff value is a floating point number

Reimplemented from yarp::os::Value.

Reimplemented in yarp::os::impl::StoreDouble.

Definition at line 53 of file BottleImpl.h.

◆ isInt()

virtual bool yarp::os::impl::Storable::isInt ( ) const
inlinevirtual

Checks if value is an integer (32 bit or smaller).

If so, asInt() will return that integer.

Returns
true iff value is an integer

Reimplemented from yarp::os::Value.

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

Definition at line 50 of file BottleImpl.h.

◆ isInt64()

virtual bool yarp::os::impl::Storable::isInt64 ( ) const
inlinevirtual

Checks if value is a 64-bit integer or smaller.

If so, asInt64() will return that integer.

Returns
true iff value is a 64-bit integer or smaller

Reimplemented from yarp::os::Value.

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

Definition at line 51 of file BottleImpl.h.

◆ isLeaf()

virtual bool yarp::os::impl::Storable::isLeaf ( ) const
inlinevirtual

Reimplemented from yarp::os::Value.

Definition at line 144 of file BottleImpl.h.

◆ isList()

virtual bool yarp::os::impl::Storable::isList ( ) const
inlinevirtual

Checks if value is a list.

If so, asList() will return that list.

Returns
true iff value is a list

Reimplemented from yarp::os::Value.

Reimplemented in yarp::os::impl::StoreList.

Definition at line 54 of file BottleImpl.h.

◆ isNull()

virtual bool yarp::os::impl::Storable::isNull ( ) const
inlinevirtual

Checks if the object is invalid.

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

Reimplemented from yarp::os::Value.

Reimplemented in yarp::os::impl::StoreNull.

Definition at line 58 of file BottleImpl.h.

◆ isString()

virtual bool yarp::os::impl::Storable::isString ( ) const
inlinevirtual

Checks if value is a string.

If so, asString() will return that string.

Returns
true iff value is a string

Reimplemented from yarp::os::Value.

Reimplemented in yarp::os::impl::StoreString.

Definition at line 52 of file BottleImpl.h.

◆ isVocab()

virtual bool yarp::os::impl::Storable::isVocab ( ) const
inlinevirtual

Checks if value is a vocabulary identifier.

If so, asVocab() will return it.

Returns
true iff value is a vocabulary identifier

Reimplemented from yarp::os::Value.

Reimplemented in yarp::os::impl::StoreVocab.

Definition at line 56 of file BottleImpl.h.

◆ operator==()

bool Storable::operator== ( const yarp::os::Value alt) const

Definition at line 1349 of file BottleImpl.cpp.

◆ read()

bool Storable::read ( ConnectionReader reader)
virtual

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

Reimplemented from yarp::os::Value.

Definition at line 1355 of file BottleImpl.cpp.

◆ readRaw()

◆ subCode()

virtual int yarp::os::impl::Storable::subCode ( ) const
inlinevirtual

Return a code describing this item, used in serializing bottles.

Reimplemented in yarp::os::impl::StoreList.

Definition at line 143 of file BottleImpl.h.

◆ toString()

virtual yarp::os::ConstString yarp::os::impl::Storable::toString ( ) const
pure virtual

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.

Implemented in yarp::os::impl::StoreDict, yarp::os::impl::StoreList, yarp::os::impl::StoreDouble, yarp::os::impl::StoreBlob, yarp::os::impl::StoreString, yarp::os::impl::StoreVocab, yarp::os::impl::StoreInt64, yarp::os::impl::StoreInt, and yarp::os::impl::StoreNull.

◆ toStringNested()

virtual ConstString yarp::os::impl::Storable::toStringNested ( ) const
inlinevirtual

Create string representation, including any syntax that should wrap it such as braces or parentheses.

Reimplemented in yarp::os::impl::StoreDict, yarp::os::impl::StoreList, yarp::os::impl::StoreBlob, yarp::os::impl::StoreString, and yarp::os::impl::StoreVocab.

Definition at line 118 of file BottleImpl.h.

◆ write()

bool Storable::write ( ConnectionWriter writer)
virtual

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

Reimplemented from yarp::os::Value.

Definition at line 1364 of file BottleImpl.cpp.

◆ writeRaw()


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