YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
StringOutputStream.h
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#ifndef YARP_OS_STRINGOUTPUTSTREAM_H
8#define YARP_OS_STRINGOUTPUTSTREAM_H
9
10#include <yarp/os/Bytes.h>
12
13#include <string>
14
15namespace yarp::os {
16
21{
22public:
24
26 {
27 }
28
29 std::string toString() const
30 {
31 return data;
32 }
33
34 void reset()
35 {
36 data = "";
37 }
38
39 void write(const Bytes& b) override
40 {
41 std::string tmp((char*)b.get(), b.length());
42 data += tmp;
43 }
44
45 void close() override
46 {
47 }
48
49 bool isOk() const override
50 {
51 return true;
52 }
53
54 const std::string& str() const
55 {
56 return data;
57 }
58
59private:
61};
62
63} // namespace yarp::os
64
65#endif // YARP_OS_STRINGOUTPUTSTREAM_H
A mini-server for performing network communication in the background.
A simple abstraction for a block of bytes.
Definition Bytes.h:24
size_t length() const
Definition Bytes.cpp:22
const char * get() const
Definition Bytes.cpp:27
Simple specification of the minimum functions needed from output streams.
virtual void write(char ch)
Write a single byte to the stream.
An OutputStream that produces a string.
const std::string & str() const
bool isOk() const override
Check if the stream is ok or in an error state.
void close() override
Terminate the stream.
void write(const Bytes &b) override
Write a block of bytes to the stream.
An interface to the operating system, including Port based communication.
#define YARP_SUPPRESS_DLL_INTERFACE_WARNING_ARG(x)
Suppress MSVC C4251 warning for the declaration.
Definition system.h:338