YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
return_get_locations_list.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// Constructor with field values
15 const std::vector<std::string>& locations) :
16 WirePortable(),
17 retval(retval),
18 locations(locations)
19{
20}
21
22// Read structure on a Wire
24{
25 if (!read_retval(reader)) {
26 return false;
27 }
28 if (!read_locations(reader)) {
29 return false;
30 }
31 if (reader.isError()) {
32 return false;
33 }
34 return true;
35}
36
37// Read structure on a Connection
39{
40 yarp::os::idl::WireReader reader(connection);
41 if (!reader.readListHeader(2)) {
42 return false;
43 }
44 if (!read(reader)) {
45 return false;
46 }
47 return true;
48}
49
50// Write structure on a Wire
52{
53 if (!write_retval(writer)) {
54 return false;
55 }
56 if (!write_locations(writer)) {
57 return false;
58 }
59 if (writer.isError()) {
60 return false;
61 }
62 return true;
63}
64
65// Write structure on a Connection
67{
68 yarp::os::idl::WireWriter writer(connection);
69 if (!writer.writeListHeader(2)) {
70 return false;
71 }
72 if (!write(writer)) {
73 return false;
74 }
75 return true;
76}
77
78// Convert to a printable string
80{
82 if (!yarp::os::Portable::copyPortable(*this, b)) {
83 return {};
84 }
85 return b.toString();
86}
87
88// read retval field
89bool return_get_locations_list::read_retval(yarp::os::idl::WireReader& reader)
90{
91 if (!reader.readBool(retval)) {
92 retval = false;
93 }
94 return true;
95}
96
97// write retval field
98bool return_get_locations_list::write_retval(const yarp::os::idl::WireWriter& writer) const
99{
100 if (!writer.writeBool(retval)) {
101 return false;
102 }
103 return true;
104}
105
106// read (nested) retval field
107bool return_get_locations_list::nested_read_retval(yarp::os::idl::WireReader& reader)
108{
109 if (!reader.readBool(retval)) {
110 retval = false;
111 }
112 return true;
113}
114
115// write (nested) retval field
116bool return_get_locations_list::nested_write_retval(const yarp::os::idl::WireWriter& writer) const
117{
118 if (!writer.writeBool(retval)) {
119 return false;
120 }
121 return true;
122}
123
124// read locations field
125bool return_get_locations_list::read_locations(yarp::os::idl::WireReader& reader)
126{
127 if (reader.noMore()) {
128 reader.fail();
129 return false;
130 }
131 size_t _csize;
133 reader.readListBegin(_etype, _csize);
134 // WireReader removes BOTTLE_TAG_LIST from the tag
135 constexpr int expected_tag = ((BOTTLE_TAG_STRING) & (~BOTTLE_TAG_LIST));
136 if constexpr (expected_tag != 0) {
137 if (_csize != 0 && _etype.code != expected_tag) {
138 return false;
139 }
140 }
141 locations.resize(_csize);
142 for (size_t _i = 0; _i < _csize; ++_i) {
143 if (reader.noMore()) {
144 reader.fail();
145 return false;
146 }
147 if (!reader.readString(locations[_i])) {
148 reader.fail();
149 return false;
150 }
151 }
152 reader.readListEnd();
153 return true;
154}
155
156// write locations field
157bool return_get_locations_list::write_locations(const yarp::os::idl::WireWriter& writer) const
158{
159 if (!writer.writeListBegin(BOTTLE_TAG_STRING, locations.size())) {
160 return false;
161 }
162 for (const auto& _item : locations) {
163 if (!writer.writeString(_item, true)) {
164 return false;
165 }
166 }
167 if (!writer.writeListEnd()) {
168 return false;
169 }
170 return true;
171}
172
173// read (nested) locations field
174bool return_get_locations_list::nested_read_locations(yarp::os::idl::WireReader& reader)
175{
176 if (reader.noMore()) {
177 reader.fail();
178 return false;
179 }
180 size_t _csize;
182 reader.readListBegin(_etype, _csize);
183 // WireReader removes BOTTLE_TAG_LIST from the tag
184 constexpr int expected_tag = ((BOTTLE_TAG_STRING) & (~BOTTLE_TAG_LIST));
185 if constexpr (expected_tag != 0) {
186 if (_csize != 0 && _etype.code != expected_tag) {
187 return false;
188 }
189 }
190 locations.resize(_csize);
191 for (size_t _i = 0; _i < _csize; ++_i) {
192 if (reader.noMore()) {
193 reader.fail();
194 return false;
195 }
196 if (!reader.readString(locations[_i])) {
197 reader.fail();
198 return false;
199 }
200 }
201 reader.readListEnd();
202 return true;
203}
204
205// write (nested) locations field
206bool return_get_locations_list::nested_write_locations(const yarp::os::idl::WireWriter& writer) const
207{
208 if (!writer.writeListBegin(BOTTLE_TAG_STRING, locations.size())) {
209 return false;
210 }
211 for (const auto& _item : locations) {
212 if (!writer.writeString(_item, true)) {
213 return false;
214 }
215 }
216 if (!writer.writeListEnd()) {
217 return false;
218 }
219 return true;
220}
#define BOTTLE_TAG_STRING
Definition Bottle.h:26
#define BOTTLE_TAG_LIST
Definition Bottle.h:28
bool read(yarp::os::idl::WireReader &reader) override
return_get_locations_list()=default
std::vector< std::string > locations
bool write(const yarp::os::idl::WireWriter &writer) const override
A simple collection of objects that can be described and transmitted in a portable way.
Definition Bottle.h:64
std::string toString() const override
Gives a human-readable textual representation of the bottle.
Definition Bottle.cpp:211
An interface for reading from a network connection.
An interface for writing to a network connection.
static bool copyPortable(const PortWriter &writer, PortReader &reader)
Copy one portable to another, via writing and reading.
Definition Portable.cpp:16
IDL-friendly connection reader.
Definition WireReader.h:27
bool readString(std::string &str, bool *is_vocab=nullptr)
void readListBegin(yarp::os::idl::WireState &nstate, size_t &len)
IDL-friendly state.
Definition WireState.h:17
IDL-friendly connection writer.
Definition WireWriter.h:28
bool writeBool(bool x, bool skip_tag=false) const
bool writeListHeader(int len) const
bool writeString(const std::string &str, bool skip_tag=false) const
bool writeListBegin(int tag, size_t len) const