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