YARP
Yet Another Robot Platform
SizedWriter.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
3  * Copyright (C) 2006-2010 RobotCub Consortium
4  * All rights reserved.
5  *
6  * This software may be modified and distributed under the terms of the
7  * BSD-3-Clause license. See the accompanying LICENSE file for details.
8  */
9 
10 #include <yarp/os/SizedWriter.h>
11 
12 #include <yarp/os/Bytes.h>
14 #include <yarp/os/OutputStream.h>
15 
16 
18 
20 {
21  for (size_t i = 0; i < length(); i++) {
22  Bytes b((char*)data(i), length(i));
23  os.write(b);
24  }
25 }
26 
28 {
29  for (size_t i = 0; i < length(); i++) {
30  connection.appendBlock((char*)data(i), length(i));
31  }
32  return true;
33 }
34 
36 {
37 }
A simple abstraction for a block of bytes.
Definition: Bytes.h:28
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:25
virtual void write(char ch)
Write a single byte to the stream.
virtual void write(OutputStream &os)
Definition: SizedWriter.cpp:19
virtual size_t length() const =0
virtual void clear()
Definition: SizedWriter.cpp:35
virtual const char * data(size_t index) const =0