YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
HatsDataList.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 (based on compiler 0.14.1-yarped)
7// yarpidl_thrift version 2.0 - 11/11/2026
8// This is an automatically generated file.
9// It could get re-generated if the ALLOW_IDL_GENERATION flag is on.
10
12
13namespace yarp::dev {
14
15// Constructor with field values
16HatsDataList::HatsDataList(const std::vector<std::int8_t>& value) :
17 WirePortable(),
18 value(value)
19{
20}
21
22// Read structure on a Wire
24{
25 if (!read_value(reader)) {
26 return false;
27 }
28 if (reader.isError()) {
29 return false;
30 }
31 return true;
32}
33
34// Read structure on a 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
49{
50 if (!write_value(writer)) {
51 return false;
52 }
53 if (writer.isError()) {
54 return false;
55 }
56 return true;
57}
58
59// Write structure on a Connection
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
73std::string HatsDataList::toString() const
74{
76 if (!yarp::os::Portable::copyPortable(*this, b)) {
77 return {};
78 }
79 return b.toString();
80}
81
82// read value field
83bool HatsDataList::read_value(yarp::os::idl::WireReader& reader)
84{
85 if (reader.noMore()) {
86 reader.fail();
87 return false;
88 }
89 {
90 size_t _csize;
92 reader.readListBegin(_etype, _csize);
93 // WireReader removes BOTTLE_TAG_LIST from the tag
94 constexpr int expected_tag = ((BOTTLE_TAG_INT8) & (~BOTTLE_TAG_LIST));
95 if constexpr (expected_tag != 0) {
96 if (_csize != 0 && _etype.code != expected_tag) {
97 return false;
98 }
99 }
100 value.resize(_csize);
101 if (_csize != 0 && !reader.readBlock(reinterpret_cast<char*>(value.data()), value.size() * sizeof(std::int8_t))) {
102 return false;
103 }
104 reader.readListEnd();
105 }
106 return true;
107}
108
109// write value field
110bool HatsDataList::write_value(const yarp::os::idl::WireWriter& writer) const
111{
112 if (!writer.writeListBegin(BOTTLE_TAG_INT8, value.size())) {
113 return false;
114 }
115 if (!writer.writeBlock(reinterpret_cast<const char*>(value.data()), value.size() * sizeof(std::int8_t))) {
116 return false;
117 }
118 if (!writer.writeListEnd()) {
119 return false;
120 }
121 return true;
122}
123
124// read (nested) value field
125bool HatsDataList::nested_read_value(yarp::os::idl::WireReader& reader)
126{
127 if (reader.noMore()) {
128 reader.fail();
129 return false;
130 }
131 {
132 size_t _csize;
134 reader.readListBegin(_etype, _csize);
135 // WireReader removes BOTTLE_TAG_LIST from the tag
136 constexpr int expected_tag = ((BOTTLE_TAG_INT8) & (~BOTTLE_TAG_LIST));
137 if constexpr (expected_tag != 0) {
138 if (_csize != 0 && _etype.code != expected_tag) {
139 return false;
140 }
141 }
142 value.resize(_csize);
143 if (_csize != 0 && !reader.readBlock(reinterpret_cast<char*>(value.data()), value.size() * sizeof(std::int8_t))) {
144 return false;
145 }
146 reader.readListEnd();
147 }
148 return true;
149}
150
151// write (nested) value field
152bool HatsDataList::nested_write_value(const yarp::os::idl::WireWriter& writer) const
153{
154 if (!writer.writeListBegin(BOTTLE_TAG_INT8, value.size())) {
155 return false;
156 }
157 if (!writer.writeBlock(reinterpret_cast<const char*>(value.data()), value.size() * sizeof(std::int8_t))) {
158 return false;
159 }
160 if (!writer.writeListEnd()) {
161 return false;
162 }
163 return true;
164}
165
166} // namespace yarp::dev
#define BOTTLE_TAG_INT8
Definition Bottle.h:19
#define BOTTLE_TAG_LIST
Definition Bottle.h:29
std::string toString() const
bool write(const yarp::os::idl::WireWriter &writer) const override
std::vector< std::int8_t > value
bool read(yarp::os::idl::WireReader &reader) 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:212
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
void readListBegin(yarp::os::idl::WireState &nstate, size_t &len)
bool readBlock(char *const data, size_t len)
IDL-friendly state.
Definition WireState.h:17
IDL-friendly connection writer.
Definition WireWriter.h:28
bool writeListHeader(int len) const
bool writeBlock(const char *data, size_t len) const
bool writeListBegin(int tag, size_t len) const
For streams capable of holding different kinds of content, check what they actually have.