YARP
Yet Another Robot Platform
InputStream.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_INPUTSTREAM_H
8 #define YARP_OS_INPUTSTREAM_H
9 
10 #include <yarp/conf/numeric.h>
11 
12 #include <yarp/os/api.h>
13 
14 #include <string>
15 
16 namespace yarp {
17 namespace os {
18 
19 class Bytes;
20 
26 {
27 public:
32 
36  virtual ~InputStream();
37 
43  virtual void check();
44 
51  virtual int read();
52 
64  virtual yarp::conf::ssize_t read(Bytes& b, size_t offset, yarp::conf::ssize_t len);
65 
75 
76 
80  virtual yarp::conf::ssize_t partialRead(yarp::os::Bytes& b);
81 
85  virtual void close() = 0;
86 
91  virtual void interrupt();
92 
98  virtual bool isOk() const = 0;
99 
104  virtual bool setReadTimeout(double timeout);
105 
109  std::string readLine(const char terminal = '\n', bool* success = nullptr);
110 
114  yarp::conf::ssize_t readFull(Bytes& b);
115 
119  yarp::conf::ssize_t readDiscard(size_t len);
120 
125  typedef void (*readEnvelopeCallbackType)(void*, const yarp::os::Bytes& envelope);
126 
136  virtual bool setReadEnvelopeCallback(readEnvelopeCallbackType callback, void* data);
137 };
138 
139 } // namespace os
140 } // namespace yarp
141 
142 #endif // YARP_OS_INPUTSTREAM_H
A simple abstraction for a block of bytes.
Definition: Bytes.h:25
Simple specification of the minimum functions needed from input streams.
Definition: InputStream.h:26
virtual bool isOk() const =0
Check if the stream is ok or in an error state.
virtual yarp::conf::ssize_t read(yarp::os::Bytes &b)=0
Read a block of data from the stream.
virtual void close()=0
Terminate the stream.
InputStream()
Constructor.
virtual ~InputStream()
Destructor.
::ssize_t ssize_t
Definition: numeric.h:86
bool read(ImageOf< PixelRgb > &dest, const std::string &src, image_fileformat format=FORMAT_ANY)
Definition: ImageFile.cpp:923
The main, catch-all namespace for YARP.
Definition: dirs.h:16
#define YARP_os_API
Definition: api.h:18