69 for (
auto&
i : content) {
76void BottleImpl::smartAdd(
const std::string& str)
78 if (str.length() > 0) {
89 for (
size_t i = 0;
i < str.length();
i++) {
90 if (str ==
"inf" || str ==
"-inf" || str ==
"nan") {
102 if (!hexActive && (ch2 ==
'e' || ch2 ==
'E')) {
106 if (ch2 ==
'x' || ch2 ==
'X') {
113 if (ch2 ==
'0' || ch2 ==
'+' || ch2 ==
'-') {
114 if (ch2 ==
'+' || ch2 ==
'-') {
124 if (!((ch2 >=
'0' && ch2 <=
'9') || ch2 ==
'.' || ch2 ==
'e' ||
125 ch2 ==
'E' || ch2 ==
'+' || ch2 ==
'-' ||
126 (hexActive && ((ch2 >=
'a' && ch2 <=
'f') ||
127 (ch2 >=
'A' && ch2 <=
'F'))))) {
133 if (
static_cast<int>(str.length()) - (hexStart + 1) > 8) {
140 ((ch >=
'0' && ch <=
'9') || ch ==
'+' || ch ==
'-' || ch ==
'.' || ch ==
'i' || ch ==
'n' ) &&
141 (ch !=
'.' || str.length() > 1)) {
143 s =
new StoreInt64(0);
145 s =
new StoreFloat64(0);
147 }
else if (ch ==
'(') {
149 }
else if (ch ==
'[') {
150 s =
new StoreVocab32();
151 }
else if (ch ==
'{') {
154 s = ss =
new StoreString(
"");
164 && s->
asInt64() >= std::numeric_limits<int32_t>::min()
165 && s->
asInt64() <= std::numeric_limits<int32_t>::max()) {
173 if (str.length() == 0 || str[0] !=
'\"') {
177 s =
new StoreVocab32(
static_cast<int>(
'1'));
178 }
else if (val ==
"false") {
180 s =
new StoreVocab32(0);
200 std::string
nline = line +
" ";
202 for (
char ch :
nline) {
208 if (ch !=
' ' && ch !=
'\t' && ch !=
'\n' && ch !=
'\r') {
234 if ((!
quoted) && (ch ==
',' || ch ==
' ' || ch ==
'\t' ||
235 ch ==
'\n' || ch ==
'\r') &&
262 std::string
nline = txt;
265 for (
char ch :
nline) {
270 if (ch !=
' ' && ch !=
'\t' && ch !=
'\n' && ch !=
'\r') {
297 (ch ==
' ' || ch ==
'\t' || ch ==
'\n' || ch ==
'\r') &&
315 for (
unsigned int i = 0;
i < content.size();
i++) {
327 return content.size();
336 std::int32_t
id = speciality;
357 std::string
wrapper(text, len);
362 reader.
reset(sis,
nullptr, route, len,
false);
374 reader.
reset(sis,
nullptr, route, data.
length(),
false);
398 for (
int i = 0;
i < len;
i++) {
456 bool done = (str.length() <= 0);
458 if (str[str.length() - 1] ==
'\\') {
459 str = str.substr(0, str.length() - 1);
501 std::int32_t len = 0;
507 for (
int i = 0;
i < len;
i++) {
517void BottleImpl::synch()
const
522void BottleImpl::synch()
530 BufferedConnectionWriter writer;
536 writer.appendInt32(
static_cast<std::int32_t
>(
size()));
537 for (
auto s : content) {
538 if (speciality == 0) {
540 writer.appendInt32(s->
getCode());
546 s->
asList()->implementation->setNested(
true);
550 data.resize(writer.dataSize(),
' ');
551 MemoryOutputStream m(&data[0]);
571 this->nested = nested;
582 return index <
size();
648 return lst->internal();
655 return lst->internal();
661 if (len == 0 ||
alt->size() == 0) {
676 const size_t last = src->
size() - 1;
677 for (
size_t i = 0; (
i < len) && (first +
i <= last); ++
i) {
694 for (
size_t i = 0;
i <
size();
i++) {
698 cursor = &(cursor->
asList()->get(0));
710 for (
size_t i = 0;
i <
size();
i++) {
716 cursor = &(bot->
get(0));
721 return org->asList()->get(1);
723 return get(
static_cast<int>(
i + 1));
A simple collection of objects that can be described and transmitted in a portable way.
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
A mini-server for performing network communication in the background.
A simple abstraction for a block of bytes.
An interface for reading from a network connection.
virtual bool isTextMode() const =0
Check if the connection is text mode.
virtual std::int32_t expectInt32()=0
Read a 32-bit integer from the network connection.
virtual std::string expectText(const char terminatingChar='\n')=0
Read some text from the network connection.
virtual bool isError() const =0
An interface for writing to a network connection.
virtual bool isError() const =0
virtual bool isTextMode() const =0
Check if the connection is text mode.
virtual void appendText(const std::string &str, const char terminate='\n')=0
Send a terminated string to the network connection.
virtual void appendBlock(const char *data, size_t len)=0
Send a block of data to the network connection.
A class for storing options and configuration information.
Information about a connection between two ports.
A base class for nested structures that can be searched.
A single value (typically within a Bottle).
virtual bool isList() const
Checks if value is a list.
virtual Bottle * asList() const
Get list value.
std::string toString() const override
Return a standard text representation of the content of the object.
virtual std::int32_t getCode() const
Get standard type code of value.
A flexible data format for holding a bunch of numbers and strings.
bool fromBytes(const yarp::os::Bytes &data)
Storable & get(size_type index) const
yarp::os::Bottle & addList()
static StoreNull & getNull()
const char * getBytes() const
bool write(ConnectionWriter &writer) const
Value & findGroupBit(const std::string &key) const
bool checkIndex(size_type index) const
void toBytes(yarp::os::Bytes &data)
bool isFloat64(int index)
Value & findBit(const std::string &key) const
bool isFloat32(int index)
void copyRange(const BottleImpl *alt, size_type first=0, size_type len=npos)
yarp::os::Property & addDict()
static bool isComplete(const char *txt)
bool read(ConnectionReader &reader)
std::string toString() const
void fromBinary(const char *text, size_t len)
void setNested(bool nested)
void specialize(std::int32_t subCode)
void fromString(const std::string &line)
A single item in a Bottle.
virtual std::string toStringNested() const
Create string representation, including any syntax that should wrap it such as braces or parentheses.
std::int64_t asInt64() const override
Get 64-bit integer value.
bool isList() const override
Checks if value is a list.
virtual bool writeRaw(ConnectionWriter &connection) const =0
static Storable * createByCode(std::int32_t id)
virtual void fromStringNested(const std::string &src)
Initialize from a string representation.
virtual Storable * cloneStorable() const
Typed synonym for clone()
yarp::os::Bottle * asList() const override
Get list value.
bool isInt64() const override
Checks if value is a 64-bit integer.
std::int32_t asInt32() const override
Get 32-bit integer value.
static const std::int32_t code
std::string asString() const override
Get string value.
Lets Readable objects read from the underlying InputStream associated with the connection between two...
void reset(yarp::os::InputStream &in, TwoWayStream *str, const Route &route, size_t len, bool textMode, bool bareMode=false)
bool isError() const override
std::int32_t expectInt32() override
Read a 32-bit integer from the network connection.
#define yCError(component,...)
#define yCAssert(component, x)
#define yCTrace(component,...)
#define yCFatal(component,...)
#define YARP_OS_LOG_COMPONENT(name, name_string)
std::int32_t subCoder(T &content)
constexpr yarp::conf::vocab32_t createVocab32(char a, char b=0, char c=0, char d=0)
Create a vocab from chars.