BashSpark
Loading...
Searching...
No Matches
bs::basic_ifakestream< char_t > Class Template Reference

A class for input stream behavior with a character type. More...

#include <fakestream.h>

Public Types

using traits_type = std::char_traits< char_t >
 Type traits for the character type.
 
using char_type = traits_type::char_type
 Fundamental character type.
 
using int_type = traits_type::int_type
 Type for representing character values.
 

Public Member Functions

ALWAYS_INLINE basic_ifakestream ()
 Constructs an empty input stream.
 
ALWAYS_INLINE basic_ifakestream (const char *const pData, const std::size_t nSize)
 Constructs an input stream with data and size.
 
ALWAYS_INLINE basic_ifakestream (const std::string_view &sText)
 Constructs an input stream with string view.
 
 basic_ifakestream (const basic_ifakestream &)=delete
 
 basic_ifakestream (basic_ifakestream &&)=delete
 
basic_ifakestreamoperator= (const basic_ifakestream &)=delete
 
basic_ifakestreamoperator= (basic_ifakestream &&)=delete
 
ALWAYS_INLINE int_type get () noexcept
 Retrieves the next character character from the stream and moves to the next.
 
ALWAYS_INLINE int_type peek () noexcept
 Retrieves the next character from the stream. Does not increment stream position.
 
ALWAYS_INLINE int_type prev () noexcept
 Retrieves the previous character from the stream. Does not move stream position.
 
ALWAYS_INLINE void put_back () noexcept
 Returns the last read character to the stream.
 
ALWAYS_INLINE std::size_t read (char_type *const pBuffer, const std::size_t nCount) noexcept
 Reads a specified number of characters into a buffer.
 
ALWAYS_INLINE bool eof () const noexcept
 Checks if the end of the stream has been reached.
 
ALWAYS_INLINE std::size_t tell () const noexcept
 Gets the current position in the stream.
 
ALWAYS_INLINE void seek (const std::size_t pos) noexcept
 Seeks to a specified position in the stream.
 
ALWAYS_INLINE std::size_t size () const noexcept
 Gets the stream data size.
 
ALWAYS_INLINE std::basic_string_view< char_typeview () const noexcept
 Gets a read-only view of the stream data.
 
ALWAYS_INLINE std::basic_string_view< char_typesub_view (const std::size_t nBegin, std::size_t nLength) const noexcept
 Gets a read-only view of the stream data.
 
ALWAYS_INLINE std::basic_string< char_typestr () const
 Converts the data to a string.
 
ALWAYS_INLINE std::basic_string_view< char_typeremaining_view () const noexcept
 Gets a read-only view of the stream remaining data.
 
ALWAYS_INLINE std::basic_string< char_typeremaining_str () const
 Converts the remaining data to a string.
 

Static Public Attributes

static constexpr auto EOF_VALUE = traits_type::eof()
 End-of-file marker.
 

Detailed Description

template<typename char_t>
class bs::basic_ifakestream< char_t >

A class for input stream behavior with a character type.

Template Parameters
char_tThe character type (e.g., char, wchar_t).

Constructor & Destructor Documentation

◆ basic_ifakestream() [1/2]

template<typename char_t >
ALWAYS_INLINE bs::basic_ifakestream< char_t >::basic_ifakestream ( const char *const  pData,
const std::size_t  nSize 
)
inline

Constructs an input stream with data and size.

Parameters
pDataPointer to the data.
nSizeSize of the data.

◆ basic_ifakestream() [2/2]

template<typename char_t >
ALWAYS_INLINE bs::basic_ifakestream< char_t >::basic_ifakestream ( const std::string_view &  sText)
inline

Constructs an input stream with string view.

Parameters
sTextString view.

Member Function Documentation

◆ eof()

template<typename char_t >
ALWAYS_INLINE bool bs::basic_ifakestream< char_t >::eof ( ) const
inlinenoexcept

Checks if the end of the stream has been reached.

Returns
True if at end of stream, otherwise false.

◆ get()

template<typename char_t >
ALWAYS_INLINE int_type bs::basic_ifakestream< char_t >::get ( )
inlinenoexcept

Retrieves the next character character from the stream and moves to the next.

Returns
The next character or EOF_VALUE if at end of stream.

◆ peek()

template<typename char_t >
ALWAYS_INLINE int_type bs::basic_ifakestream< char_t >::peek ( )
inlinenoexcept

Retrieves the next character from the stream. Does not increment stream position.

Returns
The next character or EOF_VALUE if at end of stream.

◆ prev()

template<typename char_t >
ALWAYS_INLINE int_type bs::basic_ifakestream< char_t >::prev ( )
inlinenoexcept

Retrieves the previous character from the stream. Does not move stream position.

Returns
The next character or EOF_VALUE if at beggining of stream.

◆ read()

template<typename char_t >
ALWAYS_INLINE std::size_t bs::basic_ifakestream< char_t >::read ( char_type *const  pBuffer,
const std::size_t  nCount 
)
inlinenoexcept

Reads a specified number of characters into a buffer.

Parameters
pBufferPointer to the buffer for storing data.
nCountNumber of characters to read.
Returns
Number of characters actually read.

◆ remaining_str()

template<typename char_t >
ALWAYS_INLINE std::basic_string< char_type > bs::basic_ifakestream< char_t >::remaining_str ( ) const
inline

Converts the remaining data to a string.

Returns
A string representation of the data.

◆ remaining_view()

template<typename char_t >
ALWAYS_INLINE std::basic_string_view< char_type > bs::basic_ifakestream< char_t >::remaining_view ( ) const
inlinenoexcept

Gets a read-only view of the stream remaining data.

Returns
A string view of the data.

◆ seek()

template<typename char_t >
ALWAYS_INLINE void bs::basic_ifakestream< char_t >::seek ( const std::size_t  pos)
inlinenoexcept

Seeks to a specified position in the stream.

Parameters
posPosition to seek to.

◆ size()

template<typename char_t >
ALWAYS_INLINE std::size_t bs::basic_ifakestream< char_t >::size ( ) const
inlinenoexcept

Gets the stream data size.

Returns
The stream data size.

◆ str()

template<typename char_t >
ALWAYS_INLINE std::basic_string< char_type > bs::basic_ifakestream< char_t >::str ( ) const
inline

Converts the data to a string.

Returns
A string representation of the data.

◆ sub_view()

template<typename char_t >
ALWAYS_INLINE std::basic_string_view< char_type > bs::basic_ifakestream< char_t >::sub_view ( const std::size_t  nBegin,
std::size_t  nLength 
) const
inlinenoexcept

Gets a read-only view of the stream data.

Returns
A string view of the data.

◆ tell()

template<typename char_t >
ALWAYS_INLINE std::size_t bs::basic_ifakestream< char_t >::tell ( ) const
inlinenoexcept

Gets the current position in the stream.

Returns
Current position.

◆ view()

template<typename char_t >
ALWAYS_INLINE std::basic_string_view< char_type > bs::basic_ifakestream< char_t >::view ( ) const
inlinenoexcept

Gets a read-only view of the stream data.

Returns
A string view of the data.

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