iCub-main
rawValuesKeyMetadataMap.cpp
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3  * SPDX-License-Identifier: BSD-3-Clause
4  */
5 
6 // Autogenerated by Thrift Compiler (0.14.1-yarped)
7 //
8 // This is an automatically generated file.
9 // It could get re-generated if the ALLOW_IDL_GENERATION flag is on.
10 
12 
13 namespace iCub {
14 
15 // Constructor with field values
16 rawValuesKeyMetadataMap::rawValuesKeyMetadataMap(const std::map<std::string, rawValuesKeyMetadata>& metadataMap) :
17  WirePortable(),
18  metadataMap(metadataMap)
19 {
20 }
21 
22 // Read structure on a Wire
23 bool rawValuesKeyMetadataMap::read(yarp::os::idl::WireReader& reader)
24 {
25  if (!read_metadataMap(reader)) {
26  return false;
27  }
28  if (reader.isError()) {
29  return false;
30  }
31  return true;
32 }
33 
34 // Read structure on a Connection
35 bool rawValuesKeyMetadataMap::read(yarp::os::ConnectionReader& connection)
36 {
37  yarp::os::idl::WireReader reader(connection);
38  if (!reader.readListHeader(1)) {
39  return false;
40  }
41  if (!read(reader)) {
42  return false;
43  }
44  return true;
45 }
46 
47 // Write structure on a Wire
48 bool rawValuesKeyMetadataMap::write(const yarp::os::idl::WireWriter& writer) const
49 {
50  if (!write_metadataMap(writer)) {
51  return false;
52  }
53  if (writer.isError()) {
54  return false;
55  }
56  return true;
57 }
58 
59 // Write structure on a Connection
60 bool rawValuesKeyMetadataMap::write(yarp::os::ConnectionWriter& connection) const
61 {
62  yarp::os::idl::WireWriter writer(connection);
63  if (!writer.writeListHeader(1)) {
64  return false;
65  }
66  if (!write(writer)) {
67  return false;
68  }
69  return true;
70 }
71 
72 // Convert to a printable string
74 {
75  yarp::os::Bottle b;
76  if (!yarp::os::Portable::copyPortable(*this, b)) {
77  return {};
78  }
79  return b.toString();
80 }
81 
82 // read metadataMap field
83 bool rawValuesKeyMetadataMap::read_metadataMap(yarp::os::idl::WireReader& reader)
84 {
85  if (reader.noMore()) {
86  reader.fail();
87  return false;
88  }
89  size_t _csize;
90  yarp::os::idl::WireState _ktype;
91  yarp::os::idl::WireState _vtype;
92  reader.readMapBegin(_ktype, _vtype, _csize);
93  for (size_t _i = 0; _i < _csize; ++_i) {
94  size_t _msize;
95  yarp::os::idl::WireState _lst;
96  reader.readListBegin(_lst, _msize);
97  std::string _key;
98  if (reader.noMore()) {
99  reader.fail();
100  return false;
101  }
102  if (!reader.readString(_key)) {
103  reader.fail();
104  return false;
105  }
106  rawValuesKeyMetadata& _val = metadataMap[_key];
107  if (reader.noMore()) {
108  reader.fail();
109  return false;
110  }
111  if (!reader.readNested(_val)) {
112  reader.fail();
113  return false;
114  }
115  reader.readListEnd();
116  }
117  reader.readMapEnd();
118  return true;
119 }
120 
121 // write metadataMap field
122 bool rawValuesKeyMetadataMap::write_metadataMap(const yarp::os::idl::WireWriter& writer) const
123 {
124  if (!writer.writeMapBegin(BOTTLE_TAG_STRING, BOTTLE_TAG_LIST, metadataMap.size())) {
125  return false;
126  }
127  for (const auto& _item : metadataMap) {
128  if (!writer.writeListBegin(0,2)) {
129  return false;
130  }
131  if (!writer.writeString(_item.first)) {
132  return false;
133  }
134  if (!writer.writeNested(_item.second)) {
135  return false;
136  }
137  if (!writer.writeListEnd()) {
138  return false;
139  }
140  }
141  if (!writer.writeMapEnd()) {
142  return false;
143  }
144  return true;
145 }
146 
147 // read (nested) metadataMap field
148 bool rawValuesKeyMetadataMap::nested_read_metadataMap(yarp::os::idl::WireReader& reader)
149 {
150  if (reader.noMore()) {
151  reader.fail();
152  return false;
153  }
154  size_t _csize;
155  yarp::os::idl::WireState _ktype;
156  yarp::os::idl::WireState _vtype;
157  reader.readMapBegin(_ktype, _vtype, _csize);
158  for (size_t _i = 0; _i < _csize; ++_i) {
159  size_t _msize;
160  yarp::os::idl::WireState _lst;
161  reader.readListBegin(_lst, _msize);
162  std::string _key;
163  if (reader.noMore()) {
164  reader.fail();
165  return false;
166  }
167  if (!reader.readString(_key)) {
168  reader.fail();
169  return false;
170  }
171  rawValuesKeyMetadata& _val = metadataMap[_key];
172  if (reader.noMore()) {
173  reader.fail();
174  return false;
175  }
176  if (!reader.readNested(_val)) {
177  reader.fail();
178  return false;
179  }
180  reader.readListEnd();
181  }
182  reader.readMapEnd();
183  return true;
184 }
185 
186 // write (nested) metadataMap field
187 bool rawValuesKeyMetadataMap::nested_write_metadataMap(const yarp::os::idl::WireWriter& writer) const
188 {
189  if (!writer.writeMapBegin(BOTTLE_TAG_STRING, BOTTLE_TAG_LIST, metadataMap.size())) {
190  return false;
191  }
192  for (const auto& _item : metadataMap) {
193  if (!writer.writeListBegin(0,2)) {
194  return false;
195  }
196  if (!writer.writeString(_item.first)) {
197  return false;
198  }
199  if (!writer.writeNested(_item.second)) {
200  return false;
201  }
202  if (!writer.writeListEnd()) {
203  return false;
204  }
205  }
206  if (!writer.writeMapEnd()) {
207  return false;
208  }
209  return true;
210 }
211 
212 } // namespace iCub
bool read(yarp::os::idl::WireReader &reader) override
bool write(const yarp::os::idl::WireWriter &writer) const override
std::map< std::string, rawValuesKeyMetadata > metadataMap
This file contains the definition of unique IDs for the body parts and the skin parts of the robot.