YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
SoundMarkerData.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
16SoundMarkerData::SoundMarkerData(const std::string& label,
17 const std::int32_t channel,
18 const std::int32_t sample_id) :
19 WirePortable(),
20 label(label),
21 channel(channel),
22 sample_id(sample_id)
23{
24}
25
26// Read structure on a Wire
28{
29 if (!read_label(reader)) {
30 return false;
31 }
32 if (!read_channel(reader)) {
33 return false;
34 }
35 if (!read_sample_id(reader)) {
36 return false;
37 }
38 if (reader.isError()) {
39 return false;
40 }
41 return true;
42}
43
44// Read structure on a Connection
46{
47 yarp::os::idl::WireReader reader(connection);
48 if (!reader.readListHeader(3)) {
49 return false;
50 }
51 if (!read(reader)) {
52 return false;
53 }
54 return true;
55}
56
57// Write structure on a Wire
59{
60 if (!write_label(writer)) {
61 return false;
62 }
63 if (!write_channel(writer)) {
64 return false;
65 }
66 if (!write_sample_id(writer)) {
67 return false;
68 }
69 if (writer.isError()) {
70 return false;
71 }
72 return true;
73}
74
75// Write structure on a Connection
77{
78 yarp::os::idl::WireWriter writer(connection);
79 if (!writer.writeListHeader(3)) {
80 return false;
81 }
82 if (!write(writer)) {
83 return false;
84 }
85 return true;
86}
87
88// Convert to a printable string
89std::string SoundMarkerData::toString() const
90{
92 if (!yarp::os::Portable::copyPortable(*this, b)) {
93 return {};
94 }
95 return b.toString();
96}
97
98// read label field
99bool SoundMarkerData::read_label(yarp::os::idl::WireReader& reader)
100{
101 if (reader.noMore()) {
102 reader.fail();
103 return false;
104 }
105 if (!reader.readString(label)) {
106 reader.fail();
107 return false;
108 }
109 return true;
110}
111
112// write label field
113bool SoundMarkerData::write_label(const yarp::os::idl::WireWriter& writer) const
114{
115 if (!writer.writeString(label)) {
116 return false;
117 }
118 return true;
119}
120
121// read (nested) label field
122bool SoundMarkerData::nested_read_label(yarp::os::idl::WireReader& reader)
123{
124 if (reader.noMore()) {
125 reader.fail();
126 return false;
127 }
128 if (!reader.readString(label)) {
129 reader.fail();
130 return false;
131 }
132 return true;
133}
134
135// write (nested) label field
136bool SoundMarkerData::nested_write_label(const yarp::os::idl::WireWriter& writer) const
137{
138 if (!writer.writeString(label)) {
139 return false;
140 }
141 return true;
142}
143
144// read channel field
145bool SoundMarkerData::read_channel(yarp::os::idl::WireReader& reader)
146{
147 if (!reader.readI32(channel)) {
148 channel = -1;
149 }
150 return true;
151}
152
153// write channel field
154bool SoundMarkerData::write_channel(const yarp::os::idl::WireWriter& writer) const
155{
156 if (!writer.writeI32(channel)) {
157 return false;
158 }
159 return true;
160}
161
162// read (nested) channel field
163bool SoundMarkerData::nested_read_channel(yarp::os::idl::WireReader& reader)
164{
165 if (!reader.readI32(channel)) {
166 channel = -1;
167 }
168 return true;
169}
170
171// write (nested) channel field
172bool SoundMarkerData::nested_write_channel(const yarp::os::idl::WireWriter& writer) const
173{
174 if (!writer.writeI32(channel)) {
175 return false;
176 }
177 return true;
178}
179
180// read sample_id field
181bool SoundMarkerData::read_sample_id(yarp::os::idl::WireReader& reader)
182{
183 if (!reader.readI32(sample_id)) {
184 sample_id = 0;
185 }
186 return true;
187}
188
189// write sample_id field
190bool SoundMarkerData::write_sample_id(const yarp::os::idl::WireWriter& writer) const
191{
192 if (!writer.writeI32(sample_id)) {
193 return false;
194 }
195 return true;
196}
197
198// read (nested) sample_id field
199bool SoundMarkerData::nested_read_sample_id(yarp::os::idl::WireReader& reader)
200{
201 if (!reader.readI32(sample_id)) {
202 sample_id = 0;
203 }
204 return true;
205}
206
207// write (nested) sample_id field
208bool SoundMarkerData::nested_write_sample_id(const yarp::os::idl::WireWriter& writer) const
209{
210 if (!writer.writeI32(sample_id)) {
211 return false;
212 }
213 return true;
214}
215
216} // namespace yarp::sig
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
bool readString(std::string &str, bool *is_vocab=nullptr)
bool readI32(std::int32_t &x)
IDL-friendly connection writer.
Definition WireWriter.h:28
bool writeI32(std::int32_t x, bool skip_tag=false) const
bool writeListHeader(int len) const
bool writeString(const std::string &str, bool skip_tag=false) const
bool write(const yarp::os::idl::WireWriter &writer) const override
std::string toString() const
bool read(yarp::os::idl::WireReader &reader) override