YARP
Yet Another Robot Platform
Storable.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3  * SPDX-FileCopyrightText: 2006-2010 RobotCub Consortium
4  * SPDX-FileCopyrightText: 2006, 2008 Arjan Gijsberts
5  * SPDX-License-Identifier: BSD-3-Clause
6  */
7 
8 #ifndef YARP_OS_IMPL_STORABLE_H
9 #define YARP_OS_IMPL_STORABLE_H
10 
11 
12 #include <yarp/os/Log.h>
13 #include <yarp/os/LogComponent.h>
14 #include <yarp/os/Value.h>
15 #include <yarp/os/Vocab.h>
16 
17 
18 #define UNIT_MASK \
19  (BOTTLE_TAG_INT8 | \
20  BOTTLE_TAG_INT16 | \
21  BOTTLE_TAG_INT32 | \
22  BOTTLE_TAG_INT64 | \
23  BOTTLE_TAG_FLOAT32 | \
24  BOTTLE_TAG_FLOAT64 | \
25  BOTTLE_TAG_VOCAB32 | \
26  BOTTLE_TAG_STRING | \
27  BOTTLE_TAG_BLOB)
28 
29 #define GROUP_MASK \
30  (BOTTLE_TAG_LIST | \
31  BOTTLE_TAG_DICT)
32 
34 
35 namespace yarp {
36 namespace os {
37 namespace impl {
38 
44 {
45 public:
49  virtual ~Storable();
50 
54  virtual Storable* createStorable() const = 0;
55 
59  virtual Storable* cloneStorable() const
60  {
61  Storable* item = createStorable();
62  yCAssert(STORABLE, item != nullptr);
63  item->copy(*this);
64  return item;
65  }
66 
70  virtual void copy(const Storable& alt) = 0;
71 
72  bool operator==(const yarp::os::Value& alt) const;
73 
74  yarp::os::Value* create() const override
75  {
76  return createStorable();
77  }
78 
79  yarp::os::Value* clone() const override
80  {
81  return cloneStorable();
82  }
83 
84  static Storable* createByCode(std::int32_t id);
85 
86 
87  bool read(ConnectionReader& connection) override;
88  bool write(ConnectionWriter& connection) const override;
89 
90  virtual bool readRaw(ConnectionReader& connection) = 0;
91  virtual bool writeRaw(ConnectionWriter& connection) const = 0;
92 
93  bool isBool() const override
94  {
95  return false;
96  }
97 
98  bool asBool() const override
99  {
100  return false;
101  }
102 
103  bool isInt8() const override
104  {
105  return false;
106  }
107 
108  std::int8_t asInt8() const override
109  {
110  return 0;
111  }
112 
113  bool isInt16() const override
114  {
115  return false;
116  }
117 
118  std::int16_t asInt16() const override
119  {
120  return 0;
121  }
122 
123  bool isInt32() const override
124  {
125  return false;
126  }
127 
128  std::int32_t asInt32() const override
129  {
130  return 0;
131  }
132 
133  bool isInt64() const override
134  {
135  return false;
136  }
137 
138  std::int64_t asInt64() const override
139  {
140  return 0;
141  }
142 
143  bool isFloat32() const override
144  {
145  return false;
146  }
147 
149  {
150  return 0.0f;
151  }
152 
153  bool isFloat64() const override
154  {
155  return false;
156  }
157 
159  {
160  return 0.0;
161  }
162 
163  bool isString() const override
164  {
165  return false;
166  }
167 
168  std::string asString() const override
169  {
170  return {};
171  }
172 
173  bool isList() const override
174  {
175  return false;
176  }
177 
178  yarp::os::Bottle* asList() const override
179  {
180  return nullptr;
181  }
182 
183  bool isDict() const override
184  {
185  return false;
186  }
187 
188  yarp::os::Property* asDict() const override
189  {
190  return nullptr;
191  }
192 
193  bool isVocab32() const override
194  {
195  return false;
196  }
197 
199  {
200  return 0;
201  }
202 
203  bool isBlob() const override
204  {
205  return false;
206  }
207 
208  const char* asBlob() const override
209  {
210  return static_cast<const char*>(nullptr);
211  }
212 
213  size_t asBlobLength() const override
214  {
215  return 0;
216  }
217 
218  bool isNull() const override
219  {
220  return false;
221  }
222 
223 
224  Searchable* asSearchable() const override
225  {
226  if (isDict()) {
227  return asDict();
228  }
229  return asList();
230  }
232  bool check(const std::string& key) const override;
233 
234  yarp::os::Value& find(const std::string& key) const override;
235  yarp::os::Bottle& findGroup(const std::string& key) const override;
236 
237 
243  virtual void fromString(const std::string& src) = 0;
244 
250  virtual void fromStringNested(const std::string& src)
251  {
252  fromString(src);
253  }
254 
255  std::string toString() const override = 0;
256 
261  virtual std::string toStringNested() const
262  {
263  return toString();
264  }
265 
269  virtual std::int32_t subCode() const
270  {
271  return 0;
272  }
273 
274  bool isLeaf() const override
275  {
276  return true;
277  }
278 };
279 
280 
285  public Storable
286 {
287 public:
288  StoreNull() = default;
289 
290  Storable* createStorable() const override
291  {
292  return new StoreNull();
293  }
294 
295  void copy(const Storable& alt) override
296  {
297  YARP_UNUSED(alt);
298  }
299 
300  std::string toString() const override
301  {
302  return {};
303  }
304 
305  void fromString(const std::string& src) override
306  {
307  YARP_UNUSED(src);
308  }
309 
310  std::int32_t getCode() const override
311  {
312  return -1;
313  }
314 
315  bool readRaw(ConnectionReader& connection) override
316  {
317  YARP_UNUSED(connection);
318  return false;
319  }
320 
321  bool writeRaw(ConnectionWriter& connection) const override
322  {
323  YARP_UNUSED(connection);
324  return false;
325  }
326 
327  bool isNull() const override
328  {
329  return true;
330  }
331 };
332 
333 
338  public Storable
339 {
340 private:
341  std::int8_t x{0};
342 
343 public:
344  StoreInt8() = default;
345 
346  StoreInt8(std::int8_t x) :
347  x(x)
348  {
349  }
350 
351  Storable* createStorable() const override
352  {
353  return new StoreInt8();
354  }
355 
356  void copy(const Storable& alt) override
357  {
358  x = alt.asInt8();
359  }
360 
361  std::string toString() const override;
362  void fromString(const std::string& src) override;
363 
364  static const std::int32_t code;
365  std::int32_t getCode() const override
366  {
367  return code;
368  }
369 
370  bool readRaw(ConnectionReader& reader) override;
371  bool writeRaw(ConnectionWriter& writer) const override;
372 
373  bool isInt8() const override
374  {
375  return true;
376  }
377 
378  bool asBool() const override
379  {
380  return x != 0;
381  }
382 
383  std::int8_t asInt8() const override
384  {
385  return x;
386  }
387 
388  std::int16_t asInt16() const override
389  {
390  return x;
391  }
392 
393  std::int32_t asInt32() const override
394  {
395  return x;
396  }
397 
398  std::int64_t asInt64() const override
399  {
400  return x;
401  }
402 
404  {
405  return x;
406  }
407 
409  {
410  return x;
411  }
412 
414  {
415  return x;
416  }
417 };
418 
419 
424  public Storable
425 {
426 private:
427  std::int16_t x{0};
428 
429 public:
430  StoreInt16() = default;
431 
432  StoreInt16(std::int16_t x) :
433  x(x)
434  {
435  }
436 
437  Storable* createStorable() const override
438  {
439  return new StoreInt16();
440  }
441 
442  void copy(const Storable& alt) override
443  {
444  x = alt.asInt16();
445  }
446 
447  std::string toString() const override;
448  void fromString(const std::string& src) override;
449 
450  static const std::int32_t code;
451  std::int32_t getCode() const override
452  {
453  return code;
454  }
455 
456  bool readRaw(ConnectionReader& reader) override;
457  bool writeRaw(ConnectionWriter& writer) const override;
458 
459  bool isInt16() const override
460  {
461  return true;
462  }
463 
464  bool asBool() const override
465  {
466  return x != 0;
467  }
468 
469  std::int8_t asInt8() const override
470  {
471  return static_cast<std::int8_t>(x);
472  }
473 
474  std::int16_t asInt16() const override
475  {
476  return x;
477  }
478 
479  std::int32_t asInt32() const override
480  {
481  return x;
482  }
483 
484  std::int64_t asInt64() const override
485  {
486  return x;
487  }
488 
490  {
491  return x;
492  }
493 
495  {
496  return x;
497  }
498 
500  {
501  return x;
502  }
503 };
504 
505 
510  public Storable
511 {
512 private:
513  std::int32_t x{0};
514 
515 public:
516  StoreInt32() = default;
517 
518  StoreInt32(std::int32_t x) :
519  x(x)
520  {
521  }
522 
523  Storable* createStorable() const override
524  {
525  return new StoreInt32();
526  }
527 
528  void copy(const Storable& alt) override
529  {
530  x = alt.asInt32();
531  }
532 
533  std::string toString() const override;
534  void fromString(const std::string& src) override;
535 
536  static const std::int32_t code;
537  std::int32_t getCode() const override
538  {
539  return code;
540  }
541 
542  bool readRaw(ConnectionReader& reader) override;
543  bool writeRaw(ConnectionWriter& writer) const override;
544 
545  std::int8_t asInt8() const override
546  {
547  return static_cast<std::int8_t>(x);
548  }
549 
550  bool asBool() const override
551  {
552  return x != 0;
553  }
554 
555  std::int16_t asInt16() const override
556  {
557  return static_cast<std::int16_t>(x);
558  }
559 
560  bool isInt32() const override
561  {
562  return true;
563  }
564 
565  std::int32_t asInt32() const override
566  {
567  return x;
568  }
569 
570  std::int64_t asInt64() const override
571  {
572  return x;
573  }
574 
576  {
577  return static_cast<yarp::conf::float32_t>(x);
578  }
579 
581  {
582  return x;
583  }
584 
586  {
587  return x;
588  }
589 };
590 
595  public Storable
596 {
597 private:
598  std::int64_t x{0};
599 
600 public:
601  StoreInt64() = default;
602 
603  StoreInt64(std::int64_t x) :
604  x(x)
605  {
606  }
607 
608  Storable* createStorable() const override
609  {
610  return new StoreInt64();
611  }
612 
613  void copy(const Storable& alt) override
614  {
615  x = alt.asInt64();
616  }
617 
618  std::string toString() const override;
619  void fromString(const std::string& src) override;
620 
621  static const std::int32_t code;
622  std::int32_t getCode() const override
623  {
624  return code;
625  }
626 
627  bool readRaw(ConnectionReader& reader) override;
628  bool writeRaw(ConnectionWriter& writer) const override;
629 
630  bool isInt64() const override
631  {
632  return true;
633  }
634 
635  bool asBool() const override
636  {
637  return x != 0;
638  }
639 
640  std::int8_t asInt8() const override
641  {
642  return static_cast<std::int8_t>(x);
643  }
644 
645  std::int16_t asInt16() const override
646  {
647  return static_cast<std::int16_t>(x);
648  }
649 
650  std::int32_t asInt32() const override
651  {
652  return static_cast<std::int32_t>(x);
653  }
654 
655  std::int64_t asInt64() const override
656  {
657  return x;
658  }
659 
661  {
662  return static_cast<yarp::conf::float32_t>(x);
663  }
664 
666  {
667  return static_cast<yarp::conf::float64_t>(x);
668  }
669 
671  {
672  return static_cast<yarp::conf::vocab32_t>(x);
673  }
674 };
675 
680  public Storable
681 {
682 private:
683  yarp::conf::float32_t x{0.0f};
684 
685 public:
686  StoreFloat32() = default;
687 
689  x(x)
690  {
691  }
692 
693  Storable* createStorable() const override
694  {
695  return new StoreFloat32();
696  }
697 
698  void copy(const Storable& alt) override
699  {
700  x = alt.asFloat32();
701  }
702 
703  std::string toString() const override;
704  void fromString(const std::string& src) override;
705 
706  static const std::int32_t code;
707  std::int32_t getCode() const override
708  {
709  return code;
710  }
711 
712  bool readRaw(ConnectionReader& reader) override;
713  bool writeRaw(ConnectionWriter& writer) const override;
714 
715  bool isFloat32() const override
716  {
717  return true;
718  }
719 
720  std::int8_t asInt8() const override
721  {
722  return static_cast<std::int8_t>(x);
723  }
724 
725  std::int16_t asInt16() const override
726  {
727  return static_cast<std::int16_t>(x);
728  }
729 
730  std::int32_t asInt32() const override
731  {
732  return static_cast<std::int32_t>(x);
733  }
734 
735  std::int64_t asInt64() const override
736  {
737  return static_cast<std::int64_t>(x);
738  }
739 
741  {
742  return x;
743  }
744 
746  {
747  return x;
748  }
749 };
750 
755  public Storable
756 {
757 private:
758  yarp::conf::float64_t x{0.0};
759 
760 public:
761  StoreFloat64() = default;
762 
764  x(x)
765  {
766  }
767 
768  Storable* createStorable() const override
769  {
770  return new StoreFloat64();
771  }
772 
773  void copy(const Storable& alt) override
774  {
775  x = alt.asFloat64();
776  }
777 
778  std::string toString() const override;
779  void fromString(const std::string& src) override;
780 
781  static const std::int32_t code;
782  std::int32_t getCode() const override
783  {
784  return code;
785  }
786 
787  bool readRaw(ConnectionReader& reader) override;
788  bool writeRaw(ConnectionWriter& writer) const override;
789 
790  bool isFloat64() const override
791  {
792  return true;
793  }
794 
795  std::int8_t asInt8() const override
796  {
797  return static_cast<std::int8_t>(x);
798  }
799 
800  std::int16_t asInt16() const override
801  {
802  return static_cast<std::int16_t>(x);
803  }
804 
805  std::int32_t asInt32() const override
806  {
807  return static_cast<std::int32_t>(x);
808  }
809 
810  std::int64_t asInt64() const override
811  {
812  return static_cast<std::int64_t>(x);
813  }
814 
816  {
817  return static_cast<yarp::conf::float32_t>(x);
818  }
819 
821  {
822  return x;
823  }
824 };
825 
830  public Storable
831 {
833 
834 public:
835  StoreVocab32() = default;
836 
838  x(x)
839  {
840  }
841 
842  Storable* createStorable() const override
843  {
844  return new StoreVocab32();
845  }
846 
847  void copy(const Storable& alt) override
848  {
849  x = alt.asVocab32();
850  }
851 
852  std::string toString() const override;
853  void fromString(const std::string& src) override;
854  std::string toStringNested() const override;
855  void fromStringNested(const std::string& src) override;
856 
857  static const std::int32_t code;
858  std::int32_t getCode() const override
859  {
860  return code;
861  }
862 
863  bool readRaw(ConnectionReader& reader) override;
864  bool writeRaw(ConnectionWriter& writer) const override;
865 
866  bool isBool() const override
867  {
868  return (x == 0 || x == '1');
869  }
870 
871  bool asBool() const override
872  {
873  return x != 0;
874  }
875 
876  std::int32_t asInt32() const override
877  {
878  return x;
879  }
880 
881  std::int64_t asInt64() const override
882  {
883  return x;
884  }
885 
887  {
888  return static_cast<yarp::conf::float32_t>(x);
889  }
890 
892  {
893  return x;
894  }
895 
896  bool isVocab32() const override
897  {
898  return true;
899  }
900 
902  {
903  return x;
904  }
905 
906  std::string asString() const override
907  {
908  return toString();
909  }
910 };
911 
916  public Storable
917 {
918 private:
920 
921 public:
922  StoreString() = default;
923 
924  StoreString(const std::string& x)
925  {
926  this->x = x;
927  }
928 
929  Storable* createStorable() const override
930  {
931  return new StoreString();
932  }
933 
934  void copy(const Storable& alt) override
935  {
936  x = alt.asString();
937  }
938 
939  std::string toString() const override;
940  void fromString(const std::string& src) override;
941  std::string toStringNested() const override;
942  void fromStringNested(const std::string& src) override;
943 
944  static const std::int32_t code;
945  std::int32_t getCode() const override
946  {
947  return code;
948  }
949 
950  bool readRaw(ConnectionReader& reader) override;
951  bool writeRaw(ConnectionWriter& writer) const override;
952 
953  bool isString() const override
954  {
955  return true;
956  }
957 
958  std::string asString() const override
959  {
960  return x;
961  }
962 
964  {
965  return yarp::os::Vocab32::encode(x);
966  }
967 
968  // Quote and escape a string for printing it nested
969  static std::string quotedString(const std::string& x);
970 };
971 
976  public Storable
977 {
978 private:
980 
981 public:
982  StoreBlob() = default;
983 
984  StoreBlob(const std::string& x)
985  {
986  this->x = x;
987  }
988 
989  Storable* createStorable() const override
990  {
991  return new StoreBlob();
992  }
993 
994  void copy(const Storable& alt) override
995  {
996  if (alt.isBlob()) {
997  std::string tmp((char*)alt.asBlob(), alt.asBlobLength());
998  x = tmp;
999  } else {
1000  x = std::string();
1001  }
1002  }
1003 
1004  std::string toString() const override;
1005  void fromString(const std::string& src) override;
1006  std::string toStringNested() const override;
1007  void fromStringNested(const std::string& src) override;
1008 
1009  static const std::int32_t code;
1010  std::int32_t getCode() const override
1011  {
1012  return code;
1013  }
1014 
1015  bool readRaw(ConnectionReader& reader) override;
1016  bool writeRaw(ConnectionWriter& writer) const override;
1017 
1018  bool isBlob() const override
1019  {
1020  return true;
1021  }
1022 
1023  const char* asBlob() const override
1024  {
1025  return x.c_str();
1026  }
1027 
1028  size_t asBlobLength() const override
1029  {
1030  return x.length();
1031  }
1032 };
1033 
1034 
1039  public Storable
1040 {
1041 private:
1042  yarp::os::Bottle content{};
1043 
1044 public:
1045  StoreList() = default;
1046 
1047  Storable* createStorable() const override
1048  {
1049  return new StoreList();
1050  }
1051 
1052  void copy(const Storable& alt) override
1053  {
1054  content = *(alt.asList());
1055  }
1056 
1057  yarp::os::Bottle& internal()
1058  {
1059  return content;
1060  }
1061 
1062  std::string toString() const override;
1063  void fromString(const std::string& src) override;
1064  std::string toStringNested() const override;
1065  void fromStringNested(const std::string& src) override;
1066 
1067  static const std::int32_t code;
1068  std::int32_t getCode() const override
1069  {
1070  return code + subCode();
1071  }
1072 
1073  bool readRaw(ConnectionReader& reader) override;
1074  bool writeRaw(ConnectionWriter& writer) const override;
1075 
1076  bool isList() const override
1077  {
1078  return true;
1079  }
1080 
1081  yarp::os::Bottle* asList() const override
1082  {
1083  return (yarp::os::Bottle*)(&content);
1084  }
1085 
1086  std::int32_t subCode() const override;
1087 
1088  yarp::os::Value& find(const std::string& key) const override
1089  {
1090  return content.find(key);
1091  }
1092 
1093  yarp::os::Bottle& findGroup(const std::string& key) const override
1094  {
1095  return content.findGroup(key);
1096  }
1097 };
1098 
1099 
1104  public Storable
1105 {
1106 private:
1107  yarp::os::Property content{};
1108 
1109 public:
1110  StoreDict() = default;
1111 
1112  Storable* createStorable() const override
1113  {
1114  return new StoreDict();
1115  }
1116 
1117  void copy(const Storable& alt) override
1118  {
1119  content = *(alt.asDict());
1120  }
1121 
1123  {
1124  return content;
1125  }
1126 
1127  std::string toString() const override;
1128  void fromString(const std::string& src) override;
1129  std::string toStringNested() const override;
1130  void fromStringNested(const std::string& src) override;
1131 
1132  static const std::int32_t code;
1133  std::int32_t getCode() const override
1134  {
1135  return code;
1136  }
1137 
1138  bool readRaw(ConnectionReader& reader) override;
1139  bool writeRaw(ConnectionWriter& writer) const override;
1140 
1141  bool isDict() const override
1142  {
1143  return true;
1144  }
1145 
1146  yarp::os::Property* asDict() const override
1147  {
1148  return const_cast<yarp::os::Property*>(&content);
1149  }
1150 
1151  yarp::os::Value& find(const std::string& key) const override
1152  {
1153  return content.find(key);
1154  }
1155 
1156  yarp::os::Bottle& findGroup(const std::string& key) const override
1157  {
1158  return content.findGroup(key);
1159  }
1160 };
1161 
1162 
1163 template <typename T>
1164 inline std::int32_t subCoder(T& content)
1165 {
1166  std::int32_t c = -1;
1167  bool ok = false;
1168  for (unsigned int i = 0; i < content.size(); ++i) {
1169  std::int32_t sc = content.get(i).getCode();
1170  if (c == -1) {
1171  c = sc;
1172  ok = true;
1173  }
1174  if (sc != c) {
1175  ok = false;
1176  }
1177  }
1178  // just optimize primitive types
1179  if ((c & GROUP_MASK) != 0) {
1180  ok = false;
1181  }
1182  c = ok ? c : 0;
1183  content.specialize(c);
1184  return c;
1185 }
1186 
1187 } // namespace impl
1188 } // namespace os
1189 } // namespace yarp
1190 
1191 #endif // YARP_OS_IMPL_STORABLE_H
#define GROUP_MASK
Definition: Storable.h:29
const yarp::os::LogComponent & STORABLE()
Definition: Storable.cpp:42
A simple collection of objects that can be described and transmitted in a portable way.
Definition: Bottle.h:74
Bottle & findGroup(const std::string &key) const override
Gets a list corresponding to a given keyword.
Definition: Bottle.cpp:302
An interface for reading from a network connection.
An interface for writing to a network connection.
A class for storing options and configuration information.
Definition: Property.h:34
A base class for nested structures that can be searched.
Definition: Searchable.h:66
virtual bool check(const std::string &key) const =0
Check if there exists a property of the given name.
A single value (typically within a Bottle).
Definition: Value.h:45
Value & find(const std::string &key) const override
Gets a value corresponding to a given keyword.
Definition: Value.cpp:327
A single item in a Bottle.
Definition: Storable.h:44
const char * asBlob() const override
Get binary data value.
Definition: Storable.h:208
size_t asBlobLength() const override
Get binary data length.
Definition: Storable.h:213
virtual std::string toStringNested() const
Create string representation, including any syntax that should wrap it such as braces or parentheses.
Definition: Storable.h:261
std::int8_t asInt8() const override
Get 8-bit integer value.
Definition: Storable.h:108
virtual ~Storable()
Destructor.
std::int64_t asInt64() const override
Get 64-bit integer value.
Definition: Storable.h:138
bool isVocab32() const override
Checks if value is a vocabulary identifier.
Definition: Storable.h:193
virtual Storable * cloneStorable() const
Typed synonym for clone()
Definition: Storable.h:59
bool isList() const override
Checks if value is a list.
Definition: Storable.h:173
yarp::os::Property * asDict() const override
Get dictionary (hash table) value.
Definition: Storable.h:188
bool isInt16() const override
Checks if value is a 16-bit integer.
Definition: Storable.h:113
yarp::conf::float64_t asFloat64() const override
Get 64-bit floating point value.
Definition: Storable.h:158
virtual bool writeRaw(ConnectionWriter &connection) const =0
yarp::os::Value * clone() const override
Create a copy of the value.
Definition: Storable.h:79
virtual Storable * createStorable() const =0
Factory method.
bool isNull() const override
Checks if the object is invalid.
Definition: Storable.h:218
std::string asString() const override
Get string value.
Definition: Storable.h:168
bool isDict() const override
Checks if value is a dictionary.
Definition: Storable.h:183
bool isBlob() const override
Checks if value is a binary object.
Definition: Storable.h:203
virtual void fromStringNested(const std::string &src)
Initialize from a string representation.
Definition: Storable.h:250
virtual void fromString(const std::string &src)=0
Initialize from a string representation, assuming that any syntax around this representation such as ...
yarp::conf::float32_t asFloat32() const override
Get 32-bit floating point value.
Definition: Storable.h:148
bool isFloat32() const override
Checks if value is a 32-bit floating point number.
Definition: Storable.h:143
bool isBool() const override
Checks if value is a boolean.
Definition: Storable.h:93
yarp::os::Value * create() const override
Create a new value of the same type.
Definition: Storable.h:74
std::string toString() const override=0
Return a standard text representation of the content of the object.
yarp::os::Bottle * asList() const override
Get list value.
Definition: Storable.h:178
virtual std::int32_t subCode() const
Return a code describing this item, used in serializing bottles.
Definition: Storable.h:269
bool asBool() const override
Get boolean value.
Definition: Storable.h:98
bool isString() const override
Checks if value is a string.
Definition: Storable.h:163
virtual void copy(const Storable &alt)=0
Become a copy of the passed item.
bool isInt32() const override
Checks if value is a 32-bit integer.
Definition: Storable.h:123
bool isInt8() const override
Checks if value is a 8-bit integer.
Definition: Storable.h:103
yarp::conf::vocab32_t asVocab32() const override
Get vocabulary identifier as an integer.
Definition: Storable.h:198
Searchable * asSearchable() const override
Get dictionary or list value.
Definition: Storable.h:224
bool isInt64() const override
Checks if value is a 64-bit integer.
Definition: Storable.h:133
virtual bool readRaw(ConnectionReader &connection)=0
bool isLeaf() const override
Definition: Storable.h:274
bool isFloat64() const override
Checks if value is a 64-bit floating point number.
Definition: Storable.h:153
std::int16_t asInt16() const override
Get 16-bit integer value.
Definition: Storable.h:118
std::int32_t asInt32() const override
Get 32-bit integer value.
Definition: Storable.h:128
A binary blob item.
Definition: Storable.h:977
bool isBlob() const override
Checks if value is a binary object.
Definition: Storable.h:1018
const char * asBlob() const override
Get binary data value.
Definition: Storable.h:1023
size_t asBlobLength() const override
Get binary data length.
Definition: Storable.h:1028
Storable * createStorable() const override
Factory method.
Definition: Storable.h:989
static const std::int32_t code
Definition: Storable.h:1009
StoreBlob(const std::string &x)
Definition: Storable.h:984
void copy(const Storable &alt) override
Become a copy of the passed item.
Definition: Storable.h:994
std::int32_t getCode() const override
Get standard type code of value.
Definition: Storable.h:1010
Key/value pairs.
Definition: Storable.h:1105
yarp::os::Value & find(const std::string &key) const override
Gets a value corresponding to a given keyword.
Definition: Storable.h:1151
yarp::os::Property * asDict() const override
Get dictionary (hash table) value.
Definition: Storable.h:1146
void copy(const Storable &alt) override
Become a copy of the passed item.
Definition: Storable.h:1117
bool isDict() const override
Checks if value is a dictionary.
Definition: Storable.h:1141
std::int32_t getCode() const override
Get standard type code of value.
Definition: Storable.h:1133
static const std::int32_t code
Definition: Storable.h:1132
yarp::os::Bottle & findGroup(const std::string &key) const override
Gets a list corresponding to a given keyword.
Definition: Storable.h:1156
Storable * createStorable() const override
Factory method.
Definition: Storable.h:1112
A 32-bit floating point number item.
Definition: Storable.h:681
yarp::conf::float64_t asFloat64() const override
Get 64-bit floating point value.
Definition: Storable.h:745
yarp::conf::float32_t asFloat32() const override
Get 32-bit floating point value.
Definition: Storable.h:740
bool isFloat32() const override
Checks if value is a 32-bit floating point number.
Definition: Storable.h:715
void copy(const Storable &alt) override
Become a copy of the passed item.
Definition: Storable.h:698
std::int8_t asInt8() const override
Get 8-bit integer value.
Definition: Storable.h:720
std::int64_t asInt64() const override
Get 64-bit integer value.
Definition: Storable.h:735
std::int32_t getCode() const override
Get standard type code of value.
Definition: Storable.h:707
static const std::int32_t code
Definition: Storable.h:706
std::int16_t asInt16() const override
Get 16-bit integer value.
Definition: Storable.h:725
StoreFloat32(yarp::conf::float32_t x)
Definition: Storable.h:688
std::int32_t asInt32() const override
Get 32-bit integer value.
Definition: Storable.h:730
Storable * createStorable() const override
Factory method.
Definition: Storable.h:693
A 64-bit floating point number item.
Definition: Storable.h:756
StoreFloat64(yarp::conf::float64_t x)
Definition: Storable.h:763
std::int16_t asInt16() const override
Get 16-bit integer value.
Definition: Storable.h:800
std::int64_t asInt64() const override
Get 64-bit integer value.
Definition: Storable.h:810
bool isFloat64() const override
Checks if value is a 64-bit floating point number.
Definition: Storable.h:790
std::int32_t asInt32() const override
Get 32-bit integer value.
Definition: Storable.h:805
Storable * createStorable() const override
Factory method.
Definition: Storable.h:768
std::int8_t asInt8() const override
Get 8-bit integer value.
Definition: Storable.h:795
yarp::conf::float64_t asFloat64() const override
Get 64-bit floating point value.
Definition: Storable.h:820
void copy(const Storable &alt) override
Become a copy of the passed item.
Definition: Storable.h:773
static const std::int32_t code
Definition: Storable.h:781
yarp::conf::float32_t asFloat32() const override
Get 32-bit floating point value.
Definition: Storable.h:815
std::int32_t getCode() const override
Get standard type code of value.
Definition: Storable.h:782
A 16-bit integer item.
Definition: Storable.h:425
yarp::conf::vocab32_t asVocab32() const override
Get vocabulary identifier as an integer.
Definition: Storable.h:499
yarp::conf::float32_t asFloat32() const override
Get 32-bit floating point value.
Definition: Storable.h:489
bool asBool() const override
Get boolean value.
Definition: Storable.h:464
std::int32_t getCode() const override
Get standard type code of value.
Definition: Storable.h:451
void copy(const Storable &alt) override
Become a copy of the passed item.
Definition: Storable.h:442
static const std::int32_t code
Definition: Storable.h:450
yarp::conf::float64_t asFloat64() const override
Get 64-bit floating point value.
Definition: Storable.h:494
std::int8_t asInt8() const override
Get 8-bit integer value.
Definition: Storable.h:469
std::int32_t asInt32() const override
Get 32-bit integer value.
Definition: Storable.h:479
bool isInt16() const override
Checks if value is a 16-bit integer.
Definition: Storable.h:459
Storable * createStorable() const override
Factory method.
Definition: Storable.h:437
std::int16_t asInt16() const override
Get 16-bit integer value.
Definition: Storable.h:474
StoreInt16(std::int16_t x)
Definition: Storable.h:432
std::int64_t asInt64() const override
Get 64-bit integer value.
Definition: Storable.h:484
A 32-bit integer item.
Definition: Storable.h:511
std::int32_t getCode() const override
Get standard type code of value.
Definition: Storable.h:537
yarp::conf::float32_t asFloat32() const override
Get 32-bit floating point value.
Definition: Storable.h:575
StoreInt32(std::int32_t x)
Definition: Storable.h:518
bool isInt32() const override
Checks if value is a 32-bit integer.
Definition: Storable.h:560
yarp::conf::float64_t asFloat64() const override
Get 64-bit floating point value.
Definition: Storable.h:580
std::int8_t asInt8() const override
Get 8-bit integer value.
Definition: Storable.h:545
std::int32_t asInt32() const override
Get 32-bit integer value.
Definition: Storable.h:565
bool asBool() const override
Get boolean value.
Definition: Storable.h:550
yarp::conf::vocab32_t asVocab32() const override
Get vocabulary identifier as an integer.
Definition: Storable.h:585
std::int64_t asInt64() const override
Get 64-bit integer value.
Definition: Storable.h:570
static const std::int32_t code
Definition: Storable.h:536
Storable * createStorable() const override
Factory method.
Definition: Storable.h:523
std::int16_t asInt16() const override
Get 16-bit integer value.
Definition: Storable.h:555
void copy(const Storable &alt) override
Become a copy of the passed item.
Definition: Storable.h:528
A 64-bit integer item.
Definition: Storable.h:596
std::int32_t getCode() const override
Get standard type code of value.
Definition: Storable.h:622
static const std::int32_t code
Definition: Storable.h:621
std::int8_t asInt8() const override
Get 8-bit integer value.
Definition: Storable.h:640
bool asBool() const override
Get boolean value.
Definition: Storable.h:635
std::int64_t asInt64() const override
Get 64-bit integer value.
Definition: Storable.h:655
void copy(const Storable &alt) override
Become a copy of the passed item.
Definition: Storable.h:613
yarp::conf::float64_t asFloat64() const override
Get 64-bit floating point value.
Definition: Storable.h:665
Storable * createStorable() const override
Factory method.
Definition: Storable.h:608
yarp::conf::vocab32_t asVocab32() const override
Get vocabulary identifier as an integer.
Definition: Storable.h:670
std::int16_t asInt16() const override
Get 16-bit integer value.
Definition: Storable.h:645
bool isInt64() const override
Checks if value is a 64-bit integer.
Definition: Storable.h:630
yarp::conf::float32_t asFloat32() const override
Get 32-bit floating point value.
Definition: Storable.h:660
StoreInt64(std::int64_t x)
Definition: Storable.h:603
std::int32_t asInt32() const override
Get 32-bit integer value.
Definition: Storable.h:650
A 8-bit integer item.
Definition: Storable.h:339
std::int32_t asInt32() const override
Get 32-bit integer value.
Definition: Storable.h:393
StoreInt8(std::int8_t x)
Definition: Storable.h:346
bool asBool() const override
Get boolean value.
Definition: Storable.h:378
static const std::int32_t code
Definition: Storable.h:364
yarp::conf::vocab32_t asVocab32() const override
Get vocabulary identifier as an integer.
Definition: Storable.h:413
void copy(const Storable &alt) override
Become a copy of the passed item.
Definition: Storable.h:356
std::int32_t getCode() const override
Get standard type code of value.
Definition: Storable.h:365
std::int8_t asInt8() const override
Get 8-bit integer value.
Definition: Storable.h:383
std::int16_t asInt16() const override
Get 16-bit integer value.
Definition: Storable.h:388
yarp::conf::float64_t asFloat64() const override
Get 64-bit floating point value.
Definition: Storable.h:408
std::int64_t asInt64() const override
Get 64-bit integer value.
Definition: Storable.h:398
Storable * createStorable() const override
Factory method.
Definition: Storable.h:351
bool isInt8() const override
Checks if value is a 8-bit integer.
Definition: Storable.h:373
yarp::conf::float32_t asFloat32() const override
Get 32-bit floating point value.
Definition: Storable.h:403
A nested list of items.
Definition: Storable.h:1040
yarp::os::Bottle * asList() const override
Get list value.
Definition: Storable.h:1081
void copy(const Storable &alt) override
Become a copy of the passed item.
Definition: Storable.h:1052
yarp::os::Bottle & findGroup(const std::string &key) const override
Gets a list corresponding to a given keyword.
Definition: Storable.h:1093
yarp::os::Value & find(const std::string &key) const override
Gets a value corresponding to a given keyword.
Definition: Storable.h:1088
bool isList() const override
Checks if value is a list.
Definition: Storable.h:1076
std::int32_t getCode() const override
Get standard type code of value.
Definition: Storable.h:1068
Storable * createStorable() const override
Factory method.
Definition: Storable.h:1047
static const std::int32_t code
Definition: Storable.h:1067
An empty item.
Definition: Storable.h:286
Storable * createStorable() const override
Factory method.
Definition: Storable.h:290
std::int32_t getCode() const override
Get standard type code of value.
Definition: Storable.h:310
std::string toString() const override
Return a standard text representation of the content of the object.
Definition: Storable.h:300
void copy(const Storable &alt) override
Become a copy of the passed item.
Definition: Storable.h:295
bool writeRaw(ConnectionWriter &connection) const override
Definition: Storable.h:321
bool readRaw(ConnectionReader &connection) override
Definition: Storable.h:315
void fromString(const std::string &src) override
Initialize from a string representation, assuming that any syntax around this representation such as ...
Definition: Storable.h:305
bool isNull() const override
Checks if the object is invalid.
Definition: Storable.h:327
yarp::conf::vocab32_t asVocab32() const override
Get vocabulary identifier as an integer.
Definition: Storable.h:963
StoreString(const std::string &x)
Definition: Storable.h:924
std::int32_t getCode() const override
Get standard type code of value.
Definition: Storable.h:945
Storable * createStorable() const override
Factory method.
Definition: Storable.h:929
void copy(const Storable &alt) override
Become a copy of the passed item.
Definition: Storable.h:934
std::string asString() const override
Get string value.
Definition: Storable.h:958
static const std::int32_t code
Definition: Storable.h:944
bool isString() const override
Checks if value is a string.
Definition: Storable.h:953
A vocabulary item.
Definition: Storable.h:831
yarp::conf::vocab32_t asVocab32() const override
Get vocabulary identifier as an integer.
Definition: Storable.h:901
std::int32_t getCode() const override
Get standard type code of value.
Definition: Storable.h:858
yarp::conf::float32_t asFloat32() const override
Get 32-bit floating point value.
Definition: Storable.h:886
std::string asString() const override
Get string value.
Definition: Storable.h:906
void copy(const Storable &alt) override
Become a copy of the passed item.
Definition: Storable.h:847
bool asBool() const override
Get boolean value.
Definition: Storable.h:871
std::int64_t asInt64() const override
Get 64-bit integer value.
Definition: Storable.h:881
Storable * createStorable() const override
Factory method.
Definition: Storable.h:842
yarp::conf::float64_t asFloat64() const override
Get 64-bit floating point value.
Definition: Storable.h:891
std::int32_t asInt32() const override
Get 32-bit integer value.
Definition: Storable.h:876
bool isVocab32() const override
Checks if value is a vocabulary identifier.
Definition: Storable.h:896
static const std::int32_t code
Definition: Storable.h:857
StoreVocab32(yarp::conf::vocab32_t x)
Definition: Storable.h:837
bool isBool() const override
Checks if value is a boolean.
Definition: Storable.h:866
std::string toString(const T &value)
convert an arbitrary type to string.
#define yCAssert(component, x)
Definition: LogComponent.h:169
#define YARP_DECLARE_LOG_COMPONENT(name)
Definition: LogComponent.h:74
std::int32_t vocab32_t
Definition: numeric.h:78
double float64_t
Definition: numeric.h:77
float float32_t
Definition: numeric.h:76
NetInt32 encode(const std::string &str)
Convert a string into a vocabulary identifier.
Definition: Vocab.cpp:11
std::int32_t subCoder(T &content)
Definition: Storable.h:1164
std::string findGroup(const robotinterface::ParamList &list, const std::string &name)
Definition: Types.cpp:47
bool read(ImageOf< PixelRgb > &dest, const std::string &src, image_fileformat format=FORMAT_ANY)
Definition: ImageFile.cpp:923
bool write(const ImageOf< PixelRgb > &src, const std::string &dest, image_fileformat format=FORMAT_PPM)
Definition: ImageFile.cpp:1099
The main, catch-all namespace for YARP.
Definition: dirs.h:16
#define YARP_SUPPRESS_DLL_INTERFACE_WARNING_ARG(x)
Suppress MSVC C4251 warning for the declaration.
Definition: system.h:336
#define YARP_UNUSED(var)
Definition: api.h:162
#define YARP_os_impl_API
Definition: api.h:46