|
YARP
Yet Another Robot Platform
|
|
Go to the documentation of this file.
70 std::int32_t subCode = 0;
75 case StoreInt16::code:
78 case StoreInt32::code:
81 case StoreInt64::code:
84 case StoreVocab::code:
87 case StoreFloat32::code:
90 case StoreFloat64::code:
93 case StoreString::code:
102 storable->
asList()->implementation->setNested(
true);
114 storable->
asList()->implementation->specialize(subCode);
115 storable->
asList()->implementation->setNested(
true);
123 Value& Storable::find(
const std::string& key)
const
172 return std::to_string(x);
177 x =
static_cast<std::int8_t
>(strtol(src.c_str(),
static_cast<char**
>(
nullptr), 0));
198 return std::to_string(x);
203 x =
static_cast<std::int16_t
>(strtol(src.c_str(),
static_cast<char**
>(
nullptr), 0));
224 return std::to_string(x);
229 x = strtol(src.c_str(),
static_cast<char**
>(
nullptr), 0);
250 return std::to_string(x);
255 x = strtoll(src.c_str(),
static_cast<char**
>(
nullptr), 0);
298 return std::string(
"[") +
toString() +
"]";
304 if (src.length() > 0) {
308 }
else if (src ==
"true") {
309 x =
static_cast<int>(
'1');
310 }
else if (src ==
"false") {
395 bool needQuote =
false;
396 for (
unsigned int i = 0; i < x.length(); i++) {
398 if ((ch < 'a' || ch >
'z') && (ch < 'A' || ch >
'Z') && ch !=
'_') {
399 if ((ch >=
'0' && ch <=
'9') || ch ==
'.' || ch ==
'-') {
410 if (x.length() == 0) {
413 if (x ==
"true" || x ==
"false") {
426 }
else if (ch ==
'\r') {
429 }
else if (ch ==
'\0') {
433 if (ch ==
'\\' || ch ==
'\"') {
458 size_t len = src.length();
462 if (src[0] ==
'\"') {
465 for (
size_t i = 0; i < len; i++) {
466 if (skip && (i == 0 || i == len - 1)) {
481 }
else if (ch ==
'r') {
483 }
else if (ch ==
'0') {
503 reader.
expectBlock(
const_cast<char*
>(x.data()), len);
509 writer.
appendInt32(
static_cast<std::int32_t
>(x.length()));
521 for (
unsigned int i = 0; i < x.length(); i++) {
525 const auto* src =
reinterpret_cast<const unsigned char*
>(&x[i]);
533 return std::string(
"{") +
toString() +
"}";
539 std::string buf(bot.
size(), 0);
540 for (
size_t i = 0; i < bot.
size(); i++) {
541 buf[i] =
static_cast<char>(
static_cast<unsigned char>(bot.
get(i).
asInt32()));
548 if (src.length() > 0) {
551 std::string buf = src.substr(1, src.length() - 2);
561 reader.
expectBlock(
const_cast<char*
>(x.data()), len);
567 writer.
appendInt32(
static_cast<std::int32_t
>(x.length()));
583 return std::string(
"(") + content.
toString() +
")";
593 if (src.length() > 0) {
596 std::string buf = src.substr(1, src.length() - 2);
605 content.
read(reader);
612 content.
write(writer);
618 return subCoder(*(content.implementation));
627 return std::string(content.
toString());
632 return std::string(
"(") + content.
toString() +
")";
642 if (src.length() > 0) {
645 std::string buf = src.substr(1, src.length() - 2);
654 content.
read(reader);
661 content.
write(writer);
virtual bool check(const std::string &key) const=0
Check if there exists a property of the given name.
virtual void appendFloat32(yarp::conf::float32_t data)=0
Send a representation of a 32-bit floating point number to the network connection.
A simple collection of objects that can be described and transmitted in a portable way.
bool readRaw(ConnectionReader &reader) override
bool writeRaw(ConnectionWriter &writer) const override
void fromString(const std::string &src) override
Initialize from a string representation, assuming that any syntax around this representation such as ...
bool writeRaw(ConnectionWriter &writer) const override
bool writeRaw(ConnectionWriter &writer) const override
std::string toString() const override
Gives a human-readable textual representation of the bottle.
bool readRaw(ConnectionReader &reader) override
virtual void appendBlock(const char *data, size_t len)=0
Send a block of data to the network connection.
bool writeRaw(ConnectionWriter &writer) const override
bool readRaw(ConnectionReader &reader) override
size_type size() const
Gets the number of elements in the bottle.
void fromString(const std::string &src) override
Initialize from a string representation, assuming that any syntax around this representation such as ...
void fromString(const std::string &src) override
Initialize from a string representation, assuming that any syntax around this representation such as ...
std::string toStringNested() const override
Create string representation, including any syntax that should wrap it such as braces or parentheses.
bool write(ConnectionWriter &connection) const override
Write this object to a network connection.
virtual void appendFloat64(yarp::conf::float64_t data)=0
Send a representation of a 64-bit floating point number to the network connection.
A flexible data format for holding a bunch of numbers and strings.
bool readRaw(ConnectionReader &reader) override
bool write(ConnectionWriter &writer) const override
Write this object to a network connection.
std::string toString() const override
Return a standard text representation of the content of the object.
bool readRaw(ConnectionReader &reader) override
void fromString(const std::string &txt, bool wipe=true)
Interprets a string as a list of properties.
std::string toStringNested() const override
Create string representation, including any syntax that should wrap it such as braces or parentheses.
bool readRaw(ConnectionReader &reader) override
virtual void appendInt8(std::int8_t data)=0
Send a representation of a 8-bit integer to the network connection.
bool readRaw(ConnectionReader &reader) override
#define BOTTLE_TAG_STRING
void fromString(const std::string &src) override
Initialize from a string representation, assuming that any syntax around this representation such as ...
void fromStringNested(const std::string &src) override
Initialize from a string representation.
void fromStringNested(const std::string &src) override
Initialize from a string representation.
void fromStringNested(const std::string &src) override
Initialize from a string representation.
bool readRaw(ConnectionReader &reader) override
void fromString(const std::string &text)
Initializes bottle from a string.
static yarp::conf::float64_t toFloat64(const std::string &s)
void fromString(const std::string &src) override
Initialize from a string representation, assuming that any syntax around this representation such as ...
bool writeRaw(ConnectionWriter &writer) const override
std::string toString() const override
Return a standard text representation of the content of the object.
A single item in a Bottle.
virtual std::int8_t expectInt8()=0
Read a 8-bit integer from the network connection.
std::string toString() const override
Return a standard text representation of the content of the object.
const yarp::os::LogComponent & STORABLE()
bool writeRaw(ConnectionWriter &writer) const override
std::string decode(NetInt32 code)
Convert a vocabulary identifier into a string.
std::string toString() const override
Return a standard text representation of the content of the object.
void fromStringNested(const std::string &src) override
Initialize from a string representation.
virtual yarp::conf::float64_t expectFloat64()=0
Read a 64-bit floating point number from the network connection.
static std::string quotedString(const std::string &x)
std::string toStringNested() const override
Create string representation, including any syntax that should wrap it such as braces or parentheses.
bool readRaw(ConnectionReader &reader) override
#define BOTTLE_TAG_FLOAT32
bool operator==(const yarp::os::Value &alt) const
virtual std::int32_t expectInt32()=0
Read a 32-bit integer from the network connection.
virtual std::int64_t expectInt64()=0
Read a 64-bit integer from the network connection.
std::string toStringNested() const override
Create string representation, including any syntax that should wrap it such as braces or parentheses.
bool writeRaw(ConnectionWriter &writer) const override
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
std::string toString() const override
Return a standard text representation of the content of the object.
bool write(ConnectionWriter &writer) const override
Output a representation of the bottle to a network connection.
An interface for writing to a network connection.
static yarp::conf::float32_t toFloat32(const std::string &s)
bool readRaw(ConnectionReader &reader) override
void fromString(const std::string &src) override
Initialize from a string representation, assuming that any syntax around this representation such as ...
std::string toString() const override
Return a standard text representation of the content of the object.
A 32-bit floating point number item.
std::string toStringNested() const override
Create string representation, including any syntax that should wrap it such as braces or parentheses.
void fromString(const std::string &src) override
Initialize from a string representation, assuming that any syntax around this representation such as ...
yarp::os::Value & find(const std::string &key) const override
Gets a value corresponding to a given keyword.
bool isNull() const override
Checks if the object is invalid.
NetInt32 encode(const std::string &str)
Convert a string into a vocabulary identifier.
yarp::os::Bottle * asList() const override
Get list value.
void fromString(const std::string &src) override
Initialize from a string representation, assuming that any syntax around this representation such as ...
A 64-bit floating point number item.
std::string toString() const override
Return a standard text representation of the content of the object.
std::string toString() const override
Return a standard text representation of the content of the object.
std::string toString() const override=0
Return a standard text representation of the content of the object.
bool writeRaw(ConnectionWriter &writer) const override
bool writeRaw(ConnectionWriter &writer) const override
void fromString(const std::string &src) override
Initialize from a string representation, assuming that any syntax around this representation such as ...
static Bottle & getNullBottle()
A special Bottle with no content.
#define yCAssert(component, x)
bool isNull() const override
Checks if the object is invalid.
bool read(ConnectionReader &connection) override
Read this object from a network connection.
virtual void appendInt32(std::int32_t data)=0
Send a representation of a 32-bit integer to the network connection.
An interface for reading from a network connection.
virtual void appendInt64(std::int64_t data)=0
Send a representation of a 64-bit integer to the network connection.
static std::string toString(int x)
#define BOTTLE_TAG_FLOAT64
virtual Bottle & findGroup(const std::string &key) const=0
Gets a list corresponding to a given keyword.
virtual std::int32_t asInt32() const
Get 32-bit integer value.
virtual std::int16_t expectInt16()=0
Read a 16-bit integer from the network connection.
bool readRaw(ConnectionReader &reader) override
virtual std::int32_t getCode() const
Get standard type code of value.
void fromStringNested(const std::string &src) override
Initialize from a string representation.
void fromString(const std::string &src) override
Initialize from a string representation, assuming that any syntax around this representation such as ...
bool read(ConnectionReader &reader) override
Read this object from a network connection.
bool writeRaw(ConnectionWriter &writer) const override
bool writeRaw(ConnectionWriter &writer) const override
virtual yarp::conf::float32_t expectFloat32()=0
Read a 32-bit floating point number from the network connection.
bool read(ConnectionReader &reader) override
Set the bottle's value based on input from a network connection.
virtual bool writeRaw(ConnectionWriter &connection) const =0
std::string toString() const override
Return a standard text representation of the content of the object.
std::string toString() const override
Return a standard text representation of the content of the object.
virtual bool expectBlock(char *data, size_t len)=0
Read a block of data from the network connection.
void fromString(const std::string &src) override
Initialize from a string representation, assuming that any syntax around this representation such as ...
std::string toString() const override
Return a standard text representation of the content of the object.
virtual void appendInt16(std::int16_t data)=0
Send a representation of a 16-bit integer to the network connection.
A single value (typically within a Bottle).
#define YARP_OS_LOG_COMPONENT(name, name_string)
std::int32_t subCoder(T &content)
virtual bool readRaw(ConnectionReader &connection)=0
std::string toString() const override
Return a standard text representation of the content of the object.
static StoreNull & getNull()
std::string toString() const override
Return a standard text representation of the content of the object.
std::int32_t subCode() const override
Return a code describing this item, used in serializing bottles.