mod_servlet
C++Servlets
 All Classes Files Functions Variables Typedefs Macros Pages
servlet::string_sink< CharT, Traits > Class Template Reference

Implementation of sink to std::string Besides to having similar functionality to std::basic_ostringstream this class also allows to access directly the destination std::string More...

#include <io_string.h>

Public Types

typedef std::basic_string
< CharT, Traits > 
string_type
 Type of the underlying string.
 
typedef
std::experimental::basic_string_view
< CharT, Traits > 
string_view_type
 string_view for string_type
 

Public Member Functions

 string_sink (std::size_t max_size=std::string::npos)
 Constructs object with optional argument to specify maximum size of the destination string_type. More...
 
std::streamsize write (const CharT *s, std::streamsize n)
 Writes first n character from the array s into destination string More...
 
void flush ()
 Sets flushed flag to true
 
void reset ()
 Resets the sink.
 
string_view_type view () const
 Returns string_view to the destination std::string More...
 
string_typestr ()
 Returns the reference to the destination std::string More...
 
bool was_flushed () const
 Return flag which indicates whether this sink was flushed since last reset. More...
 
std::size_t characters_written () const
 Return the number of character which were written into this sink since last reset. More...
 

Detailed Description

template<typename CharT, typename Traits = std::char_traits<CharT>>
class servlet::string_sink< CharT, Traits >

Implementation of sink to std::string Besides to having similar functionality to std::basic_ostringstream this class also allows to access directly the destination std::string

Template Parameters
CharTcharacter type for this stream
Traitscahracter traits type to be used in this stream.
See Also
sink

Constructor & Destructor Documentation

template<typename CharT , typename Traits = std::char_traits<CharT>>
servlet::string_sink< CharT, Traits >::string_sink ( std::size_t  max_size = std::string::npos)
inline

Constructs object with optional argument to specify maximum size of the destination string_type.

By default this size is unlimited.

Parameters
max_sizeSize limit for destination string

Member Function Documentation

template<typename CharT , typename Traits = std::char_traits<CharT>>
std::size_t servlet::string_sink< CharT, Traits >::characters_written ( ) const
inline

Return the number of character which were written into this sink since last reset.

Returns
the number of characters written to this sink since last reset.
template<typename CharT , typename Traits = std::char_traits<CharT>>
string_type& servlet::string_sink< CharT, Traits >::str ( )
inline

Returns the reference to the destination std::string

Returns
reference to the destination string
template<typename CharT , typename Traits = std::char_traits<CharT>>
string_view_type servlet::string_sink< CharT, Traits >::view ( ) const
inline

Returns string_view to the destination std::string

Returns
view of the destination string.
template<typename CharT , typename Traits = std::char_traits<CharT>>
bool servlet::string_sink< CharT, Traits >::was_flushed ( ) const
inline

Return flag which indicates whether this sink was flushed since last reset.

Returns
true if this sink was flushed since last reset
template<typename CharT , typename Traits = std::char_traits<CharT>>
std::streamsize servlet::string_sink< CharT, Traits >::write ( const CharT *  s,
std::streamsize  n 
)
inline

Writes first n character from the array s into destination string

Parameters
sPointer to an array of at least n elements
nNumber of characters to write.
Returns
Number of successefully written characters

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