YARP
Yet Another Robot Platform
SizedWriter.cpp
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3  * SPDX-FileCopyrightText: 2006-2010 RobotCub Consortium
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #include <yarp/os/SizedWriter.h>
8 
9 #include <yarp/os/Bytes.h>
11 #include <yarp/os/OutputStream.h>
12 
13 
15 
17 {
18  for (size_t i = 0; i < length(); i++) {
19  Bytes b((char*)data(i), length(i));
20  os.write(b);
21  }
22 }
23 
25 {
26  for (size_t i = 0; i < length(); i++) {
27  connection.appendBlock((char*)data(i), length(i));
28  }
29  return true;
30 }
31 
33 {
34 }
A simple abstraction for a block of bytes.
Definition: Bytes.h:25
An interface for writing to a network connection.
virtual void appendBlock(const char *data, size_t len)=0
Send a block of data to the network connection.
Simple specification of the minimum functions needed from output streams.
Definition: OutputStream.h:22
virtual void write(char ch)
Write a single byte to the stream.
virtual void write(OutputStream &os)
Definition: SizedWriter.cpp:16
virtual size_t length() const =0
virtual void clear()
Definition: SizedWriter.cpp:32
virtual const char * data(size_t index) const =0