36 #if defined (FLEXIPORT_STATIC)
37 #define FLEXIPORT_EXPORT
38 #elif defined (FLEXIPORT_EXPORTS)
39 #define FLEXIPORT_EXPORT __declspec (dllexport)
41 #define FLEXIPORT_EXPORT __declspec (dllimport)
44 #define FLEXIPORT_EXPORT
47#include "flexiport_types.h"
101 virtual ssize_t
Read (
void *
const buffer,
size_t count) = 0;
113 virtual ssize_t
ReadFull (
void *
const buffer,
size_t count) = 0;
121 virtual ssize_t ReadString (std::string &buffer);
138 virtual ssize_t ReadUntil (
void *
const buffer,
size_t count, uint8_t terminator);
155 virtual ssize_t ReadStringUntil (std::string &buffer,
char terminator);
179 virtual ssize_t ReadLine (
char *
const buffer,
size_t count);
195 virtual ssize_t
ReadLine (std::string &buffer) {
return ReadStringUntil (buffer,
'\n'); }
200 virtual ssize_t Skip (
size_t count);
206 virtual ssize_t SkipUntil (uint8_t terminator,
unsigned int count);
230 virtual ssize_t
Write (
const void *
const buffer,
size_t count) = 0;
238 virtual ssize_t WriteFull (
const void *
const buffer,
size_t count);
249 virtual ssize_t WriteString (
const char *
const buffer);
250 virtual ssize_t WriteString (
const std::string &buffer)
251 {
return WriteString (buffer.c_str ()); }
262 virtual std::string GetStatus ()
const;
282 virtual bool IsBlocking ()
const {
return (_timeout._sec != 0 ||
283 _timeout._usec != 0); }
287 virtual bool CanRead ()
const {
return _canRead; }
291 virtual bool CanWrite ()
const {
return _canWrite; }
307 Port (
unsigned int debug,
Timeout timeout,
bool canRead,
bool canWrite,
bool alwaysOpen);
309 void ProcessOptions (
const std::map<std::string, std::string> &options);
310 virtual bool ProcessOption (
const std::string &option,
const std::string &value);
311 virtual void CheckPort (
bool read) = 0;
316 void operator= (
const Port&);
Base Port class.
Definition port.h:80
virtual ssize_t BytesAvailableWait()=0
Get the number of bytes waiting after blocking for the timeout.
std::string GetPortType() const
Get the port type.
Definition port.h:266
virtual bool CanWrite() const
Get the write permissions of the port.
Definition port.h:291
virtual bool CanRead() const
Get the read permissions of the port.
Definition port.h:287
virtual ssize_t ReadLine(std::string &buffer)
Read a new-line terminated string of data.
Definition port.h:195
virtual void SetCanWrite(bool canWrite)=0
Set the write permissions of the port.
virtual void Flush()=0
Flush the port's input and output buffers, discarding all data.
virtual void SetTimeout(Timeout timeout)=0
Set the timeout value. Set seconds to -1 to disable timeouts and block forever.
virtual bool IsBlocking() const
Get the blocking property of the port. If the timeout is non-zero, the port will block.
Definition port.h:282
virtual ssize_t BytesAvailable()=0
Get the number of bytes waiting to be read at the port. Returns immediatly.
virtual ssize_t Read(void *const buffer, size_t count)=0
Read from the port.
virtual void Open()=0
Open the port.
virtual void SetCanRead(bool canRead)=0
Set the read permissions of the port.
virtual void Drain()=0
Drain the port's output buffers.
virtual ssize_t ReadFull(void *const buffer, size_t count)=0
Read the requested quantity of data from the port.
virtual bool IsOpen() const =0
Check if the port is open.
void SetDebug(int debug)
Set the debug level.
Definition port.h:268
virtual Timeout GetTimeout() const
Get the timeout.
Definition port.h:279
virtual ssize_t Write(const void *const buffer, size_t count)=0
Write data to the port.
virtual void Close()=0
Close the port.
int GetDebug() const
Get the debug level.
Definition port.h:270
An object used to represent timeouts.
Definition timeout.h:63
FlexiPort data communications library.