7 #ifndef YARP_OS_VALUE_H
8 #define YARP_OS_VALUE_H
23 #ifndef DOXYGEN_SHOULD_SKIP_THIS
61 explicit Value(std::int32_t x,
bool isVocab32 =
false);
75 explicit Value(
const std::string& str,
bool isVocab32 =
false);
82 Value(
void* data,
int length);
106 virtual bool isBool()
const;
114 inline virtual
bool isInt() const final
124 virtual bool isInt8()
const;
131 virtual bool isInt16()
const;
138 virtual bool isInt32()
const;
145 virtual bool isInt64()
const;
154 inline virtual
bool isDouble() const final
164 virtual bool isFloat32()
const;
171 virtual bool isFloat64()
const;
177 virtual bool isString()
const;
183 virtual bool isList()
const;
190 virtual bool isDict()
const;
197 virtual bool isVocab32()
const;
199 #ifndef YARP_NO_DEPRECATED
206 YARP_DEPRECATED_MSG("Use isVocab32 instead")
218 virtual bool isBlob()
const;
226 virtual bool asBool()
const;
228 #ifndef YARP_NO_DEPRECATED
237 YARP_DEPRECATED_MSG("Use asInt32 instead")
238 inline virtual int asInt() const final
240 return static_cast<int>(asInt32());
253 virtual std::int8_t asInt8()
const;
264 virtual std::int16_t asInt16()
const;
275 virtual std::int32_t asInt32()
const;
286 virtual std::int64_t asInt64()
const;
288 #ifndef YARP_NO_DEPRECATED
297 YARP_DEPRECATED_MSG("Use asFloat64 instead")
300 return static_cast<double>(asFloat64());
332 #ifndef YARP_NO_DEPRECATED
338 YARP_DEPRECATED_MSG("Use asVocab32 instead")
350 virtual std::string asString()
const;
357 virtual Bottle* asList()
const;
378 virtual const char* asBlob()
const;
385 virtual size_t asBlobLength()
const;
394 bool check(
const std::string& key)
const override;
397 Value& find(
const std::string& key)
const override;
407 bool operator==(
const Value& alt)
const;
414 bool operator!=(
const Value& alt)
const;
422 void fromString(
const char* str);
424 std::string
toString()
const override;
430 virtual Value* create()
const;
436 virtual Value* clone()
const;
442 virtual std::int32_t getCode()
const;
444 bool isNull()
const override;
446 virtual bool isLeaf()
const;
448 #ifndef YARP_NO_DEPRECATED
456 YARP_DEPRECATED_MSG("Use makeInt32 instead")
459 return makeInt32(
static_cast<std::int32_t
>(x));
468 static Value* makeInt8(std::int8_t x);
475 static Value* makeInt16(std::int16_t x);
482 static Value* makeInt32(std::int32_t x);
489 static Value* makeInt64(std::int64_t x);
491 #ifndef YARP_NO_DEPRECATED
499 YARP_DEPRECATED_MSG("Use makeFloat64 instead")
525 static Value* makeString(
const std::string& str);
558 #ifndef YARP_NO_DEPRECATED
565 YARP_DEPRECATED_MSG("Use makeVocab32 instead")
568 return makeVocab32(v);
578 static
Value* makeVocab(const std::
string& str)
580 return makeVocab32(str);
590 static Value* makeBlob(
void* data,
int length);
596 static Value* makeList();
603 static Value* makeList(
const char* txt);
611 static Value* makeValue(
const std::string& txt);
618 static Value& getNullValue();
620 #ifndef DOXYGEN_SHOULD_SKIP_THIS
A simple collection of objects that can be described and transmitted in a portable way.
An interface for reading from a network connection.
An interface for writing to a network connection.
This is a base class for objects that can be both read from and be written to the YARP network.
A class for storing options and configuration information.
A base class for nested structures that can be searched.
virtual bool check(const std::string &key) const =0
Check if there exists a property of the given name.
virtual Bottle & findGroup(const std::string &key) const =0
Gets a list corresponding to a given keyword.
A single value (typically within a Bottle).
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 ...
virtual int asInt() const final
Get integer value.
virtual yarp::conf::vocab32_t asVocab() const
Get vocabulary identifier as an integer.
virtual bool isVocab() const
Checks if value is a vocabulary identifier.
static Value * makeVocab32(char a, char b=0, char c=0, char d=0)
Create a vocabulary identifier Value.
static Value * makeInt(int x)
Create an integer Value.
static Value * makeDouble(double x)
Create a floating point Value.
virtual double asDouble() const final
Get floating point value.
static Value * makeVocab(yarp::conf::vocab32_t v)
Create a vocabulary identifier Value.
A single item in a Bottle.
#define YARP_DEPRECATED_MSG(MSG)
Expands to either the standard [[deprecated]] attribute or a compiler-specific decorator such as __at...
std::string toString(const T &value)
convert an arbitrary type to string.
NetInt32 encode(const std::string &str)
Convert a string into a vocabulary identifier.
constexpr yarp::conf::vocab32_t createVocab32(char a, char b=0, char c=0, char d=0)
Create a vocab from chars.
std::string findGroup(const robotinterface::ParamList &list, const std::string &name)
bool read(ImageOf< PixelRgb > &dest, const std::string &src, image_fileformat format=FORMAT_ANY)
bool write(const ImageOf< PixelRgb > &src, const std::string &dest, image_fileformat format=FORMAT_PPM)
The main, catch-all namespace for YARP.