YARP
Yet Another Robot Platform
BottleImpl.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
3  * Copyright (C) 2006-2010 RobotCub Consortium
4  * Copyright (C) 2006, 2008 Arjan Gijsberts
5  * All rights reserved.
6  *
7  * This software may be modified and distributed under the terms of the
8  * BSD-3-Clause license. See the accompanying LICENSE file for details.
9  */
10 
12 
13 #include <yarp/conf/numeric.h>
14 
20 
21 #include <limits>
22 
23 using yarp::os::Bottle;
24 using yarp::os::Bytes;
28 using yarp::os::Value;
31 
32 namespace {
33 YARP_OS_LOG_COMPONENT(BOTTLEIMPL, "yarp.os.impl.BottleImpl")
34 } // namespace
35 
36 BottleImpl::BottleImpl() :
37  parent(nullptr),
38  invalid(false),
39  ro(false),
40  speciality(0),
41  nested(false),
42  dirty(true)
43 {
44 }
45 
47  parent(parent),
48  invalid(false),
49  ro(false),
50  speciality(0),
51  nested(false),
52  dirty(true)
53 {
54 }
55 
56 
58 {
59  clear();
60 }
61 
62 
63 void BottleImpl::add(Storable* s)
64 {
65  content.push_back(s);
66  dirty = true;
67 }
68 
69 
71 {
72  for (auto& i : content) {
73  delete i;
74  }
75  content.clear();
76  dirty = true;
77 }
78 
79 void BottleImpl::smartAdd(const std::string& str)
80 {
81  if (str.length() > 0) {
82  char ch = str[0];
83  Storable* s = nullptr;
84  StoreString* ss = nullptr;
85  bool numberLike = true;
86  bool preamble = true;
87  bool hexActive = false;
88  size_t hexStart = 0;
89  int periodCount = 0;
90  int signCount = 0;
91  bool hasPeriodOrE = false;
92  for (size_t i = 0; i < str.length(); i++) {
93  if (str == "inf" || str == "-inf" || str == "nan") {
94  hasPeriodOrE = true;
95  break;
96  }
97  char ch2 = str[i];
98  if (ch2 == '.') {
99  hasPeriodOrE = true;
100  periodCount++;
101  if (periodCount > 1) {
102  numberLike = false;
103  }
104  }
105  if (!hexActive && (ch2 == 'e' || ch2 == 'E')) {
106  hasPeriodOrE = true;
107  }
108  if (preamble) {
109  if (ch2 == 'x' || ch2 == 'X') {
110  hexActive = true;
111  hexStart = i;
112  continue;
113  }
114  }
115  if (preamble) {
116  if (ch2 == '0' || ch2 == '+' || ch2 == '-') {
117  if (ch2 == '+' || ch2 == '-') {
118  signCount++;
119  if (signCount > 1) {
120  numberLike = false;
121  }
122  }
123  continue;
124  }
125  }
126  preamble = false;
127  if (!((ch2 >= '0' && ch2 <= '9') || ch2 == '.' || ch2 == 'e' ||
128  ch2 == 'E' || ch2 == '+' || ch2 == '-' ||
129  (hexActive && ((ch2 >= 'a' && ch2 <= 'f') ||
130  (ch2 >= 'A' && ch2 <= 'F'))))) {
131  numberLike = false;
132  break;
133  }
134  }
135  if (hexActive) {
136  if (static_cast<int>(str.length()) - (hexStart + 1) > 8) {
137  // we can only deal with 32bit hexadecimal
138  numberLike = false;
139  }
140  }
141 
142  if (numberLike &&
143  ((ch >= '0' && ch <= '9') || ch == '+' || ch == '-' || ch == '.' || ch == 'i' /* inf */ || ch == 'n' /* nan */) &&
144  (ch != '.' || str.length() > 1)) {
145  if (!hasPeriodOrE) {
146  s = new StoreInt64(0);
147  } else {
148  s = new StoreFloat64(0);
149  }
150  } else if (ch == '(') {
151  s = new StoreList();
152  } else if (ch == '[') {
153  s = new StoreVocab();
154  } else if (ch == '{') {
155  s = new StoreBlob();
156  } else {
157  s = ss = new StoreString("");
158  }
159  if (s != nullptr) {
160  s->fromStringNested(str);
161 
162  // Traditionally all int are read as 32 bit integers, but 64 bit
163  // integers will not fit.
164  // Therefore the value is read as 64 bit, but if the value would fit
165  // a 32 bit integer, it is cast to a 32 bit integer.
166  if (s->isInt64()
167  && s->asInt64() >= std::numeric_limits<int32_t>::min()
168  && s->asInt64() <= std::numeric_limits<int32_t>::max()) {
169  Storable* s_i32 = new StoreInt32(s->asInt32());
170  delete s;
171  s = s_i32;
172  s_i32 = nullptr;
173  }
174 
175  if (ss != nullptr) {
176  if (str.length() == 0 || str[0] != '\"') {
177  std::string val = ss->asString();
178  if (val == "true") {
179  delete s;
180  s = new StoreVocab(static_cast<int>('1'));
181  } else if (val == "false") {
182  delete s;
183  s = new StoreVocab(0);
184  }
185  }
186  }
187  add(s);
188  }
189  ss = nullptr;
190  }
191 }
192 
193 void BottleImpl::fromString(const std::string& line)
194 {
195  clear();
196  dirty = true;
197  std::string arg;
198  bool quoted = false;
199  bool back = false;
200  bool begun = false;
201  int nested = 0;
202  int nestedAlt = 0;
203  std::string nline = line + " ";
204 
205  for (char ch : nline) {
206  if (back) {
207  arg += ch;
208  back = false;
209  } else {
210  if (!begun) {
211  if (ch != ' ' && ch != '\t' && ch != '\n' && ch != '\r') {
212  begun = true;
213  }
214  }
215  if (begun) {
216  if (ch == '\"') {
217  quoted = !quoted;
218  }
219  if (!quoted) {
220  if (ch == '(') {
221  nested++;
222  }
223  if (ch == ')') {
224  nested--;
225  }
226  if (ch == '{') {
227  nestedAlt++;
228  }
229  if (ch == '}') {
230  nestedAlt--;
231  }
232  }
233  if (ch == '\\') {
234  back = true;
235  arg += ch;
236  } else {
237  if ((!quoted) && (ch == ',' || ch == ' ' || ch == '\t' ||
238  ch == '\n' || ch == '\r') &&
239  (nestedAlt == 0) && (nested == 0)) {
240  if (!arg.empty()) {
241  if (arg == "null") {
242  add(new StoreVocab(yarp::os::createVocab('n', 'u', 'l', 'l')));
243  } else {
244  smartAdd(arg);
245  }
246  }
247  arg = "";
248  begun = false;
249  } else {
250  arg += ch;
251  }
252  }
253  }
254  }
255  }
256 }
257 
258 bool BottleImpl::isComplete(const char* txt)
259 {
260  bool quoted = false;
261  bool back = false;
262  bool begun = false;
263  int nested = 0;
264  int nestedAlt = 0;
265  std::string nline = txt;
266  nline += " ";
267 
268  for (char ch : nline) {
269  if (back) {
270  back = false;
271  } else {
272  if (!begun) {
273  if (ch != ' ' && ch != '\t' && ch != '\n' && ch != '\r') {
274  begun = true;
275  }
276  }
277  if (begun) {
278  if (ch == '\"') {
279  quoted = !quoted;
280  }
281  if (!quoted) {
282  if (ch == '(') {
283  nested++;
284  }
285  if (ch == ')') {
286  nested--;
287  }
288  if (ch == '{') {
289  nestedAlt++;
290  }
291  if (ch == '}') {
292  nestedAlt--;
293  }
294  }
295  if (ch == '\\') {
296  back = true;
297  // arg += ch;
298  } else {
299  if ((!quoted) &&
300  (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r') &&
301  (nestedAlt == 0) && (nested == 0)) {
302  // smartAdd(arg);
303  begun = false;
304  } else {
305  // arg += ch;
306  }
307  }
308  }
309  }
310  }
311  return nested == 0 && nestedAlt == 0 && !quoted;
312 }
313 
314 
315 std::string BottleImpl::toString() const
316 {
317  std::string result;
318  for (unsigned int i = 0; i < content.size(); i++) {
319  if (i > 0) {
320  result += " ";
321  }
322  Storable& s = *content[i];
323  result += s.toStringNested();
324  }
325  return result;
326 }
327 
329 {
330  return content.size();
331 }
332 
333 
335 {
336  if (reader.isError()) {
337  return false;
338  }
339  std::int32_t id = speciality;
340  yCTrace(BOTTLEIMPL, "READING, nest flag is %d", nested);
341  if (id == 0) {
342  id = reader.expectInt32();
343  yCTrace(BOTTLEIMPL, "READ subcode %" PRId32, id);
344  } else {
345  yCTrace(BOTTLEIMPL, "READ skipped subcode %" PRId32, speciality);
346  }
347  Storable* storable = Storable::createByCode(id);
348  if (storable == nullptr) {
349  yCError(BOTTLEIMPL, "Reader failed, unrecognized object code %" PRId32, id);
350  return false;
351  }
352  storable->readRaw(reader);
353  add(storable);
354  return true;
355 }
356 
357 
358 void BottleImpl::fromBinary(const char* text, size_t len)
359 {
360  std::string wrapper(text, len);
361  StringInputStream sis;
362  sis.add(wrapper);
363  StreamConnectionReader reader;
364  Route route;
365  reader.reset(sis, nullptr, route, len, false);
366  read(reader);
367 }
368 
369 
370 bool BottleImpl::fromBytes(const Bytes& data)
371 {
372  std::string wrapper(data.get(), data.length());
373  StringInputStream sis;
374  sis.add(wrapper);
375  StreamConnectionReader reader;
376  Route route;
377  reader.reset(sis, nullptr, route, data.length(), false);
378 
379  clear();
380  dirty = true; // for clarity
381 
382  if (!nested) {
383  clear();
384  specialize(0);
385 
386  std::int32_t code = reader.expectInt32();
387  if (reader.isError()) {
388  return false;
389  }
390  yCTrace(BOTTLEIMPL, "READ got top level code %" PRId32, code);
391  code = code & UNIT_MASK;
392  if (code != 0) {
393  specialize(code);
394  }
395  }
396  std::int32_t len = reader.expectInt32();
397  if (reader.isError()) {
398  return false;
399  }
400  yCTrace(BOTTLEIMPL, "READ bottle length %d", len);
401  for (int i = 0; i < len; i++) {
402  bool ok = fromBytes(reader);
403  if (!ok) {
404  return false;
405  }
406  }
407 
408  return true;
409 }
410 
412 {
413  synch();
414  yCAssert(BOTTLEIMPL, data.length() == byteCount());
415  memcpy(data.get(), getBytes(), byteCount());
416 }
417 
418 
419 const char* BottleImpl::getBytes() const
420 {
421  yCTrace(BOTTLEIMPL, "am I nested? %d", nested);
422  synch();
423  return &data[0];
424 }
425 
426 size_t BottleImpl::byteCount() const
427 {
428  synch();
429  return data.size();
430 }
431 
433 {
434  synch();
435 }
436 
438 {
439  // could simplify this if knew lengths of blocks up front
440  if (writer.isTextMode()) {
441  writer.appendText(toString());
442  } else {
443  synch();
444  writer.appendBlock(getBytes(), byteCount());
445  }
446  return !writer.isError();
447 }
448 
449 
451 {
452  bool result = false;
453 
454  if (reader.isTextMode()) {
455  std::string str = reader.expectText();
456  if (reader.isError()) {
457  return false;
458  }
459  bool done = (str.length() <= 0);
460  while (!done) {
461  if (str[str.length() - 1] == '\\') {
462  str = str.substr(0, str.length() - 1);
463  str += reader.expectText();
464  if (reader.isError()) {
465  return false;
466  }
467  } else {
468  if (isComplete(str.c_str())) {
469  done = true;
470  } else {
471  str += "\n";
472  str += reader.expectText();
473  if (reader.isError()) {
474  return false;
475  }
476  }
477  }
478  }
479  fromString(str);
480  result = true;
481  } else {
482  if (!nested) {
483  // no byte length any more to facilitate nesting
484  // reader.expectInt32(); // the bottle byte ct; ignored
485 
486  clear();
487  specialize(0);
488 
489  std::int32_t code = reader.expectInt32();
490  if (reader.isError()) {
491  return false;
492  }
493  yCTrace(BOTTLEIMPL, "READ got top level code %" PRId32, code);
494  code = code & UNIT_MASK;
495  if (code != 0) {
496  specialize(code);
497  }
498  }
499 
500  result = true;
501  clear();
502  dirty = true; // for clarity
503 
504  std::int32_t len = 0;
505  len = reader.expectInt32();
506  if (reader.isError()) {
507  return false;
508  }
509  yCTrace(BOTTLEIMPL, "READ got length %d", len);
510  for (int i = 0; i < len; i++) {
511  bool ok = fromBytes(reader);
512  if (!ok) {
513  return false;
514  }
515  }
516  }
517  return result;
518 }
519 
520 void BottleImpl::synch() const
521 {
522  const_cast<BottleImpl*>(this)->synch();
523 }
524 
525 void BottleImpl::synch()
526 {
527  if (dirty) {
528  if (!nested) {
529  subCode();
530  yCTrace(BOTTLEIMPL, "bottle code %" PRId32, StoreList::code + subCode());
531  }
532  data.clear();
533  BufferedConnectionWriter writer;
534  if (!nested) {
535  writer.appendInt32(StoreList::code + speciality);
536  yCTrace(BOTTLEIMPL, "wrote bottle code %" PRId32, StoreList::code + speciality);
537  }
538  yCTrace(BOTTLEIMPL, "bottle length %zd", size());
539  writer.appendInt32(static_cast<std::int32_t>(size()));
540  for (auto s : content) {
541  if (speciality == 0) {
542  yCTrace(BOTTLEIMPL, "subcode %" PRId32, s->getCode());
543  writer.appendInt32(s->getCode());
544  } else {
545  yCTrace(BOTTLEIMPL, "skipped subcode %" PRId32, s->getCode());
546  yCAssert(BOTTLEIMPL, speciality == s->getCode());
547  }
548  if (s->isList()) {
549  s->asList()->implementation->setNested(true);
550  }
551  s->writeRaw(writer);
552  }
553  data.resize(writer.dataSize(), ' ');
554  MemoryOutputStream m(&data[0]);
555  writer.write(m);
556  dirty = false;
557  }
558 }
559 
560 
561 void BottleImpl::specialize(std::int32_t subCode)
562 {
563  speciality = subCode;
564 }
565 
566 
568 {
569  return speciality;
570 }
571 
572 void BottleImpl::setNested(bool nested)
573 {
574  this->nested = nested;
575 }
576 
577 
578 std::int32_t BottleImpl::subCode()
579 {
580  return subCoder(*this);
581 }
582 
584 {
585  return index < size();
586 }
587 
588 bool BottleImpl::isInt8(int index)
589 {
590  return (checkIndex(index) ? content[index]->isInt8() : false);
591 }
592 
593 bool BottleImpl::isInt16(int index)
594 {
595  return (checkIndex(index) ? content[index]->isInt16() : false);
596 }
597 
598 bool BottleImpl::isInt32(int index)
599 {
600  return (checkIndex(index) ? content[index]->isInt32() : false);
601 }
602 
603 bool BottleImpl::isInt64(int index)
604 {
605  return (checkIndex(index) ? content[index]->isInt64() : false);
606 }
607 
608 bool BottleImpl::isFloat32(int index)
609 {
610  return (checkIndex(index) ? content[index]->isFloat32() : false);
611 }
612 
613 bool BottleImpl::isFloat64(int index)
614 {
615  return (checkIndex(index) ? content[index]->isFloat64() : false);
616 }
617 
618 bool BottleImpl::isString(int index)
619 {
620  return (checkIndex(index) ? content[index]->isString() : false);
621 }
622 
623 bool BottleImpl::isList(int index)
624 {
625  return (checkIndex(index) ? content[index]->isList() : false);
626 }
627 
629 {
630  Storable* stb = nullptr;
631  if (size() == 0) {
632  stb = new StoreNull();
633  } else {
634  stb = content[size() - 1];
635  content.pop_back();
636  dirty = true;
637  }
638  yCAssert(BOTTLEIMPL, stb != nullptr);
639  return stb;
640 }
641 
643 {
644  return (checkIndex(index) ? *(content[index]) : getNull());
645 }
646 
648 {
649  auto* lst = new StoreList();
650  add(lst);
651  return lst->internal();
652 }
653 
655 {
656  auto* lst = new StoreDict();
657  add(lst);
658  return lst->internal();
659 }
660 
662 {
663 
664  if (len == 0 || alt->size() == 0) {
665  clear();
666  return;
667  }
668 
669  // Handle copying to the same object just a subset of the bottle
670  const BottleImpl* src = alt;
671  BottleImpl tmp(nullptr);
672  if (alt == this) {
673  tmp.fromString(toString());
674  src = &tmp;
675  }
676 
677  clear();
678 
679  const size_t last = src->size() - 1;
680  for (size_t i = 0; (i < len) && (first + i <= last); ++i) {
681  add(src->get(first + i).cloneStorable());
682  }
683 }
684 
686 {
687  if (ro) {
688  yCFatal(BOTTLEIMPL, "Attempted to modify the null bottle");
689  }
690  if (invalid) {
691  invalid = false;
692  }
693 }
694 
695 Value& BottleImpl::findGroupBit(const std::string& key) const
696 {
697  for (size_t i = 0; i < size(); i++) {
698  Value* org = &(get(static_cast<int>(i)));
699  Value* cursor = org;
700  if (cursor->isList()) {
701  cursor = &(cursor->asList()->get(0));
702  }
703  if (key == cursor->toString()) {
704  return *org;
705  }
706  }
707  // return invalid object
708  return get(-1);
709 }
710 
711 Value& BottleImpl::findBit(const std::string& key) const
712 {
713  for (size_t i = 0; i < size(); i++) {
714  Value* org = &(get(static_cast<int>(i)));
715  Value* cursor = org;
716  bool nested = false;
717  if (cursor->isList()) {
718  Bottle* bot = cursor->asList();
719  cursor = &(bot->get(0));
720  nested = true;
721  }
722  if (key == cursor->toString()) {
723  if (nested) {
724  return org->asList()->get(1);
725  }
726  if ((parent != nullptr) && (parent->getMonitor() != nullptr)) {
727  SearchReport report;
728  report.key = key;
729  report.isFound = true;
730  if (size() == 2) {
731  report.value = get(static_cast<int>(i + 1)).toString();
732  }
733  if (parent != nullptr) {
734  parent->reportToMonitor(report);
735  }
736  }
737  return get(static_cast<int>(i + 1));
738  }
739  }
740  // return invalid object
741  if ((parent != nullptr) && (parent->getMonitor() != nullptr)) {
742  SearchReport report;
743  report.key = key;
744  parent->reportToMonitor(report);
745  }
746  return get(-1);
747 }
yarp::os::impl::BottleImpl::parent
Searchable * parent
Definition: BottleImpl.h:45
yarp::os::impl::BottleImpl::specialize
void specialize(std::int32_t subCode)
Definition: BottleImpl.cpp:561
yarp::os::Bottle
A simple collection of objects that can be described and transmitted in a portable way.
Definition: Bottle.h:73
yarp::os::impl::Storable::createByCode
static Storable * createByCode(std::int32_t id)
Definition: Storable.cpp:67
yarp::os::impl::Storable::fromStringNested
virtual void fromStringNested(const std::string &src)
Initialize from a string representation.
Definition: Storable.h:253
yarp::os::impl::BottleImpl::read
bool read(ConnectionReader &reader)
Definition: BottleImpl.cpp:450
yarp::os::impl::StoreDict
Key/value pairs.
Definition: Storable.h:1108
BottleImpl.h
yarp::os::impl::BottleImpl::edit
void edit()
Definition: BottleImpl.cpp:685
yarp::os::createVocab
constexpr yarp::conf::vocab32_t createVocab(char a, char b=0, char c=0, char d=0)
Definition: Vocab.h:22
yarp::os::impl::BottleImpl::addDict
yarp::os::Property & addDict()
Definition: BottleImpl.cpp:654
yarp::os::ConnectionWriter::appendBlock
virtual void appendBlock(const char *data, size_t len)=0
Send a block of data to the network connection.
yarp::os::impl::StreamConnectionReader::reset
void reset(yarp::os::InputStream &in, TwoWayStream *str, const Route &route, size_t len, bool textMode, bool bareMode=false)
Definition: StreamConnectionReader.cpp:49
yarp::os::impl::Storable::cloneStorable
virtual Storable * cloneStorable() const
Typed synonym for clone()
Definition: Storable.h:62
yarp::os::Searchable
A base class for nested structures that can be searched.
Definition: Searchable.h:69
yarp::os::impl::Storable::toStringNested
virtual std::string toStringNested() const
Create string representation, including any syntax that should wrap it such as braces or parentheses.
Definition: Storable.h:264
yarp::os::impl::BottleImpl::findBit
Value & findBit(const std::string &key) const
Definition: BottleImpl.cpp:711
yarp::os::impl::BottleImpl::isInt8
bool isInt8(int index)
Definition: BottleImpl.cpp:588
yarp::os::impl::StreamConnectionReader::expectInt32
std::int32_t expectInt32() override
Read a 32-bit integer from the network connection.
Definition: StreamConnectionReader.cpp:220
yarp::os::impl::BottleImpl::byteCount
size_t byteCount() const
Definition: BottleImpl.cpp:426
yarp::os::impl::BottleImpl
A flexible data format for holding a bunch of numbers and strings.
Definition: BottleImpl.h:36
numeric.h
yarp::os::impl::BottleImpl::BottleImpl
BottleImpl()
Definition: BottleImpl.cpp:36
yarp::os::impl::BottleImpl::fromBinary
void fromBinary(const char *text, size_t len)
Definition: BottleImpl.cpp:358
yarp::os::StringInputStream::add
void add(const std::string &txt)
Definition: StringInputStream.h:47
yarp::os::impl::StoreString
A string item.
Definition: Storable.h:920
yarp::os::impl::BottleImpl::size
size_type size() const
Definition: BottleImpl.cpp:328
yarp::os::impl::BottleImpl::~BottleImpl
virtual ~BottleImpl()
Definition: BottleImpl.cpp:57
yarp::os::impl::StreamConnectionReader::isError
bool isError() const override
Definition: StreamConnectionReader.cpp:347
yarp::os::impl::BottleImpl::onCommencement
void onCommencement()
Definition: BottleImpl.cpp:432
StreamConnectionReader.h
yarp::os::impl::StreamConnectionReader
Lets Readable objects read from the underlying InputStream associated with the connection between two...
Definition: StreamConnectionReader.h:42
yarp::os::Route
Information about a connection between two ports.
Definition: Route.h:32
yarp::os::impl::Storable
A single item in a Bottle.
Definition: Storable.h:47
LogComponent.h
StringInputStream.h
yarp::os::impl::BottleImpl::findGroupBit
Value & findGroupBit(const std::string &key) const
Definition: BottleImpl.cpp:695
yarp::os::impl::StoreVocab
A vocabulary item.
Definition: Storable.h:834
yarp::os::impl::BottleImpl::copyRange
void copyRange(const BottleImpl *alt, size_type first=0, size_type len=npos)
Definition: BottleImpl.cpp:661
yarp::os::impl::BottleImpl::isFloat32
bool isFloat32(int index)
Definition: BottleImpl.cpp:608
yarp::os::impl::Storable::asInt64
std::int64_t asInt64() const override
Get 64-bit integer value.
Definition: Storable.h:141
yarp::os::impl::BottleImpl::getBytes
const char * getBytes() const
Definition: BottleImpl.cpp:419
yarp::os::ConnectionWriter::isError
virtual bool isError() const =0
yarp::os::ConnectionReader::expectInt32
virtual std::int32_t expectInt32()=0
Read a 32-bit integer from the network connection.
yarp::os::impl::BottleImpl::pop
Storable * pop()
Definition: BottleImpl.cpp:628
yarp::os::Bottle::get
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
Definition: Bottle.cpp:249
yarp::os::ConnectionWriter
An interface for writing to a network connection.
Definition: ConnectionWriter.h:40
yarp::os::impl::BottleImpl::invalid
bool invalid
Definition: BottleImpl.h:174
yarp::os::impl::BottleImpl::fromString
void fromString(const std::string &line)
Definition: BottleImpl.cpp:193
yarp::os::impl::BottleImpl::write
bool write(ConnectionWriter &writer) const
Definition: BottleImpl.cpp:437
yarp::os::impl::BottleImpl::isComplete
static bool isComplete(const char *txt)
Definition: BottleImpl.cpp:258
yarp::os::Bytes::get
const char * get() const
Definition: Bytes.cpp:30
BufferedConnectionWriter.h
yarp::os::impl::BottleImpl::checkIndex
bool checkIndex(size_type index) const
Definition: BottleImpl.cpp:583
yarp::os::Bytes::length
size_t length() const
Definition: Bytes.cpp:25
yarp::os::ConnectionReader::isError
virtual bool isError() const =0
yarp::os::impl::StoreString::asString
std::string asString() const override
Get string value.
Definition: Storable.h:961
yarp::os::impl::StoreList
A nested list of items.
Definition: Storable.h:1043
yarp::os::impl::Storable::asList
yarp::os::Bottle * asList() const override
Get list value.
Definition: Storable.h:181
yarp::os::StringInputStream
An InputStream that reads from a string.
Definition: StringInputStream.h:25
yarp::os::Bytes
A simple abstraction for a block of bytes.
Definition: Bytes.h:28
yarp::os::impl::Storable::toString
std::string toString() const override=0
Return a standard text representation of the content of the object.
yarp::os::impl::BottleImpl::getSpecialization
int getSpecialization()
Definition: BottleImpl.cpp:567
yarp::os::impl::BottleImpl::subCode
std::int32_t subCode()
Definition: BottleImpl.cpp:578
yarp::os::impl::BottleImpl::isInt16
bool isInt16(int index)
Definition: BottleImpl.cpp:593
yarp::os::Value::isList
virtual bool isList() const
Checks if value is a list.
Definition: Value.cpp:165
yCAssert
#define yCAssert(component, x)
Definition: LogComponent.h:172
yarp::os::ConnectionReader
An interface for reading from a network connection.
Definition: ConnectionReader.h:40
yarp::os::impl::BottleImpl::toString
std::string toString() const
Definition: BottleImpl.cpp:315
yarp::os::impl::BottleImpl::setNested
void setNested(bool nested)
Definition: BottleImpl.cpp:572
yCError
#define yCError(component,...)
Definition: LogComponent.h:157
yarp::os::ConnectionWriter::isTextMode
virtual bool isTextMode() const =0
Check if the connection is text mode.
yarp::os::Value::getCode
virtual std::int32_t getCode() const
Get standard type code of value.
Definition: Value.cpp:377
yarp::os::impl::Storable::isInt64
bool isInt64() const override
Checks if value is a 64-bit integer.
Definition: Storable.h:136
yarp::os::ConnectionReader::expectText
virtual std::string expectText(const char terminatingChar='\n')=0
Read some text from the network connection.
MemoryOutputStream.h
yarp::os::impl::BottleImpl::isList
bool isList(int index)
Definition: BottleImpl.cpp:623
yarp::os::ConnectionReader::isTextMode
virtual bool isTextMode() const =0
Check if the connection is text mode.
yarp::os::impl::BottleImpl::isString
bool isString(int index)
Definition: BottleImpl.cpp:618
yarp::os::impl::Storable::asInt32
std::int32_t asInt32() const override
Get 32-bit integer value.
Definition: Storable.h:131
yarp::os::impl::BottleImpl::fromBytes
bool fromBytes(const yarp::os::Bytes &data)
Definition: BottleImpl.cpp:370
yarp::os::impl::Storable::writeRaw
virtual bool writeRaw(ConnectionWriter &connection) const =0
yarp::os::Value::asList
virtual Bottle * asList() const
Get list value.
Definition: Value.cpp:243
yarp::os::impl::BottleImpl::isInt64
bool isInt64(int index)
Definition: BottleImpl.cpp:603
yCTrace
#define yCTrace(component,...)
Definition: LogComponent.h:88
yarp::os::impl::BottleImpl::addList
yarp::os::Bottle & addList()
Definition: BottleImpl.cpp:647
yarp::os::impl::BottleImpl::ro
bool ro
Definition: BottleImpl.h:175
yarp::os::Value::toString
std::string toString() const override
Return a standard text representation of the content of the object.
Definition: Value.cpp:359
yarp::os::Value
A single value (typically within a Bottle).
Definition: Value.h:47
yarp::os::impl::StoreList::code
static const std::int32_t code
Definition: Storable.h:1070
yarp::os::impl::BottleImpl::size_type
size_t size_type
Definition: BottleImpl.h:38
UNIT_MASK
#define UNIT_MASK
Definition: Storable.h:21
YARP_OS_LOG_COMPONENT
#define YARP_OS_LOG_COMPONENT(name, name_string)
Definition: LogComponent.h:37
yarp::os::impl::BottleImpl::toBytes
void toBytes(yarp::os::Bytes &data)
Definition: BottleImpl.cpp:411
yarp::os::impl::subCoder
std::int32_t subCoder(T &content)
Definition: Storable.h:1167
yarp::os::impl::Storable::readRaw
virtual bool readRaw(ConnectionReader &connection)=0
yarp::os::ConnectionWriter::appendText
virtual void appendText(const std::string &str, const char terminate='\n')=0
Send a terminated string to the network connection.
yarp::os::impl::BottleImpl::isFloat64
bool isFloat64(int index)
Definition: BottleImpl.cpp:613
yarp::os::impl::BottleImpl::isInt32
bool isInt32(int index)
Definition: BottleImpl.cpp:598
yarp::os::impl::BottleImpl::clear
void clear()
Definition: BottleImpl.cpp:70
yarp::os::impl::BottleImpl::getNull
static StoreNull & getNull()
Definition: BottleImpl.h:158
yarp::os::Property
A class for storing options and configuration information.
Definition: Property.h:37
yarp::os::impl::StoreNull
An empty item.
Definition: Storable.h:289
yarp::os::impl::Storable::isList
bool isList() const override
Checks if value is a list.
Definition: Storable.h:176
yarp::os::impl::BottleImpl::get
Storable & get(size_type index) const
Definition: BottleImpl.cpp:642
yCFatal
#define yCFatal(component,...)
Definition: LogComponent.h:168