Sese Framework  2.3.0
A cross-platform framework
Loading...
Searching...
No Matches
sese::io::BaseStreamReader< T > Class Template Reference

Output stream wrapping class, UTF-8 under Windows requires special handling. More...

#include <BaseStreamReader.h>

Public Types

using Ptr = std::shared_ptr<BaseStreamReader<T>>
 

Public Member Functions

 BaseStreamReader (const Stream::Ptr &source)
 Constructor.
 
bool read (T &ch)
 Read a character.
 
std::basic_string< T > readLine ()
 Read a line.
 
const ByteBuilder::PtrgetBuffer () noexcept
 

Private Member Functions

int64_t preRead ()
 Cache ahead-of-time data.
 

Private Attributes

Stream::Ptr sourceStream
 
ByteBuilder::Ptr bufferStream
 

Detailed Description

template<typename T = char>
class sese::io::BaseStreamReader< T >

Output stream wrapping class, UTF-8 under Windows requires special handling.

Member Typedef Documentation

◆ Ptr

template<typename T = char>
using sese::io::BaseStreamReader< T >::Ptr = std::shared_ptr<BaseStreamReader<T>>

Constructor & Destructor Documentation

◆ BaseStreamReader()

template<typename T = char>
sese::io::BaseStreamReader< T >::BaseStreamReader ( const Stream::Ptr & source)
inlineexplicit

Constructor.

Parameters
sourceStream to be wrapped

References sese::io::BaseStreamReader< T >::bufferStream, and sese::io::BaseStreamReader< T >::sourceStream.

Member Function Documentation

◆ getBuffer()

template<typename T = char>
const ByteBuilder::Ptr & sese::io::BaseStreamReader< T >::getBuffer ( )
inlinenoexcept

Used to cache ahead-of-time data

Returns
Cache

References sese::io::BaseStreamReader< T >::bufferStream.

◆ preRead()

template<typename T = char>
int64_t sese::io::BaseStreamReader< T >::preRead ( )
inlineprivate

Cache ahead-of-time data.

This method is used to cache the data of the source stream in advance. It is used to improve the performance of the readLine method.

Returns
The number of bytes cached

References sese::io::BaseStreamReader< T >::bufferStream, sese::io::BaseStreamReader< T >::sourceStream, STREAM_BYTE_STREAM_SIZE_FACTOR, and STRING_BUFFER_SIZE_FACTOR.

Referenced by sese::io::BaseStreamReader< T >::read(), and sese::io::BaseStreamReader< T >::readLine().

◆ read()

template<typename T = char>
bool sese::io::BaseStreamReader< T >::read ( T & ch)
inline

Read a character.

Parameters
chCharacter container
Returns
Whether the read was successful

Cache missed, trying to read from the source

The source has been read

References sese::io::BaseStreamReader< T >::bufferStream, and sese::io::BaseStreamReader< T >::preRead().

Referenced by sese::io::BaseStreamReader< T >::readLine().

◆ readLine()

template<typename T = char>
std::basic_string< T > sese::io::BaseStreamReader< T >::readLine ( )
inline

Read a line.

Returns
Returns the read string; a length of zero indicates completion

References sese::io::BaseStreamReader< T >::bufferStream, sese::io::BaseStreamReader< T >::preRead(), and sese::io::BaseStreamReader< T >::read().

Member Data Documentation

◆ bufferStream

◆ sourceStream


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