staticlib_io  1.2.11
 All Classes Namespaces Files Functions Variables
Public Member Functions | List of all members
staticlib::io::array_sink< AllocFun, FreeFun > Class Template Reference

Growing heap array, that can release underlying buffer. More...

#include <staticlib/io/array_sink.hpp>

Public Member Functions

 array_sink (AllocFun alloc_fun, FreeFun free_fun, size_t initial_capacity, float grow_coef=1.5)
 Constructor.
 array_sink (const array_sink &)
 Deleted copy constructor.
array_sink & operator= (const array_sink &)
 Deleted copy assignment operator.
 array_sink (array_sink &&other) STATICLIB_NOEXCEPT
 Move constructor.
array_sink & operator= (array_sink &&other) STATICLIB_NOEXCEPT
 Move assignment operator.
 ~array_sink () STATICLIB_NOEXCEPT
 Destructor.
std::streamsize write (span< const char > span)
 Write implementation.
std::streamsize flush ()
 No-op flush.
span< char > release ()
 Releases underlying buffer and returns it inside the span.
char * data ()
 Underlying buffer accessor.
const char * data () const
 Underlying buffer const accessor.
size_t size () const
 Size accessor.

Detailed Description

template<typename AllocFun, typename FreeFun>
class staticlib::io::array_sink< AllocFun, FreeFun >

Growing heap array, that can release underlying buffer.

Constructor & Destructor Documentation

template<typename AllocFun , typename FreeFun >
staticlib::io::array_sink< AllocFun, FreeFun >::array_sink ( AllocFun  alloc_fun,
FreeFun  free_fun,
size_t  initial_capacity,
float  grow_coef = 1.5 
)
inline

Constructor.

Parameters
alloc_funfunction to use to allocate memory
free_funfunction to use to free memory
initial_capacityinitial capacity to allocate*
template<typename AllocFun , typename FreeFun >
staticlib::io::array_sink< AllocFun, FreeFun >::array_sink ( const array_sink< AllocFun, FreeFun > &  )

Deleted copy constructor.

Parameters
otherinstance
template<typename AllocFun , typename FreeFun >
staticlib::io::array_sink< AllocFun, FreeFun >::array_sink ( array_sink< AllocFun, FreeFun > &&  other)
inline

Move constructor.

Parameters
otherother instance
template<typename AllocFun , typename FreeFun >
staticlib::io::array_sink< AllocFun, FreeFun >::~array_sink ( )
inline

Destructor.

Member Function Documentation

template<typename AllocFun , typename FreeFun >
char* staticlib::io::array_sink< AllocFun, FreeFun >::data ( )
inline

Underlying buffer accessor.

Returns
pointer to underlying buffer
template<typename AllocFun , typename FreeFun >
const char* staticlib::io::array_sink< AllocFun, FreeFun >::data ( ) const
inline

Underlying buffer const accessor.

Returns
const pointer to underlying buffer
template<typename AllocFun , typename FreeFun >
std::streamsize staticlib::io::array_sink< AllocFun, FreeFun >::flush ( )
inline

No-op flush.

Returns
zero
template<typename AllocFun , typename FreeFun >
array_sink& staticlib::io::array_sink< AllocFun, FreeFun >::operator= ( const array_sink< AllocFun, FreeFun > &  )

Deleted copy assignment operator.

Parameters
otherinstance
Returns
this instance
template<typename AllocFun , typename FreeFun >
array_sink& staticlib::io::array_sink< AllocFun, FreeFun >::operator= ( array_sink< AllocFun, FreeFun > &&  other)
inline

Move assignment operator.

Parameters
otherother instance
Returns
this instance
template<typename AllocFun , typename FreeFun >
span<char> staticlib::io::array_sink< AllocFun, FreeFun >::release ( )
inline

Releases underlying buffer and returns it inside the span.

Returned buffer is always NUL-terminated and must be freed by the client. Sink is left in empty state.

Returns
span with sink buffer
template<typename AllocFun , typename FreeFun >
size_t staticlib::io::array_sink< AllocFun, FreeFun >::size ( ) const
inline

Size accessor.

Returns
current size of the buffer
template<typename AllocFun , typename FreeFun >
std::streamsize staticlib::io::array_sink< AllocFun, FreeFun >::write ( span< const char >  span)
inline

Write implementation.

Parameters
spanbuffer span
Returns
number of bytes processed

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