Evo C++ Library v0.5.1
Classes | Typedefs | Enumerations | Functions
EvoIO

Evo input/output streams. More...

Classes

class  AsyncBase
 Base class for Async I/O. More...
 
class  AsyncBuffers
 Holds data for async I/O buffers (used internally with AsyncServer and protocol implementations). More...
 
class  AsyncClient< T, Q >
 Template class for an async I/O client. More...
 
class  AsyncEventLoop
 Manages an event-loop for async I/O. More...
 
class  AsyncServer< T >
 Async I/O server for receiving and handling requests. More...
 
struct  AsyncServerHandler
 Base async I/O server handler. More...
 
class  AsyncServerReplyT< T >
 Handles sending server replies, and accounts for potentially out of order responses. More...
 
struct  Console
 Console I/O. More...
 
struct  ConsoleMT
 Multithreaded console I/O. More...
 
struct  ConsoleNotMT
 Single threaded console I/O. More...
 
struct  Date
 Structure holding a calendar date. More...
 
struct  DateTime
 Full calendar date and time of day with timezone offset. More...
 
class  Directory
 Directory reader. More...
 
class  ExceptionDirOpen
 Directory open exception for errors opening a directory for reading entries, see Exception. More...
 
class  ExceptionSocketConfig
 Socket config exception for getopt() or setopt() errors, see Exception. More...
 
class  ExceptionSocketIn
 Socket input stream exception for socket read errors, see Exception. More...
 
class  ExceptionSocketOpen
 Socket open exception for socket connect/bind/listen errors, see Exception. More...
 
class  ExceptionSocketOut
 Socket output stream exception for socket write errors, see Exception. More...
 
class  File
 File I/O stream. More...
 
class  FilePath
 File and directory path helpers. More...
 
struct  IoBase
 Base binary stream interface. More...
 
class  IoDevice
 I/O device base class for streams. More...
 
struct  IoFile
 File I/O device (used internally). More...
 
struct  IoReader
 Buffered reader for IoDevice (used internally). More...
 
struct  IoSocket
 Socket I/O device (used internally). More...
 
struct  IoWriter
 Buffered writer for IoDevice (used internally). More...
 
class  NetworkInterfaces
 Query network adapter interfaces from OS. More...
 
struct  Pipe
 Pipe stream access. More...
 
class  PipeIn
 Input stream for reading from pipe. More...
 
class  PipeOut
 Output stream for writing to pipe. More...
 
class  Socket
 Socket I/O stream. More...
 
struct  SocketAddress
 Generic socket address (used internally). More...
 
struct  SocketAddressBase
 Base socket address. More...
 
struct  SocketAddressInfo
 Resolves socket name/address to socket address info. More...
 
struct  SocketAddressIp
 TCP/IP socket address. More...
 
struct  SocketAddressUnix
 Unix Domain socket address (linux/unix). More...
 
class  SocketCast
 Socket for I/O casting (datagram/UDP). More...
 
class  Stream< T >
 Input/Output stream implementation. More...
 
struct  StreamBase
 Base text and binary stream interface. More...
 
struct  StreamExtMT< T, M >
 Extends an existing stream with mutex for multithreaded synchronization. More...
 
struct  StreamFormatter< T >
 Stream output formatter with state. More...
 
class  StreamIn< T >
 Input stream implementation. More...
 
struct  StreamMT< T >
 Stream with mutex for multithreaded synchronization. More...
 
struct  StreamMT< File >
 Stream with mutex for multithreaded synchronization, specialized for File. More...
 
class  StreamOut< T >
 Output stream implementation. More...
 
struct  SysDir
 System directory reader (used internally). More...
 
struct  SysLinuxIo
 
struct  TimeOfDay
 Structure holding a time of day. More...
 
struct  TimeZoneOffset
 Structure holding a time zone offset from UTC. More...
 

Typedefs

typedef AsyncServerReplyT AsyncServerReply
 Handles sending server replies – see AsyncServerReplyT. More...
 
typedef StreamMT< FileFileMT
 File with mutex for synchonization – see File and StreamMT<File> More...
 
typedef StreamMT< PipeInPipeInMT
 Input pipe with mutex for synchonization – see StreamMT. More...
 
typedef StreamMT< PipeOutPipeOutMT
 Output pipe with mutex for synchonization – see StreamMT. More...
 

Enumerations

enum  AsyncError {
  aeNONE = 0, aeCONNECT, aeCLOSED, aeIO,
  aeIO_READ, aeIO_WRITE, aeTIMEOUT, aeCLIENT
}
 Async I/O error type. More...
 
enum  AsyncReadResult { arrERROR = 0, arrDONE, arrMORE }
 Async I/O read results used by protocol events. More...
 
enum  Open {
  oREAD = O_RDONLY, oREAD_WRITE = O_RDWR, oREAD_WRITE_NEW = O_RDWR | O_CREAT | O_TRUNC, oREAD_APPEND = O_RDWR | O_APPEND,
  oREAD_APPEND_NEW = O_RDWR | O_APPEND | O_CREAT | O_TRUNC, oWRITE = O_WRONLY, oWRITE_NEW = O_WRONLY | O_CREAT | O_TRUNC, oAPPEND = O_WRONLY | O_CREAT | O_APPEND,
  oAPPEND_NEW = O_WRONLY | O_APPEND | O_CREAT | O_TRUNC
}
 Open mode for files and streams. More...
 
