dodo  0.0.1
A C++ library to create containerized Linux services
dodo::network::StringReadBuffer Class Reference

String based VirtualReadBuffer, conventient for testing purposes as parsers can be tested against strings instead of network sources. More...

#include <socketreadbuffer.hpp>

Inheritance diagram for dodo::network::StringReadBuffer:
Collaboration diagram for dodo::network::StringReadBuffer:

Public Member Functions

 StringReadBuffer (const std::string &data)
 Construct a FileReadBuffer. More...
 
virtual char get () const
 Get the current char from VirtualReadBuffer. More...
 
virtual common::SystemError next ()
 Move to the next char from the VirtualReadBuffer. More...
 
- Public Member Functions inherited from dodo::network::VirtualReadBuffer
size_t getUnderflowCount () const
 Return the number of times underflow() was invoked. More...
 

Protected Member Functions

virtual common::SystemError underflow ()
 If the buffer_ underflows, the buffer_ must be reset refilledwith new data from the source. More...
 

Protected Attributes

std::string data_
 The string data backing the buffer. More...
 
size_t idx_
 The current index into the string buffer. More...
 
- Protected Attributes inherited from dodo::network::VirtualReadBuffer
char * buffer_
 The buffer. More...
 
ssize_t bufsize_
 The size of buffer_. More...
 
size_t underflows_
 The number underflow() invocations. More...
 

Detailed Description

String based VirtualReadBuffer, conventient for testing purposes as parsers can be tested against strings instead of network sources.

Definition at line 185 of file socketreadbuffer.hpp.

Constructor & Destructor Documentation

◆ StringReadBuffer()

dodo::network::StringReadBuffer::StringReadBuffer ( const std::string &  data)
inlineexplicit

Construct a FileReadBuffer.

Parameters
dataThe string data

Definition at line 192 of file socketreadbuffer.hpp.

References data_, and idx_.

Member Function Documentation

◆ get()

virtual char dodo::network::StringReadBuffer::get ( ) const
inlinevirtual

Get the current char from VirtualReadBuffer.

Returns
The current character read.
See also
next()

Implements dodo::network::VirtualReadBuffer.

Definition at line 196 of file socketreadbuffer.hpp.

References data_, and idx_.

◆ next()

virtual common::SystemError dodo::network::StringReadBuffer::next ( )
inlinevirtual

Move to the next char from the VirtualReadBuffer.

Note that call will return a SystemError::ecEAGAIN if there is no more data (received within the prevailing timeout).

Returns
SystemError::ecOK and c is valid, or an SystemError.

Implements dodo::network::VirtualReadBuffer.

Definition at line 198 of file socketreadbuffer.hpp.

References data_, dodo::common::SystemError::ecEAGAIN, dodo::common::SystemError::ecOK, and idx_.

◆ underflow()

virtual common::SystemError dodo::network::StringReadBuffer::underflow ( )
inlineprotectedvirtual

If the buffer_ underflows, the buffer_ must be reset refilledwith new data from the source.

Returns
Systemerror::ecOK on succes.

Implements dodo::network::VirtualReadBuffer.

Definition at line 202 of file socketreadbuffer.hpp.

References dodo::common::SystemError::ecOK.

Field Documentation

◆ data_

std::string dodo::network::StringReadBuffer::data_
protected

The string data backing the buffer.

Definition at line 202 of file socketreadbuffer.hpp.

Referenced by get(), next(), and StringReadBuffer().

◆ idx_

size_t dodo::network::StringReadBuffer::idx_
protected

The current index into the string buffer.

Definition at line 212 of file socketreadbuffer.hpp.

Referenced by get(), next(), and StringReadBuffer().


The documentation for this class was generated from the following file: