Base Framework
Public Member Functions | Static Public Attributes | Protected Types | Protected Member Functions | Protected Attributes | List of all members
FormatInputStream Class Reference

Reader of formatted input. More...

#include <base/string/FormatInputStream.h>

Inherits FilterInputStream.

Public Member Functions

 FormatInputStream (InputStream &in)
 
unsigned int available () const
 
char getCharacter ()
 
String getWord ()
 
String getLine ()
 
unsigned int read (uint8 *buffer, unsigned int size, bool nonblocking=false)
 
 ~FormatInputStream ()
 
- Public Member Functions inherited from FilterInputStream
 FilterInputStream (InputStream &in)
 
void close ()
 
unsigned int skip (unsigned int count)
 
void wait () const
 
bool wait (unsigned int timeout) const
 
- Public Member Functions inherited from Stream
virtual ~Stream () noexcept(false)
 
- Public Member Functions inherited from ReferenceCountedObject
 ReferenceCountedObject () noexcept
 
 ReferenceCountedObject (const ReferenceCountedObject &copy) noexcept
 
 ReferenceCountedObject (ReferenceCountedObject &&move) noexcept
 
ReferenceCountedObjectoperator= (const ReferenceCountedObject &copy) noexcept
 
ReferenceCountedObjectoperator= (ReferenceCountedObject &&move) noexcept
 
MemorySize getNumberOfReferences_INTERNAL () const noexcept
 
virtual bool useGarbageCollector () const noexcept
 
- Public Member Functions inherited from DynamicObject
 DynamicObject () noexcept
 
bool isValidObject () const noexcept
 
virtual ~DynamicObject () noexcept(false)
 
 _COM_AZURE_DEV__BASE__OVERRIDE_ALLOC ()
 

Static Public Attributes

static constexpr unsigned int LINE_GRANULARITY = 1024
 
static constexpr unsigned int WINDOW_SIZE = 4096
 

Protected Types

typedef Allocator< uint8 >::Iterator Iterator
 
typedef Allocator< uint8 >::ReadIterator ReadIterator
 

Protected Member Functions

bool overwriteFromSource ()
 
bool appendFromSource ()
 

Protected Attributes

Allocator< uint8 > buffer
 
Iterator head
 
ReadIterator tail
 
String line
 
- Protected Attributes inherited from FilterInputStream
InputStreamin
 

Detailed Description

Reader of formatted input.

Format input stream. This class is not MT-safe.

See also
FormatOutputStream
Version
1.0
Examples
testsuite/client.cpp, testsuite/ftp.cpp, testsuite/http.cpp, and testsuite/server.cpp.

Constructor & Destructor Documentation

◆ FormatInputStream()

FormatInputStream::FormatInputStream ( InputStream in)

Initializes the format input stream.

Parameters
inThe input stream.

◆ ~FormatInputStream()

FormatInputStream::~FormatInputStream ( )

Destroys the format input stream.

Member Function Documentation

◆ appendFromSource()

bool FormatInputStream::appendFromSource ( )
protected

Fills the internal buffer with bytes from the input stream without removing any characters already in the buffer.

◆ available()

unsigned int FormatInputStream::available ( ) const
virtual

Returns the number of bytes that can be read or skipped over without blocking.

Returns
Available number of bytes in stream.

Reimplemented from FilterInputStream.

Examples
testsuite/client.cpp, and testsuite/server.cpp.

◆ getCharacter()

char FormatInputStream::getCharacter ( )
inline

Reads one character from the stream.

◆ getLine()

String FormatInputStream::getLine ( )

Reads one line from the stream.

◆ getWord()

String FormatInputStream::getWord ( )

Reads one word from the stream.

◆ overwriteFromSource()

bool FormatInputStream::overwriteFromSource ( )
protected

Fills the internal buffer with bytes from the input stream. Removes any characters already in the buffer.

◆ read()

unsigned int FormatInputStream::read ( uint8 *  buffer,
unsigned int  size,
bool  nonblocking = false 
)
virtual

Fills the specified buffer with bytes from the stream. Blocks if asked to read more bytes than available.

Parameters
bufferThe buffer to receive the bytes.
sizeThe size of the buffer.
nonblockingSpecifies that the method may not block. Default is false.
Returns
The actual number of bytes read from the stream.

Reimplemented from FilterInputStream.

Member Data Documentation

◆ buffer

Allocator<uint8> FormatInputStream::buffer
protected

The internal buffer.

◆ head

Iterator FormatInputStream::head
protected

The current write position.

◆ line

String FormatInputStream::line
protected

Preallocated line.

◆ LINE_GRANULARITY

constexpr unsigned int FormatInputStream::LINE_GRANULARITY = 1024
staticconstexpr

Specifies the default line granularity.

◆ tail

ReadIterator FormatInputStream::tail
protected

The current read position.

◆ WINDOW_SIZE

constexpr unsigned int FormatInputStream::WINDOW_SIZE = 4096
staticconstexpr

Specifies the window size.