YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
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>
14#include <yarp/os/Value.h>
15#include <yarp/os/Vocab.h>
16#include <yarp/os/Vocab64.h>
17
18
19#define UNIT_MASK \
20 (BOTTLE_TAG_INT8 | \
21 BOTTLE_TAG_INT16 | \
22 BOTTLE_TAG_INT32 | \
23 BOTTLE_TAG_INT64 | \
24 BOTTLE_TAG_FLOAT32 | \
25 BOTTLE_TAG_FLOAT64 | \
26 BOTTLE_TAG_VOCAB32 | \
27 BOTTLE_TAG_VOCAB64 | \
28 BOTTLE_TAG_STRING | \
29 BOTTLE_TAG_BLOB)
30
31#define GROUP_MASK \
32 (BOTTLE_TAG_LIST | \
33 BOTTLE_TAG_DICT)
34
36
37namespace yarp::os::impl {
38
44{
45public:
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
198 bool isVocab64() const override
199 {
200 return false;
201 }
202
204 {
205 return 0;
206 }
207
209 {
210 return 0;
211 }
212
213 bool isBlob() const override
214 {
215 return false;
216 }
217
218 const char* asBlob() const override
219 {
220 return static_cast<const char*>(nullptr);
221 }
222
223 size_t asBlobLength() const override
224 {
225 return 0;
226 }
227
228 bool isNull() const override
229 {
230 return false;
231 }
232
233
234 Searchable* asSearchable() const override
235 {
236 if (isDict()) {
237 return asDict();
238 }
239 return asList();
240 }
242 bool check(const std::string& key) const override;
243
244 yarp::os::Value& find(const std::string& key) const override;
245 yarp::os::Bottle& findGroup(const std::string& key) const override;
246
247
253 virtual void fromString(const std::string& src) = 0;
254
260 virtual void fromStringNested(const std::string& src)
261 {
262 fromString(src);
263 }
264
265 std::string toString() const override = 0;
266
271 virtual std::string toStringNested() const
272 {
273 return toString();
274 }
275
279 virtual std::int32_t subCode() const
280 {
281 return 0;
282 }
283
284 bool isLeaf() const override
285 {
286 return true;
287 }
288};
289
290
295 public Storable
296{
297public:
298 StoreNull() = default;
299
300 Storable* createStorable() const override
301 {
302 return new StoreNull();
303 }
304
305 void copy(const Storable& alt) override
306 {
308 }
309
310 std::string toString() const override
311 {
312 return {};
313 }
314
315 void fromString(const std::string& src) override
316 {
317 YARP_UNUSED(src);
318 }
319
320 std::int32_t getCode() const override
321 {
322 return -1;
323 }
324
325 bool readRaw(ConnectionReader& connection) override
326 {
327 YARP_UNUSED(connection);
328 return false;
329 }
330
331 bool writeRaw(ConnectionWriter& connection) const override
332 {
333 YARP_UNUSED(connection);
334 return false;
335 }
336
337 bool isNull() const override
338 {
339 return true;
340 }
341};
342
343
348 public Storable
349{
350private:
351 std::int8_t x{0};
352
353public:
354 StoreInt8() = default;
355
356 StoreInt8(std::int8_t x) :
357 x(x)
358 {
359 }
360
361 Storable* createStorable() const override
362 {
363 return new StoreInt8();
364 }
365
366 void copy(const Storable& alt) override
367 {
368 x = alt.asInt8();
369 }
370
371 std::string toString() const override;
372 void fromString(const std::string& src) override;
373
374 static const std::int32_t code;
375 std::int32_t getCode() const override
376 {
377 return code;
378 }
379
380 bool readRaw(ConnectionReader& reader) override;
381 bool writeRaw(ConnectionWriter& writer) const override;
382
383 bool isInt8() const override
384 {
385 return true;
386 }
387
388 bool asBool() const override
389 {
390 return x != 0;
391 }
392
393 std::int8_t asInt8() const override
394 {
395 return x;
396 }
397
398 std::int16_t asInt16() const override
399 {
400 return x;
401 }
402
403 std::int32_t asInt32() const override
404 {
405 return x;
406 }
407
408 std::int64_t asInt64() const override
409 {
410 return x;
411 }
412
414 {
415 return x;
416 }
417
419 {
420 return x;
421 }
422
424 {
425 return x;
426 }
427};
428
429
434 public Storable
435{
436private:
437 std::int16_t x{0};
438
439public:
440 StoreInt16() = default;
441
442 StoreInt16(std::int16_t x) :
443 x(x)
444 {
445 }
446
447 Storable* createStorable() const override
448 {
449 return new StoreInt16();
450 }
451
452 void copy(const Storable& alt) override
453 {
454 x = alt.asInt16();
455 }
456
457 std::string toString() const override;
458 void fromString(const std::string& src) override;
459
460 static const std::int32_t code;
461 std::int32_t getCode() const override
462 {
463 return code;
464 }
465
466 bool readRaw(ConnectionReader& reader) override;
467 bool writeRaw(ConnectionWriter& writer) const override;
468
469 bool isInt16() const override
470 {
471 return true;
472 }
473
474 bool asBool() const override
475 {
476 return x != 0;
477 }
478
479 std::int8_t asInt8() const override
480 {
481 return static_cast<std::int8_t>(x);
482 }
483
484 std::int16_t asInt16() const override
485 {
486 return x;
487 }
488
489 std::int32_t asInt32() const override
490 {
491 return x;
492 }
493
494 std::int64_t asInt64() const override
495 {
496 return x;
497 }
498
500 {
501 return x;
502 }
503
505 {
506 return x;
507 }
508
510 {
511 return x;
512 }
513};
514
515
520 public Storable
521{
522private:
523 std::int32_t x{0};
524
525public:
526 StoreInt32() = default;
527
528 StoreInt32(std::int32_t x) :
529 x(x)
530 {
531 }
532
533 Storable* createStorable() const override
534 {
535 return new StoreInt32();
536 }
537
538 void copy(const Storable& alt) override
539 {
540 x = alt.asInt32();
541 }
542
543 std::string toString() const override;
544 void fromString(const std::string& src) override;
545
546 static const std::int32_t code;
547 std::int32_t getCode() const override
548 {
549 return code;
550 }
551
552 bool readRaw(ConnectionReader& reader) override;
553 bool writeRaw(ConnectionWriter& writer) const override;
554
555 std::int8_t asInt8() const override
556 {
557 return static_cast<std::int8_t>(x);
558 }
559
560 bool asBool() const override
561 {
562 return x != 0;
563 }
564
565 std::int16_t asInt16() const override
566 {
567 return static_cast<std::int16_t>(x);
568 }
569
570 bool isInt32() const override
571 {
572 return true;
573 }
574
575 std::int32_t asInt32() const override
576 {
577 return x;
578 }
579
580 std::int64_t asInt64() const override
581 {
582 return x;
583 }
584
586 {
587 return static_cast<yarp::conf::float32_t>(x);
588 }
589
591 {
592 return x;
593 }
594
596 {
597 return x;
598 }
599};
600
605 public Storable
606{
607private:
608 std::int64_t x{0};
609
610public:
611 StoreInt64() = default;
612
613 StoreInt64(std::int64_t x) :
614 x(x)
615 {
616 }
617
618 Storable* createStorable() const override
619 {
620 return new StoreInt64();
621 }
622
623 void copy(const Storable& alt) override
624 {
625 x = alt.asInt64();
626 }
627
628 std::string toString() const override;
629 void fromString(const std::string& src) override;
630
631 static const std::int32_t code;
632 std::int32_t getCode() const override
633 {
634 return code;
635 }
636
637 bool readRaw(ConnectionReader& reader) override;
638 bool writeRaw(ConnectionWriter& writer) const override;
639
640 bool isInt64() const override
641 {
642 return true;
643 }
644
645 bool asBool() const override
646 {
647 return x != 0;
648 }
649
650 std::int8_t asInt8() const override
651 {
652 return static_cast<std::int8_t>(x);
653 }
654
655 std::int16_t asInt16() const override
656 {
657 return static_cast<std::int16_t>(x);
658 }
659
660 std::int32_t asInt32() const override
661 {
662 return static_cast<std::int32_t>(x);
663 }
664
665 std::int64_t asInt64() const override
666 {
667 return x;
668 }
669
671 {
672 return static_cast<yarp::conf::float32_t>(x);
673 }
674
676 {
677 return static_cast<yarp::conf::float64_t>(x);
678 }
679
681 {
682 return static_cast<yarp::conf::vocab32_t>(x);
683 }
684};
685
690 public Storable
691{
692private:
693 yarp::conf::float32_t x{0.0f};
694
695public:
696 StoreFloat32() = default;
697
699 x(x)
700 {
701 }
702
703 Storable* createStorable() const override
704 {
705 return new StoreFloat32();
706 }
707
708 void copy(const Storable& alt) override
709 {
710 x = alt.asFloat32();
711 }
712
713 std::string toString() const override;
714 void fromString(const std::string& src) override;
715
716 static const std::int32_t code;
717 std::int32_t getCode() const override
718 {
719 return code;
720 }
721
722 bool readRaw(ConnectionReader& reader) override;
723 bool writeRaw(ConnectionWriter& writer) const override;
724
725 bool isFloat32() const override
726 {
727 return true;
728 }
729
730 std::int8_t asInt8() const override
731 {
732 return static_cast<std::int8_t>(x);
733 }
734
735 std::int16_t asInt16() const override
736 {
737 return static_cast<std::int16_t>(x);
738 }
739
740 std::int32_t asInt32() const override
741 {
742 return static_cast<std::int32_t>(x);
743 }
744
745 std::int64_t asInt64() const override
746 {
747 return static_cast<std::int64_t>(x);
748 }
749
751 {
752 return x;
753 }
754
756 {
757 return x;
758 }
759};
760
765 public Storable
766{
767private:
769
770public:
771 StoreFloat64() = default;
772
774 x(x)
775 {
776 }
777
778 Storable* createStorable() const override
779 {
780 return new StoreFloat64();
781 }
782
783 void copy(const Storable& alt) override
784 {
785 x = alt.asFloat64();
786 }
787
788 std::string toString() const override;
789 void fromString(const std::string& src) override;
790
791 static const std::int32_t code;
792 std::int32_t getCode() const override
793 {
794 return code;
795 }
796
797 bool readRaw(ConnectionReader& reader) override;
798 bool writeRaw(ConnectionWriter& writer) const override;
799
800 bool isFloat64() const override
801 {
802 return true;
803 }
804
805 std::int8_t asInt8() const override
806 {
807 return static_cast<std::int8_t>(x);
808 }
809
810 std::int16_t asInt16() const override
811 {
812 return static_cast<std::int16_t>(x);
813 }
814
815 std::int32_t asInt32() const override
816 {
817 return static_cast<std::int32_t>(x);
818 }
819
820 std::int64_t asInt64() const override
821 {
822 return static_cast<std::int64_t>(x);
823 }
824
826 {
827 return static_cast<yarp::conf::float32_t>(x);
828 }
829
831 {
832 return x;
833 }
834};
835
840 public Storable
841{
843
844public:
845 StoreVocab32() = default;
846
848 x(x)
849 {
850 }
851
852 Storable* createStorable() const override
853 {
854 return new StoreVocab32();
855 }
856
857 void copy(const Storable& alt) override
858 {
859 x = alt.asVocab32();
860 }
861
862 std::string toString() const override;
863 void fromString(const std::string& src) override;
864 std::string toStringNested() const override;
865 void fromStringNested(const std::string& src) override;
866
867 static const std::int32_t code;
868 std::int32_t getCode() const override
869 {
870 return code;
871 }
872
873 bool readRaw(ConnectionReader& reader) override;
874 bool writeRaw(ConnectionWriter& writer) const override;
875
876 bool isBool() const override
877 {
878 return (x == 0 || x == '1');
879 }
880
881 bool asBool() const override
882 {
883 return x != 0;
884 }
885
886 std::int32_t asInt32() const override
887 {
888 return x;
889 }
890
891 std::int64_t asInt64() const override
892 {
893 return x;
894 }
895
897 {
898 return static_cast<yarp::conf::float32_t>(x);
899 }
900
902 {
903 return x;
904 }
905
906 bool isVocab32() const override
907 {
908 return true;
909 }
910
912 {
913 return x;
914 }
915
916 std::string asString() const override
917 {
918 return toString();
919 }
920};
921
926 public Storable
927{
929
930public:
931 StoreVocab64() = default;
932
934 x(x)
935 {
936 }
937
938 Storable* createStorable() const override
939 {
940 return new StoreVocab64();
941 }
942
943 void copy(const Storable& alt) override
944 {
945 x = alt.asVocab64();
946 }
947
948 std::string toString() const override;
949 void fromString(const std::string& src) override;
950 std::string toStringNested() const override;
951 void fromStringNested(const std::string& src) override;
952
953 static const std::int32_t code;
954 std::int32_t getCode() const override
955 {
956 return code;
957 }
958
959 bool readRaw(ConnectionReader& reader) override;
960 bool writeRaw(ConnectionWriter& writer) const override;
961
962 bool isBool() const override
963 {
964 return (x == 0 || x == '1');
965 }
966
967 bool asBool() const override
968 {
969 return x != 0;
970 }
971
972 std::int32_t asInt32() const override
973 {
974 return x;
975 }
976
977 std::int64_t asInt64() const override
978 {
979 return x;
980 }
981
983 {
984 return static_cast<yarp::conf::float32_t>(x);
985 }
986
988 {
989 return x;
990 }
991
992 bool isVocab64() const override
993 {
994 return true;
995 }
996
998 {
999 return x;
1000 }
1001
1002 std::string asString() const override
1003 {
1004 return toString();
1005 }
1006};
1007
1012 public Storable
1013{
1014private:
1016
1017public:
1018 StoreString() = default;
1019
1020 StoreString(const std::string& x)
1021 {
1022 this->x = x;
1023 }
1024
1025 Storable* createStorable() const override
1026 {
1027 return new StoreString();
1028 }
1029
1030 void copy(const Storable& alt) override
1031 {
1032 x = alt.asString();
1033 }
1034
1035 std::string toString() const override;
1036 void fromString(const std::string& src) override;
1037 std::string toStringNested() const override;
1038 void fromStringNested(const std::string& src) override;
1039
1040 static const std::int32_t code;
1041 std::int32_t getCode() const override
1042 {
1043 return code;
1044 }
1045
1046 bool readRaw(ConnectionReader& reader) override;
1047 bool writeRaw(ConnectionWriter& writer) const override;
1048
1049 bool isString() const override
1050 {
1051 return true;
1052 }
1053
1054 std::string asString() const override
1055 {
1056 return x;
1057 }
1058
1060 {
1061 return yarp::os::Vocab32::encode(x);
1062 }
1063
1064 // Quote and escape a string for printing it nested
1065 static std::string quotedString(const std::string& x);
1066};
1067
1072 public Storable
1073{
1074private:
1076
1077public:
1078 StoreBlob() = default;
1079
1080 StoreBlob(const std::string& x)
1081 {
1082 this->x = x;
1083 }
1084
1085 Storable* createStorable() const override
1086 {
1087 return new StoreBlob();
1088 }
1089
1090 void copy(const Storable& alt) override
1091 {
1092 if (alt.isBlob()) {
1093 std::string tmp((char*)alt.asBlob(), alt.asBlobLength());
1094 x = tmp;
1095 } else {
1096 x = std::string();
1097 }
1098 }
1099
1100 std::string toString() const override;
1101 void fromString(const std::string& src) override;
1102 std::string toStringNested() const override;
1103 void fromStringNested(const std::string& src) override;
1104
1105 static const std::int32_t code;
1106 std::int32_t getCode() const override
1107 {
1108 return code;
1109 }
1110
1111 bool readRaw(ConnectionReader& reader) override;
1112 bool writeRaw(ConnectionWriter& writer) const override;
1113
1114 bool isBlob() const override
1115 {
1116 return true;
1117 }
1118
1119 const char* asBlob() const override
1120 {
1121 return x.c_str();
1122 }
1123
1124 size_t asBlobLength() const override
1125 {
1126 return x.length();
1127 }
1128};
1129
1130
1135 public Storable
1136{
1137private:
1138 yarp::os::Bottle content{};
1139
1140public:
1141 StoreList() = default;
1142
1143 Storable* createStorable() const override
1144 {
1145 return new StoreList();
1146 }
1147
1148 void copy(const Storable& alt) override
1149 {
1150 content = *(alt.asList());
1151 }
1152
1154 {
1155 return content;
1156 }
1157
1158 std::string toString() const override;
1159 void fromString(const std::string& src) override;
1160 std::string toStringNested() const override;
1161 void fromStringNested(const std::string& src) override;
1162
1163 static const std::int32_t code;
1164 std::int32_t getCode() const override
1165 {
1166 return code + subCode();
1167 }
1168
1169 bool readRaw(ConnectionReader& reader) override;
1170 bool writeRaw(ConnectionWriter& writer) const override;
1171
1172 bool isList() const override
1173 {
1174 return true;
1175 }
1176
1177 yarp::os::Bottle* asList() const override
1178 {
1179 return (yarp::os::Bottle*)(&content);
1180 }
1181
1182 std::int32_t subCode() const override;
1183
1184 yarp::os::Value& find(const std::string& key) const override
1185 {
1186 return content.find(key);
1187 }
1188
1189 yarp::os::Bottle& findGroup(const std::string& key) const override
1190 {
1191 return content.findGroup(key);
1192 }
1193};
1194
1195
1200 public Storable
1201{
1202private:
1203 yarp::os::Property content{};
1204
1205public:
1206 StoreDict() = default;
1207
1208 Storable* createStorable() const override
1209 {
1210 return new StoreDict();
1211 }
1212
1213 void copy(const Storable& alt) override
1214 {
1215 content = *(alt.asDict());
1216 }
1217
1219 {
1220 return content;
1221 }
1222
1223 std::string toString() const override;
1224 void fromString(const std::string& src) override;
1225 std::string toStringNested() const override;
1226 void fromStringNested(const std::string& src) override;
1227
1228 static const std::int32_t code;
1229 std::int32_t getCode() const override
1230 {
1231 return code;
1232 }
1233
1234 bool readRaw(ConnectionReader& reader) override;
1235 bool writeRaw(ConnectionWriter& writer) const override;
1236
1237 bool isDict() const override
1238 {
1239 return true;
1240 }
1241
1242 yarp::os::Property* asDict() const override
1243 {
1244 return const_cast<yarp::os::Property*>(&content);
1245 }
1246
1247 yarp::os::Value& find(const std::string& key) const override
1248 {
1249 return content.find(key);
1250 }
1251
1252 yarp::os::Bottle& findGroup(const std::string& key) const override
1253 {
1254 return content.findGroup(key);
1255 }
1256};
1257
1258
1259template <typename T>
1260inline std::int32_t subCoder(T& content)
1261{
1262 std::int32_t c = -1;
1263 bool ok = false;
1264 for (unsigned int i = 0; i < content.size(); ++i) {
1265 std::int32_t sc = content.get(i).getCode();
1266 if (c == -1) {
1267 c = sc;
1268 ok = true;
1269 }
1270 if (sc != c) {
1271 ok = false;
1272 }
1273 }
1274 // just optimize primitive types
1275 if ((c & GROUP_MASK) != 0) {
1276 ok = false;
1277 }
1278 c = ok ? c : 0;
1279 content.specialize(c);
1280 return c;
1281}
1282
1283} // namespace yarp::os::impl
1284
1285#endif // YARP_OS_IMPL_STORABLE_H
bool operator==(const struct v4l2_control &left, const struct v4l2_control &right)
Definition CApiMock.h:65
std::string toString(const T &value)
convert an arbitrary type to string.
const yarp::os::LogComponent & STORABLE()
Definition Storable.cpp:43
const yarp::os::LogComponent & STORABLE()
Definition Storable.cpp:43
#define GROUP_MASK
Definition Storable.h:31
A simple collection of objects that can be described and transmitted in a portable way.
Definition Bottle.h:65
Bottle & findGroup(const std::string &key) const override
Gets a list corresponding to a given keyword.
Definition Bottle.cpp:299
A mini-server for performing network communication in the background.
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:33
A base class for nested structures that can be searched.
Definition Searchable.h:31
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:44
Value & find(const std::string &key) const override
Gets a value corresponding to a given keyword.
Definition Value.cpp:339
A single item in a Bottle.
Definition Storable.h:44
virtual Storable * createStorable() const =0
Factory method.
Searchable * asSearchable() const override
Get dictionary or list value.
Definition Storable.h:234
size_t asBlobLength() const override
Get binary data length.
Definition Storable.h:223
virtual std::string toStringNested() const
Create string representation, including any syntax that should wrap it such as braces or parentheses.
Definition Storable.h:271
yarp::os::Property * asDict() const override
Get dictionary (hash table) value.
Definition Storable.h:188
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 32bit vocabulary identifier.
Definition Storable.h:193
bool isList() const override
Checks if value is a list.
Definition Storable.h:173
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
bool isNull() const override
Checks if the object is invalid.
Definition Storable.h:228
const char * asBlob() const override
Get binary data value.
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
yarp::os::Value * clone() const override
Create a copy of the value.
Definition Storable.h:79
bool isBlob() const override
Checks if value is a binary object.
Definition Storable.h:213
virtual void fromStringNested(const std::string &src)
Initialize from a string representation.
Definition Storable.h:260
bool isVocab64() const override
Checks if value is a 64bit vocabulary identifier.
Definition Storable.h:198
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
std::string toString() const override=0
Return a standard text representation of the content of the object.
virtual std::int32_t subCode() const
Return a code describing this item, used in serializing bottles.
Definition Storable.h:279
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.
virtual Storable * cloneStorable() const
Typed synonym for clone()
Definition Storable.h:59
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 32 bit vocabulary identifier as an integer.
Definition Storable.h:203
yarp::os::Bottle * asList() const override
Get list value.
Definition Storable.h:178
bool isInt64() const override
Checks if value is a 64-bit integer.
Definition Storable.h:133
yarp::conf::vocab64_t asVocab64() const override
Get 64 bit vocabulary identifier as an integer.
Definition Storable.h:208
virtual bool readRaw(ConnectionReader &connection)=0
bool isLeaf() const override
Definition Storable.h:284
bool isFloat64() const override
Checks if value is a 64-bit floating point number.
Definition Storable.h:153
yarp::os::Value * create() const override
Create a new value of the same type.
Definition Storable.h:74
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:1073
bool isBlob() const override
Checks if value is a binary object.
Definition Storable.h:1114
Storable * createStorable() const override
Factory method.
Definition Storable.h:1085
size_t asBlobLength() const override
Get binary data length.
Definition Storable.h:1124
static const std::int32_t code
Definition Storable.h:1105
StoreBlob(const std::string &x)
Definition Storable.h:1080
const char * asBlob() const override
Get binary data value.
Definition Storable.h:1119
void copy(const Storable &alt) override
Become a copy of the passed item.
Definition Storable.h:1090
std::int32_t getCode() const override
Get standard type code of value.
Definition Storable.h:1106
Key/value pairs.
Definition Storable.h:1201
yarp::os::Property & internal()
Definition Storable.h:1218
yarp::os::Value & find(const std::string &key) const override
Gets a value corresponding to a given keyword.
Definition Storable.h:1247
void copy(const Storable &alt) override
Become a copy of the passed item.
Definition Storable.h:1213
bool isDict() const override
Checks if value is a dictionary.
Definition Storable.h:1237
yarp::os::Property * asDict() const override
Get dictionary (hash table) value.
Definition Storable.h:1242
std::int32_t getCode() const override
Get standard type code of value.
Definition Storable.h:1229
Storable * createStorable() const override
Factory method.
Definition Storable.h:1208
static const std::int32_t code
Definition Storable.h:1228
yarp::os::Bottle & findGroup(const std::string &key) const override
Gets a list corresponding to a given keyword.
Definition Storable.h:1252
A 32-bit floating point number item.
Definition Storable.h:691
yarp::conf::float64_t asFloat64() const override
Get 64-bit floating point value.
Definition Storable.h:755
yarp::conf::float32_t asFloat32() const override
Get 32-bit floating point value.
Definition Storable.h:750
bool isFloat32() const override
Checks if value is a 32-bit floating point number.
Definition Storable.h:725
void copy(const Storable &alt) override
Become a copy of the passed item.
Definition Storable.h:708
std::int8_t asInt8() const override
Get 8-bit integer value.
Definition Storable.h:730
std::int64_t asInt64() const override
Get 64-bit integer value.
Definition Storable.h:745
std::int32_t getCode() const override
Get standard type code of value.
Definition Storable.h:717
static const std::int32_t code
Definition Storable.h:716
std::int16_t asInt16() const override
Get 16-bit integer value.
Definition Storable.h:735
StoreFloat32(yarp::conf::float32_t x)
Definition Storable.h:698
Storable * createStorable() const override
Factory method.
Definition Storable.h:703
std::int32_t asInt32() const override
Get 32-bit integer value.
Definition Storable.h:740
A 64-bit floating point number item.
Definition Storable.h:766
StoreFloat64(yarp::conf::float64_t x)
Definition Storable.h:773
std::int16_t asInt16() const override
Get 16-bit integer value.
Definition Storable.h:810
std::int64_t asInt64() const override
Get 64-bit integer value.
Definition Storable.h:820
bool isFloat64() const override
Checks if value is a 64-bit floating point number.
Definition Storable.h:800
std::int32_t asInt32() const override
Get 32-bit integer value.
Definition Storable.h:815
Storable * createStorable() const override
Factory method.
Definition Storable.h:778
std::int8_t asInt8() const override
Get 8-bit integer value.
Definition Storable.h:805
yarp::conf::float64_t asFloat64() const override
Get 64-bit floating point value.
Definition Storable.h:830
void copy(const Storable &alt) override
Become a copy of the passed item.
Definition Storable.h:783
static const std::int32_t code
Definition Storable.h:791
yarp::conf::float32_t asFloat32() const override
Get 32-bit floating point value.
Definition Storable.h:825
std::int32_t getCode() const override
Get standard type code of value.
Definition Storable.h:792
A 16-bit integer item.
Definition Storable.h:435
yarp::conf::vocab32_t asVocab32() const override
Get 32 bit vocabulary identifier as an integer.
Definition Storable.h:509
yarp::conf::float32_t asFloat32() const override
Get 32-bit floating point value.
Definition Storable.h:499
bool asBool() const override
Get boolean value.
Definition Storable.h:474
std::int32_t getCode() const override
Get standard type code of value.
Definition Storable.h:461
void copy(const Storable &alt) override
Become a copy of the passed item.
Definition Storable.h:452
static const std::int32_t code
Definition Storable.h:460
yarp::conf::float64_t asFloat64() const override
Get 64-bit floating point value.
Definition Storable.h:504
std::int8_t asInt8() const override
Get 8-bit integer value.
Definition Storable.h:479
std::int32_t asInt32() const override
Get 32-bit integer value.
Definition Storable.h:489
bool isInt16() const override
Checks if value is a 16-bit integer.
Definition Storable.h:469
Storable * createStorable() const override
Factory method.
Definition Storable.h:447
std::int16_t asInt16() const override
Get 16-bit integer value.
Definition Storable.h:484
StoreInt16(std::int16_t x)
Definition Storable.h:442
std::int64_t asInt64() const override
Get 64-bit integer value.
Definition Storable.h:494
A 32-bit integer item.
Definition Storable.h:521
std::int32_t getCode() const override
Get standard type code of value.
Definition Storable.h:547
yarp::conf::float32_t asFloat32() const override
Get 32-bit floating point value.
Definition Storable.h:585
StoreInt32(std::int32_t x)
Definition Storable.h:528
bool isInt32() const override
Checks if value is a 32-bit integer.
Definition Storable.h:570
yarp::conf::float64_t asFloat64() const override
Get 64-bit floating point value.
Definition Storable.h:590
std::int8_t asInt8() const override
Get 8-bit integer value.
Definition Storable.h:555
std::int32_t asInt32() const override
Get 32-bit integer value.
Definition Storable.h:575
bool asBool() const override
Get boolean value.
Definition Storable.h:560
yarp::conf::vocab32_t asVocab32() const override
Get 32 bit vocabulary identifier as an integer.
Definition Storable.h:595
Storable * createStorable() const override
Factory method.
Definition Storable.h:533
std::int64_t asInt64() const override
Get 64-bit integer value.
Definition Storable.h:580
static const std::int32_t code
Definition Storable.h:546
std::int16_t asInt16() const override
Get 16-bit integer value.
Definition Storable.h:565
void copy(const Storable &alt) override
Become a copy of the passed item.
Definition Storable.h:538
A 64-bit integer item.
Definition Storable.h:606
std::int32_t getCode() const override
Get standard type code of value.
Definition Storable.h:632
static const std::int32_t code
Definition Storable.h:631
std::int8_t asInt8() const override
Get 8-bit integer value.
Definition Storable.h:650
bool asBool() const override
Get boolean value.
Definition Storable.h:645
std::int64_t asInt64() const override
Get 64-bit integer value.
Definition Storable.h:665
void copy(const Storable &alt) override
Become a copy of the passed item.
Definition Storable.h:623
yarp::conf::float64_t asFloat64() const override
Get 64-bit floating point value.
Definition Storable.h:675
yarp::conf::vocab32_t asVocab32() const override
Get 32 bit vocabulary identifier as an integer.
Definition Storable.h:680
std::int16_t asInt16() const override
Get 16-bit integer value.
Definition Storable.h:655
bool isInt64() const override
Checks if value is a 64-bit integer.
Definition Storable.h:640
Storable * createStorable() const override
Factory method.
Definition Storable.h:618
yarp::conf::float32_t asFloat32() const override
Get 32-bit floating point value.
Definition Storable.h:670
StoreInt64(std::int64_t x)
Definition Storable.h:613
std::int32_t asInt32() const override
Get 32-bit integer value.
Definition Storable.h:660
A 8-bit integer item.
Definition Storable.h:349
std::int32_t asInt32() const override
Get 32-bit integer value.
Definition Storable.h:403
StoreInt8(std::int8_t x)
Definition Storable.h:356
bool asBool() const override
Get boolean value.
Definition Storable.h:388
static const std::int32_t code
Definition Storable.h:374
yarp::conf::vocab32_t asVocab32() const override
Get 32 bit vocabulary identifier as an integer.
Definition Storable.h:423
void copy(const Storable &alt) override
Become a copy of the passed item.
Definition Storable.h:366
std::int32_t getCode() const override
Get standard type code of value.
Definition Storable.h:375
std::int8_t asInt8() const override
Get 8-bit integer value.
Definition Storable.h:393
Storable * createStorable() const override
Factory method.
Definition Storable.h:361
std::int16_t asInt16() const override
Get 16-bit integer value.
Definition Storable.h:398
yarp::conf::float64_t asFloat64() const override
Get 64-bit floating point value.
Definition Storable.h:418
std::int64_t asInt64() const override
Get 64-bit integer value.
Definition Storable.h:408
bool isInt8() const override
Checks if value is a 8-bit integer.
Definition Storable.h:383
yarp::conf::float32_t asFloat32() const override
Get 32-bit floating point value.
Definition Storable.h:413
A nested list of items.
Definition Storable.h:1136
yarp::os::Bottle & internal()
Definition Storable.h:1153
Storable * createStorable() const override
Factory method.
Definition Storable.h:1143
yarp::os::Value & find(const std::string &key) const override
Gets a value corresponding to a given keyword.
Definition Storable.h:1184
void copy(const Storable &alt) override
Become a copy of the passed item.
Definition Storable.h:1148
bool isList() const override
Checks if value is a list.
Definition Storable.h:1172
std::int32_t getCode() const override
Get standard type code of value.
Definition Storable.h:1164
yarp::os::Bottle * asList() const override
Get list value.
Definition Storable.h:1177
static const std::int32_t code
Definition Storable.h:1163
yarp::os::Bottle & findGroup(const std::string &key) const override
Gets a list corresponding to a given keyword.
Definition Storable.h:1189
std::int32_t getCode() const override
Get standard type code of value.
Definition Storable.h:320
std::string toString() const override
Return a standard text representation of the content of the object.
Definition Storable.h:310
Storable * createStorable() const override
Factory method.
Definition Storable.h:300
void copy(const Storable &alt) override
Become a copy of the passed item.
Definition Storable.h:305
bool writeRaw(ConnectionWriter &connection) const override
Definition Storable.h:331
bool readRaw(ConnectionReader &connection) override
Definition Storable.h:325
void fromString(const std::string &src) override
Initialize from a string representation, assuming that any syntax around this representation such as ...
Definition Storable.h:315
bool isNull() const override
Checks if the object is invalid.
Definition Storable.h:337
yarp::conf::vocab32_t asVocab32() const override
Get 32 bit vocabulary identifier as an integer.
Definition Storable.h:1059
Storable * createStorable() const override
Factory method.
Definition Storable.h:1025
StoreString(const std::string &x)
Definition Storable.h:1020
std::int32_t getCode() const override
Get standard type code of value.
Definition Storable.h:1041
void copy(const Storable &alt) override
Become a copy of the passed item.
Definition Storable.h:1030
std::string asString() const override
Get string value.
Definition Storable.h:1054
static const std::int32_t code
Definition Storable.h:1040
bool isString() const override
Checks if value is a string.
Definition Storable.h:1049
A 32 bit vocabulary item.
Definition Storable.h:841
yarp::conf::vocab32_t asVocab32() const override
Get 32 bit vocabulary identifier as an integer.
Definition Storable.h:911
std::int32_t getCode() const override
Get standard type code of value.
Definition Storable.h:868
yarp::conf::float32_t asFloat32() const override
Get 32-bit floating point value.
Definition Storable.h:896
std::string asString() const override
Get string value.
Definition Storable.h:916
void copy(const Storable &alt) override
Become a copy of the passed item.
Definition Storable.h:857
bool asBool() const override
Get boolean value.
Definition Storable.h:881
std::int64_t asInt64() const override
Get 64-bit integer value.
Definition Storable.h:891
Storable * createStorable() const override
Factory method.
Definition Storable.h:852
yarp::conf::float64_t asFloat64() const override
Get 64-bit floating point value.
Definition Storable.h:901
std::int32_t asInt32() const override
Get 32-bit integer value.
Definition Storable.h:886
bool isVocab32() const override
Checks if value is a 32bit vocabulary identifier.
Definition Storable.h:906
static const std::int32_t code
Definition Storable.h:867
StoreVocab32(yarp::conf::vocab32_t x)
Definition Storable.h:847
bool isBool() const override
Checks if value is a boolean.
Definition Storable.h:876
A 64 bit vocabulary item.
Definition Storable.h:927
std::int32_t getCode() const override
Get standard type code of value.
Definition Storable.h:954
bool isVocab64() const override
Checks if value is a 64bit vocabulary identifier.
Definition Storable.h:992
StoreVocab64(yarp::conf::vocab64_t x)
Definition Storable.h:933
std::int64_t asInt64() const override
Get 64-bit integer value.
Definition Storable.h:977
yarp::conf::float32_t asFloat32() const override
Get 32-bit floating point value.
Definition Storable.h:982
void copy(const Storable &alt) override
Become a copy of the passed item.
Definition Storable.h:943
std::int32_t asInt32() const override
Get 32-bit integer value.
Definition Storable.h:972
static const std::int32_t code
Definition Storable.h:953
std::string asString() const override
Get string value.
Definition Storable.h:1002
yarp::conf::float64_t asFloat64() const override
Get 64-bit floating point value.
Definition Storable.h:987
bool asBool() const override
Get boolean value.
Definition Storable.h:967
bool isBool() const override
Checks if value is a boolean.
Definition Storable.h:962
yarp::conf::vocab64_t asVocab64() const override
Get 64 bit vocabulary identifier as an integer.
Definition Storable.h:997
Storable * createStorable() const override
Factory method.
Definition Storable.h:938
#define yCAssert(component, x)
#define YARP_DECLARE_LOG_COMPONENT(name)
std::int32_t vocab32_t
Definition numeric.h:78
std::int64_t vocab64_t
Definition numeric.h:79
NetInt32 encode(const std::string &str)
Convert a string into a vocabulary identifier.
Definition Vocab32.cpp:11
The components from which ports and connections are built.
std::int32_t subCoder(T &content)
Definition Storable.h:1260
#define YARP_SUPPRESS_DLL_INTERFACE_WARNING_ARG(x)
Suppress MSVC C4251 warning for the declaration.
Definition system.h:338
#define YARP_UNUSED(var)
Definition api.h:162
#define YARP_os_impl_API
Definition api.h:46