YARP
Yet Another Robot Platform
InputStream.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2021 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 #ifndef YARP_OS_INPUTSTREAM_H
11 #define YARP_OS_INPUTSTREAM_H
12 
13 #include <yarp/conf/numeric.h>
14 
15 #include <yarp/os/api.h>
16 
17 #include <string>
18 
19 namespace yarp {
20 namespace os {
21 
22 class Bytes;
23 
29 {
30 public:
35 
39  virtual ~InputStream();
40 
46  virtual void check();
47 
54  virtual int read();
55 
67  virtual yarp::conf::ssize_t read(Bytes& b, size_t offset, yarp::conf::ssize_t len);
68 
78 
79 
83  virtual yarp::conf::ssize_t partialRead(yarp::os::Bytes& b);
84 
88  virtual void close() = 0;
89 
94  virtual void interrupt();
95 
101  virtual bool isOk() const = 0;
102 
107  virtual bool setReadTimeout(double timeout);
108 
112  std::string readLine(const char terminal = '\n', bool* success = nullptr);
113 
117  yarp::conf::ssize_t readFull(Bytes& b);
118 
122  yarp::conf::ssize_t readDiscard(size_t len);
123 
128  typedef void (*readEnvelopeCallbackType)(void*, const yarp::os::Bytes& envelope);
129 
139  virtual bool setReadEnvelopeCallback(readEnvelopeCallbackType callback, void* data);
140 };
141 
142 } // namespace os
143 } // namespace yarp
144 
145 #endif // YARP_OS_INPUTSTREAM_H
A simple abstraction for a block of bytes.
Definition: Bytes.h:28
Simple specification of the minimum functions needed from input streams.
Definition: InputStream.h:29
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:89
bool read(ImageOf< PixelRgb > &dest, const std::string &src, image_fileformat format=FORMAT_ANY)
Definition: ImageFile.cpp:920
The main, catch-all namespace for YARP.
Definition: environment.h:25
#define YARP_os_API
Definition: api.h:19