enum  Seek { sBegin = SEEK_SET, sCurrent = SEEK_CUR, sEnd = SEEK_END }
 Seek starting position. More...
 

Functions

const char * async_error_msg (AsyncError err)
 Get error message for AsyncError code. More...
 
Consolecon ()
 Shortcut for Console::get(). More...
 
ConsoleMTcon_mt ()
 Shortcut for ConsoleMT::get(). More...
 
const char * errormsg_socket (Error error)
 Get socket error message for error code. More...
 
Stringget_abspath (String &outpath, SubString &path)
 Get absolute path for given input path. More...
 
Stringget_cwd (String &outpath)
 Store current working directory in string. More...
 
bool open_readable (Open open)
 Check whether open mode is readable. More...
 
bool open_writable (Open open)
 Check whether open mode is writable. More...
 
Error set_cwd (const char *path, bool excep=1)
 Set current working directory. More...
 

Detailed Description

Evo input/output streams.

Typedef Documentation

◆ AsyncServerReply

Handles sending server replies – see AsyncServerReplyT.

◆ FileMT

typedef StreamMT<File> FileMT

File with mutex for synchonization – see File and StreamMT<File>

◆ PipeInMT

Input pipe with mutex for synchonization – see StreamMT.

◆ PipeOutMT

Output pipe with mutex for synchonization – see StreamMT.

Enumeration Type Documentation

◆ AsyncError

enum AsyncError

Async I/O error type.

Enumerator
aeNONE 

No error.

aeCONNECT 

Connection refused (clients only)

aeCLOSED 

Socket closed by other side.

aeIO 

I/O unrecoverable error.

aeIO_READ 

I/O read error.

aeIO_WRITE 

I/O write error.

aeTIMEOUT 

I/O timeout.

aeCLIENT 

Client protocol error (set by protocol implementation)

◆ AsyncReadResult

Async I/O read results used by protocol events.

Enumerator
arrERROR 

An error occurred.

arrDONE 

Done reading request.

arrMORE 

More to read for request.

◆ Open

enum Open

Open mode for files and streams.

Enumerator
oREAD 

Read only.

oREAD_WRITE 

Read and write.

oREAD_WRITE_NEW 

Read and write, create/replace.

oREAD_APPEND 

Read and write/append.

oREAD_APPEND_NEW 

Read and write/append, create/replace.

oWRITE 

Write only.

oWRITE_NEW 

Write only, create/replace.

oAPPEND 

Write/append only, created if needed.

oAPPEND_NEW 

Write/append only, create/replace.

◆ Seek

enum Seek

Seek starting position.

Enumerator
sBegin 

Seek from beginning.

sCurrent 

Seek from current position.

sEnd 

Seek to end.

Function Documentation

◆ async_error_msg()

const char* evo::async_error_msg ( AsyncError  err)
inline

Get error message for AsyncError code.

Parameters
errError code to get message for
Returns
Error message string pointer – always terminated, never empty or null

◆ con()

Console& evo::con ( )
inline

Shortcut for Console::get().

Returns
Console reference

◆ con_mt()

ConsoleMT& evo::con_mt ( )
inline

Shortcut for ConsoleMT::get().

Returns
ConsoleMT reference

◆ errormsg_socket()

const char* evo::errormsg_socket ( Error  error)
inline

Get socket error message for error code.

  • This gives more socket specific error messages where applicable, and for general errors uses errormsg()
Parameters
errorError code – see Error
Returns
Message for error code (null terminated, always an immutable string literal)

◆ get_abspath()

String& evo::get_abspath ( String outpath,
SubString path 
)
inline

Get absolute path for given input path.

  • #include <evo/dir.h>
  • This calls FilePath::abs() (with strict=false) to see if input path is an absolute path, if so this is the output path
  • If input path is relative, this joins it with the current working directory to make it an absolute path
  • This calls FilePath::normalize() to normalize the result absolute path
    • If you want to contain the input path to the current directory for security reasons, call FilePath::normalize() on it first
  • Windows: Caution: This is not thread safe in Windows, and not safe in shared libraries
  • See also: get_cwd()
Parameters
outpathStores output absolute path [out]
pathPath to get absolute path for
Returns
Reference to outpath, set to null if path is null

◆ get_cwd()

String& evo::get_cwd ( String outpath)
inline

Store current working directory in string.

Parameters
outpathString to store current working directory [out]
Returns
Reference to outpath with absolute path to current working directory, set to null if this somehow fails (unlikely)

◆ open_readable()

bool evo::open_readable ( Open  open)
inline

Check whether open mode is readable.

Parameters
openOpen mode
Returns
Whether mode is readable

◆ open_writable()

bool evo::open_writable ( Open  open)
inline

Check whether open mode is writable.

Parameters
openOpen mode
Returns
Whether mode is writable

◆ set_cwd()

Error evo::set_cwd ( const char *  path,
bool  excep = 1 
)
inline

Set current working directory.

  • #include <evo/dir.h>
  • This is generally not thread safe since it affects the whole process
  • Windows: Caution: This is not thread safe in Windows, and not safe in shared libraries
  • See also: get_cwd()
Parameters
pathDirectory path to set
excepWhether to enable exceptions on error, default set by Evo config: EVO_EXCEPTIONS
Returns
Error code, ENone for success, throws exception on error if excep=true