iCub-main
Loading...
Searching...
No Matches
rawValuesKeyMetadata.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
13namespace iCub {
14
15// Constructor with field values
16rawValuesKeyMetadata::rawValuesKeyMetadata(const std::vector<std::string>& rawValueNames,
17 const std::int32_t size) :
18 WirePortable(),
19 rawValueNames(rawValueNames),
20 size(size)
21{
22}
23
24// Read structure on a Wire
25bool rawValuesKeyMetadata::read(yarp::os::idl::WireReader& reader)
26{
27 if (!read_rawValueNames(reader)) {
28 return false;
29 }
30 if (!read_size(reader)) {
31 return false;
32 }
33 if (reader.isError()) {
34 return false;
35 }
36 return true;
37}
38
39// Read structure on a Connection
40bool rawValuesKeyMetadata::read(yarp::os::ConnectionReader& connection)
41{
42 yarp::os::idl::WireReader reader(connection);
43 if (!reader.readListHeader(2)) {
44 return false;
45 }
46 if (!read(reader)) {
47 return false;
48 }
49 return true;
50}
51
52// Write structure on a Wire
53bool rawValuesKeyMetadata::write(const yarp::os::idl::WireWriter& writer) const
54{
55 if (!write_rawValueNames(writer)) {
56 return false;
57 }
58 if (!write_size(writer)) {
59 return false;
60 }
61 if (writer.isError()) {
62 return false;
63 }
64 return true;
65}
66
67// Write structure on a Connection
68bool rawValuesKeyMetadata::write(yarp::os::ConnectionWriter& connection) const
69{
70 yarp::os::idl::WireWriter writer(connection);
71 if (!writer.writeListHeader(2)) {
72 return false;
73 }
74 if (!write(writer)) {
75 return false;
76 }
77 return true;
78}
79
80// Convert to a printable string
82{
83 yarp::os::Bottle b;
84 if (!yarp::os::Portable::copyPortable(*this, b)) {
85 return {};
86 }
87 return b.toString();
88}
89
90// read rawValueNames field
91bool rawValuesKeyMetadata::read_rawValueNames(yarp::os::idl::WireReader& reader)
92{
93 if (reader.noMore()) {
94 reader.fail();
95 return false;
96 }
97 size_t _csize;
98 yarp::os::idl::WireState _etype;
99 reader.readListBegin(_etype, _csize);
100 // WireReader removes BOTTLE_TAG_LIST from the tag
101 constexpr int expected_tag = ((BOTTLE_TAG_STRING) & (~BOTTLE_TAG_LIST));
102 if constexpr (expected_tag != 0) {
103 if (_csize != 0 && _etype.code != expected_tag) {
104 return false;
105 }
106 }
107 rawValueNames.resize(_csize);
108 for (size_t _i = 0; _i < _csize; ++_i) {
109 if (reader.noMore()) {
110 reader.fail();
111 return false;
112 }
113 if (!reader.readString(rawValueNames[_i])) {
114 reader.fail();
115 return false;
116 }
117 }
118 reader.readListEnd();
119 return true;
120}
121
122// write rawValueNames field
123bool rawValuesKeyMetadata::write_rawValueNames(const yarp::os::idl::WireWriter& writer) const
124{
125 if (!writer.writeListBegin(BOTTLE_TAG_STRING, rawValueNames.size())) {
126 return false;
127 }
128 for (const auto& _item : rawValueNames) {
129 if (!writer.writeString(_item, true)) {
130 return false;
131 }
132 }
133 if (!writer.writeListEnd()) {
134 return false;
135 }
136 return true;
137}
138
139// read (nested) rawValueNames field
140bool rawValuesKeyMetadata::nested_read_rawValueNames(yarp::os::idl::WireReader& reader)
141{
142 if (reader.noMore()) {
143 reader.fail();
144 return false;
145 }
146 size_t _csize;
147 yarp::os::idl::WireState _etype;
148 reader.readListBegin(_etype, _csize);
149 // WireReader removes BOTTLE_TAG_LIST from the tag
150 constexpr int expected_tag = ((BOTTLE_TAG_STRING) & (~BOTTLE_TAG_LIST));
151 if constexpr (expected_tag != 0) {
152 if (_csize != 0 && _etype.code != expected_tag) {
153 return false;
154 }
155 }
156 rawValueNames.resize(_csize);
157 for (size_t _i = 0; _i < _csize; ++_i) {
158 if (reader.noMore()) {
159 reader.fail();
160 return false;
161 }
162 if (!reader.readString(rawValueNames[_i])) {
163 reader.fail();
164 return false;
165 }
166 }
167 reader.readListEnd();
168 return true;
169}
170
171// write (nested) rawValueNames field
172bool rawValuesKeyMetadata::nested_write_rawValueNames(const yarp::os::idl::WireWriter& writer) const
173{
174 if (!writer.writeListBegin(BOTTLE_TAG_STRING, rawValueNames.size())) {
175 return false;
176 }
177 for (const auto& _item : rawValueNames) {
178 if (!writer.writeString(_item, true)) {
179 return false;
180 }
181 }
182 if (!writer.writeListEnd()) {
183 return false;
184 }
185 return true;
186}
187
188// read size field
189bool rawValuesKeyMetadata::read_size(yarp::os::idl::WireReader& reader)
190{
191 if (reader.noMore()) {
192 reader.fail();
193 return false;
194 }
195 if (!reader.readI32(size)) {
196 reader.fail();
197 return false;
198 }
199 return true;
200}
201
202// write size field
203bool rawValuesKeyMetadata::write_size(const yarp::os::idl::WireWriter& writer) const
204{
205 if (!writer.writeI32(size)) {
206 return false;
207 }
208 return true;
209}
210
211// read (nested) size field
212bool rawValuesKeyMetadata::nested_read_size(yarp::os::idl::WireReader& reader)
213{
214 if (reader.noMore()) {
215 reader.fail();
216 return false;
217 }
218 if (!reader.readI32(size)) {
219 reader.fail();
220 return false;
221 }
222 return true;
223}
224
225// write (nested) size field
226bool rawValuesKeyMetadata::nested_write_size(const yarp::os::idl::WireWriter& writer) const
227{
228 if (!writer.writeI32(size)) {
229 return false;
230 }
231 return true;
232}
233
234} // namespace iCub
bool write(const yarp::os::idl::WireWriter &writer) const override
bool read(yarp::os::idl::WireReader &reader) override
std::vector< std::string > rawValueNames
This file contains the definition of unique IDs for the body parts and the skin parts of the robot.