YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
VectorOfInt32Data.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::sig {
14
15// Constructor with field values
16VectorOfInt32Data::VectorOfInt32Data(const std::vector<std::int32_t>& privdata) :
17 WirePortable(),
18 privdata(privdata)
19{
20}
21
22// Read structure on a Wire
24{
25 if (!read_privdata(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_privdata(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 VectorOfInt32Data::toString() const
74{
76 if (!yarp::os::Portable::copyPortable(*this, b)) {
77 return {};
78 }
79 return b.toString();
80}
81
82// read privdata field
83bool VectorOfInt32Data::read_privdata(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_INT32) & (~BOTTLE_TAG_LIST));
95 if constexpr (expected_tag != 0) {
96 if (_csize != 0 && _etype.code != expected_tag) {
97 return false;
98 }
99 }
100 privdata.resize(_csize);
101 if (_csize != 0 && !reader.readBlock(reinterpret_cast<char*>(privdata.data()), privdata.size() * sizeof(std::int32_t))) {
102 return false;
103 }
104 reader.readListEnd();
105 }
106 return true;
107}
108
109// write privdata field
110bool VectorOfInt32Data::write_privdata(const yarp::os::idl::WireWriter& writer) const
111{
112 if (!writer.writeListBegin(BOTTLE_TAG_INT32, privdata.size())) {
113 return false;
114 }
115 if (!writer.writeBlock(reinterpret_cast<const char*>(privdata.data()), privdata.size() * sizeof(std::int32_t))) {
116 return false;
117 }
118 if (!writer.writeListEnd()) {
119 return false;
120 }
121 return true;
122}
123
124// read (nested) privdata field
125bool VectorOfInt32Data::nested_read_privdata(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_INT32) & (~BOTTLE_TAG_LIST));
137 if constexpr (expected_tag != 0) {
138 if (_csize != 0 && _etype.code != expected_tag) {
139 return false;
140 }
141 }
142 privdata.resize(_csize);
143 if (_csize != 0 && !reader.readBlock(reinterpret_cast<char*>(privdata.data()), privdata.size() * sizeof(std::int32_t))) {
144 return false;
145 }
146 reader.readListEnd();
147 }
148 return true;
149}
150
151// write (nested) privdata field
152bool VectorOfInt32Data::nested_write_privdata(const yarp::os::idl::WireWriter& writer) const
153{
154 if (!writer.writeListBegin(BOTTLE_TAG_INT32, privdata.size())) {
155 return false;
156 }
157 if (!writer.writeBlock(reinterpret_cast<const char*>(privdata.data()), privdata.size() * sizeof(std::int32_t))) {
158 return false;
159 }
160 if (!writer.writeListEnd()) {
161 return false;
162 }
163 return true;
164}
165
166} // namespace yarp::sig
#define BOTTLE_TAG_INT32
Definition Bottle.h:21
#define BOTTLE_TAG_LIST
Definition Bottle.h:29
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
std::vector< std::int32_t > privdata
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
bool read(yarp::os::idl::WireReader &reader) override
bool write(const yarp::os::idl::WireWriter &writer) const override