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

A class for output 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_ofakestream ()
 Constructs an output stream with a default buffer.
 
 basic_ofakestream (const basic_ofakestream &)=delete
 
 basic_ofakestream (basic_ofakestream &&)=delete
 
basic_ofakestreamoperator= (const basic_ofakestream &)=delete
 
basic_ofakestreamoperator= (basic_ofakestream &&)=delete
 
ALWAYS_INLINE ~basic_ofakestream ()
 Destructor that frees allocated memory.
 
ALWAYS_INLINE void put (const char_type cChar)
 Writes a single character to the stream.
 
ALWAYS_INLINE void write (const char_type *const pData, const std::size_t nLength)
 Writes a block of data to the stream.
 
ALWAYS_INLINE bool empty () const noexcept
 Checks if the stream is empty.
 
ALWAYS_INLINE std::size_t size () const noexcept
 Gets the stream size.
 
ALWAYS_INLINE void clear () noexcept
 Clears the stream by resetting the position.
 
ALWAYS_INLINE void operator<< (const std::basic_string< char_type > &sString)
 Writes a string to the stream using the << operator.
 
ALWAYS_INLINE void operator<< (const std::basic_string_view< char_type > &sString)
 Writes a string view to the stream using the << operator.
 
ALWAYS_INLINE std::basic_string_view< char_typeview () const noexcept
 Gets a read-only view of the current state of the stream.
 
ALWAYS_INLINE std::basic_string< char_typestr () const
 Converts the current data to a string.
 
ALWAYS_INLINE std::basic_string< char_typestr_reset ()
 Resets the stream and returns the current data as a string.
 
ALWAYS_INLINE std::basic_string< char_typesub_str (const std::size_t nBegin, std::size_t nLength) const noexcept
 Converts a portion of the current data to a string.
 

Static Public Attributes

static constexpr auto DEFAULT_BUFFER_SIZE = 64
 Default buffer size.
 
static constexpr auto EOF_VALUE = traits_type::eof()
 End-of-file marker.
 

Detailed Description

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

A class for output stream behavior with a character type.

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

Member Function Documentation

◆ empty()

template<typename char_t >
ALWAYS_INLINE bool bs::basic_ofakestream< char_t >::empty ( ) const
inlinenoexcept

Checks if the stream is empty.

Returns
True if the stream is empty, otherwise false.

◆ operator<<() [1/2]

template<typename char_t >
ALWAYS_INLINE void bs::basic_ofakestream< char_t >::operator<< ( const std::basic_string< char_type > &  sString)
inline

Writes a string to the stream using the << operator.

Parameters
sStringThe string to write.

◆ operator<<() [2/2]

template<typename char_t >
ALWAYS_INLINE void bs::basic_ofakestream< char_t >::operator<< ( const std::basic_string_view< char_type > &  sString)
inline

Writes a string view to the stream using the << operator.

Parameters
sStringThe string to write.

◆ put()

template<typename char_t >
ALWAYS_INLINE void bs::basic_ofakestream< char_t >::put ( const char_type  cChar)
inline

Writes a single character to the stream.

Parameters
cCharThe character to write.

◆ size()

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

Gets the stream size.

Returns
The stream size

◆ str()

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

Converts the current data to a string.

Returns
A string representation of the data.

◆ str_reset()

template<typename char_t >
ALWAYS_INLINE std::basic_string< char_type > bs::basic_ofakestream< char_t >::str_reset ( )
inline

Resets the stream and returns the current data as a string.

Returns
A string representation of the data and resets the stream.

◆ sub_str()

template<typename char_t >
ALWAYS_INLINE std::basic_string< char_type > bs::basic_ofakestream< char_t >::sub_str ( const std::size_t  nBegin,
std::size_t  nLength 
) const
inlinenoexcept

Converts a portion of the current data to a string.

Note
Only the part of the range that falls within the data will be copied
Parameters
nBeginBegin point of the data
nLengthLength of the data
Returns
A substring of the current data

◆ view()

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

Gets a read-only view of the current state of the stream.

Returns
A string view of the data.

◆ write()

template<typename char_t >
ALWAYS_INLINE void bs::basic_ofakestream< char_t >::write ( const char_type *const  pData,
const std::size_t  nLength 
)
inline

Writes a block of data to the stream.

Parameters
pDataPointer to the data to write.
nLengthLength of the data to write.

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