staticlib_io  1.2.11
 All Classes Namespaces Files Functions Variables
Namespaces | Classes | Functions
staticlib::io Namespace Reference

Namespaces

namespace  detail
namespace  detail_array_sink
namespace  hex_sink_detail

Classes

class  array_sink
 Growing heap array, that can release underlying buffer. More...
class  array_source
 Source implementation that reads data from the specified char buffer. More...
class  buffered_sink
 Sink wrapper that buffers the output. More...
class  buffered_source
 Source wrapper that buffers the input. More...
class  copying_source
 Source wrapper that copies all the data read from it into the sink specified on construction. More...
class  counting_sink
 Sink wrapper that counts the number of bytes written through it. More...
class  counting_source
 Source wrapper that counts the number of bytes read through it. More...
class  flushable_sink
 Sink wrapper that implements no-op flush. More...
class  hex_sink
 Sink wrapper that encodes data into Hexadecimal. More...
class  hex_source
 Source wrapper that decodes data from Hexadecimal. More...
class  io_exception
 Module specific exception. More...
class  limited_source
 Source wrapper that limits the number of bytes read through it and returns EOF on threshold exceed. More...
class  memory_sink
 Sink implementation that writes into fixed-size memory area. More...
class  multi_source
 Source wrapper that contains a range of sources to read data from. More...
class  null_sink
 Sink implementation with no-op write method. More...
class  reference_sink
 Sink wrapper that holds a "std::reference_wrapper" to the underlying sink. More...
class  reference_source
 Source wrapper that holds a "std::reference_wrapper" to the underlying source. More...
class  replacer_source
 Source wrapper that replaces specified substrings in the input. More...
class  shared_sink
 Sink wrapper that holds a "std::shared_ptr" to the underlying sink. More...
class  shared_source
 Source wrapper that holds a "std::shared_ptr" to the underlying source. More...
class  source_istream
 Helper template that wraps an arbitrary source into owning stream instance. More...
class  bad_span_access_exception
 Span-specific exception. More...
class  span
 Non-owning range of elements in contiguous memory. More...
class  streambuf_sink
 Sink implementation that wraps a pointer to the "std::streambuf". More...
class  streambuf_source
 Source implementation that wraps a pointer to the "std::streambuf". More...
class  string_sink
 Sink implementation that writes data to the underlying "std::string". More...
class  string_source
 Source implementation that reads data from the specified string. More...
class  unbuffered_istreambuf
 Unbuffered implementation of input streambuf, wraps Source reference (in terms of Boost.Iostreams). More...
class  unbuffered_ostreambuf
 Unbuffered implementation of output streambuf, wraps Sink reference (in terms of Boost.Iostreams). More...
class  unique_sink
 Sink wrapper that holds a "std::unique_ptr" to the underlying sink. More...
class  unique_source
 Source wrapper that holds a "std::unique_ptr" to the underlying source. More...

Functions

template<typename AllocFun , typename FreeFun >
array_sink< AllocFun, FreeFun > make_array_sink (AllocFun alloc_fun, FreeFun free_fun, size_t initial_capacity=15)
 Factory function for creating array_sink, uses "std::malloc" and "std::free".
array_sink< char *(*)(int),
void(*)(char *)> 
make_array_sink (size_t initial_capacity=15)
 Factory function for creating array_sink, uses "std::malloc" and "std::free".
template<typename Sink , class = typename std::enable_if<!std::is_lvalue_reference<Sink>::value>::type>
buffered_sink< Sink > make_buffered_sink (Sink &&sink)
 Factory function for creating buffered sinks, created sink wrapper will own specified sink.
template<typename Sink >
buffered_sink< reference_sink
< Sink > > 
make_buffered_sink (Sink &sink)
 Factory function for creating buffered sinks, created sink wrapper will NOT own specified sink.
template<typename Source , class = typename std::enable_if<!std::is_lvalue_reference<Source>::value>::type>
buffered_source< Source > make_buffered_source (Source &&source)
 Factory function for creating buffered sources, created source wrapper will own specified source.
template<typename Source >
buffered_source
< reference_source< Source > > 
make_buffered_source (Source &source)
 Factory function for creating buffered sources, created source wrapper will NOT own specified source.
template<typename Source , typename Sink , class = typename std::enable_if<!std::is_lvalue_reference<Source>::value>::type, class = typename std::enable_if<!std::is_lvalue_reference<Sink>::value>::type>
copying_source< Source, Sink > make_copying_source (Source &&source, Sink &&sink)
 Factory function for creating copying sources, created source wrapper will own specified source and sink.
template<typename Source , typename Sink >
copying_source
< reference_source< Source >
, reference_sink< Sink > > 
make_copying_source (Source &source, Sink &sink)
 Factory function for creating copying sources, created source wrapper will NOT own specified source and sink.
template<typename Sink , class = typename std::enable_if<!std::is_lvalue_reference<Sink>::value>::type>
counting_sink< Sink > make_counting_sink (Sink &&sink)
 Factory function for creating counting sinks, created sink wrapper will own specified sink.
template<typename Sink >
counting_sink< reference_sink
< Sink > > 
make_counting_sink (Sink &sink)
 Factory function for creating counting sinks, created sink wrapper will NOT own specified sink.
template<typename Source , class = typename std::enable_if<!std::is_lvalue_reference<Source>::value>::type>
counting_source< Source > make_counting_source (Source &&source)
 Factory function for creating counting sources, created source wrapper will own specified source.
template<typename Source >
counting_source
< reference_source< Source > > 
make_counting_source (Source &source)
 Factory function for creating counting sources, created source wrapper will NOT own specified source.
template<typename NonFlushableSink , class = typename std::enable_if<!std::is_lvalue_reference<NonFlushableSink>::value>::type>
flushable_sink< NonFlushableSink > make_flushable_sink (NonFlushableSink &&sink)
 Factory function for creating flushable sinks, created sink wrapper will own specified sink.
template<typename NonFlushableSink >
flushable_sink< reference_sink
< NonFlushableSink > > 
make_flushable_sink (NonFlushableSink &sink)
 Factory function for creating flushable sinks, created sink wrapper will NOT own specified sink.
std::string hex_from_string (const std::string &plain)
 Encodes the specified string as a hexadecimal string.
std::string string_to_hex (const std::string &plain)
 Encodes the specified string as a hexadecimal string.
std::string string_from_hex (const std::string &hexstr)
 Decodes the specified hexadecimal string.
std::string format_hex_and_plain (const std::string &hexstr, const std::string &plain)
 Format hex and plain strings as a hex+plain string.
std::string format_hex (const std::string &hexstr)
 Format hex-string as a hex+plain string.
std::string format_plain_as_hex (const std::string &plain)
 Format plain string as a hex+plain string.
template<typename Sink , class = typename std::enable_if<!std::is_lvalue_reference<Sink>::value>::type>
hex_sink< Sink > make_hex_sink (Sink &&sink)
 Factory function for creating hex sinks, created sink wrapper will own specified sink.
template<typename Sink >
hex_sink< reference_sink< Sink > > make_hex_sink (Sink &sink)
 Factory function for creating hex sinks, created sink wrapper will NOT own specified sink.
template<typename Source , class = typename std::enable_if<!std::is_lvalue_reference<Source>::value>::type>
hex_source< Source > make_hex_source (Source &&source)
 Factory function for creating hex sources, created source wrapper will own specified source.
template<typename Source >
hex_source< reference_source
< Source > > 
make_hex_source (Source &source)
 Factory function for creating hex sources, created source wrapper will NOT own specified source.
template<typename Source , class = typename std::enable_if<!std::is_lvalue_reference<Source>::value>::type>
limited_source< Source > make_limited_source (Source &&source, size_t limit_bytes)
 Factory function for creating limited sources, created source wrapper will own specified source.
template<typename Source >
limited_source
< reference_source< Source > > 
make_limited_source (Source &source, size_t limit_bytes)
 Factory function for creating limited sources, created source wrapper will NOT own specified source.
template<typename Range , class = typename std::enable_if<!std::is_lvalue_reference<Range>::value>::type>
multi_source< Range > make_multi_source (Range &&range)
 Factory function for creating multi sources, created source wrapper will own specified sources.
template<typename Range >
multi_source< std::vector
< reference_source< typename
Range::value_type > > > 
make_multi_source (Range &range)
 Factory function for creating multi sources, created source wrapper will NOT own specified sources.
template<typename Sink >
void write_all (Sink &sink, span< const char > span)
 Writes buffer contents to the specified Sink ensuring that the specified number of bytes are written to Sink (making multiple write calls to Sink if needed).
template<typename Source >
size_t read_all (Source &src, span< char > span)
 Reads specified number of bytes from the Source into the buffer.
template<typename Source >
void read_exact (Source &src, span< char > span)
 Reads specified number of bytes from the Source into the buffer.
template<typename Source , typename Sink >
size_t copy_all (Source &src, Sink &sink, span< char > span)
 Copies data from Source to Sink using specified buffer until source will be exhausted.
template<typename Source , typename Sink , uint16_t BufferSize = 4096>
size_t copy_all (Source &src, Sink &sink)
 Copies data from Source to Sink using on-stack array buffer until source will be exhausted.
template<typename Source , typename IntTypeSkip >
void skip (Source &src, span< char > span, IntTypeSkip to_skip)
 Skips specified number of bytes reading data repeatedly from specified source into specified buffer.
std::string str_replace (const std::string &input, std::map< std::string, std::string > values)
 Replaces "{{placeholders}}" with specified values in specified string.
template<typename Sink >
reference_sink< Sink > make_reference_sink (Sink &sink)
 Factory function for creating reference sinks.
template<typename Source >
reference_source< Source > make_reference_source (Source &source)
 Factory function for creating reference sources.
template<typename Source , class = typename std::enable_if<!std::is_lvalue_reference<Source>::value>::type>
replacer_source< Source > make_replacer_source (Source &&source, std::map< std::string, std::string > values, std::function< void(const std::string &)> on_error)
 Factory function for creating replacer sources, created source wrapper will own specified source.
template<typename Source >
replacer_source
< reference_source< Source > > 
make_replacer_source (Source &source, std::map< std::string, std::string > values, std::function< void(const std::string &)> on_error)
 Factory function for creating replacer sources, created source wrapper will NOT own specified source.
template<typename Sink >
shared_sink< Sink > make_shared_sink (std::shared_ptr< Sink > sink)
 Factory function for creating shared sinks.
template<typename Source >
shared_source< Source > make_shared_source (std::shared_ptr< Source > source)
 Factory function for creating shared sources.
template<typename Source , class = typename std::enable_if<!std::is_lvalue_reference<Source>::value>::type>
std::unique_ptr< std::istream > make_source_istream_ptr (Source &&source)
 Factory function for creating source istream unique pointers, created source wrapper will own specified source.
template<typename Source >
std::unique_ptr< std::istream > make_source_istream_ptr (Source &source)
 Factory function for creating source istream unique pointers, created source wrapper will NOT own specified source.
template<typename T , typename IntType >
span< T > make_span (T *buffer, IntType length)
 Helper function, creates span instance.
template<typename T , size_t Length>
span< T > make_span (std::array< T, Length > &buffer)
 Helper function, creates span instance from array.
template<typename T >
span< T > make_span (std::vector< T > &buffer)
 Helper function, creates span instance from vector.
template<typename Source , class = typename std::enable_if<!std::is_lvalue_reference<Source>::value>::type>
unbuffered_istreambuf< Source > make_unbuffered_istreambuf (Source &&source)
 Factory function for creating unbuffered_istreambuf sources, created source wrapper will own specified source.
template<typename Source , class = typename std::enable_if<!std::is_lvalue_reference<Source>::value>::type>
std::unique_ptr
< unbuffered_istreambuf
< Source > > 
make_unbuffered_istreambuf_ptr (Source &&source)
 Factory function for creating unbuffered_istreambuf sources, created source wrapper will own specified source.
template<typename Source >
unbuffered_istreambuf
< reference_source< Source > > 
make_unbuffered_istreambuf (Source &source)
 Factory function for creating unbuffered_istreambuf sources, created source wrapper will NOT own specified source.
template<typename Source >
std::unique_ptr
< unbuffered_istreambuf
< reference_source< Source > > > 
make_unbuffered_istreambuf_ptr (Source &source)
 Factory function for creating unbuffered_istreambuf sources, created source wrapper will NOT own specified source.
template<typename Sink , class = typename std::enable_if<!std::is_lvalue_reference<Sink>::value>::type>
unbuffered_ostreambuf< Sink > make_unbuffered_ostreambuf (Sink &&sink)
 Factory function for creating unbuffered_ostreambuf sinks, created sink wrapper will own specified sink.
template<typename Sink , class = typename std::enable_if<!std::is_lvalue_reference<Sink>::value>::type>
std::unique_ptr
< unbuffered_ostreambuf< Sink > > 
make_unbuffered_ostreambuf_ptr (Sink &&sink)
 Factory function for creating unbuffered_ostreambuf sinks, created sink wrapper will own specified sink.
template<typename Sink >
unbuffered_ostreambuf
< reference_sink< Sink > > 
make_unbuffered_ostreambuf (Sink &sink)
 Factory function for creating unbuffered_ostreambuf sinks, created sink wrapper will NOT own specified sink.
template<typename Sink >
std::unique_ptr
< unbuffered_ostreambuf
< reference_sink< Sink > > > 
make_unbuffered_ostreambuf_ptr (Sink &sink)
 Factory function for creating unbuffered_ostreambuf sinks, created sink wrapper will NOT own specified sink.
template<typename Sink >
unique_sink< Sink > make_unique_sink (Sink *sink)
 Factory function for creating unique sinks.
template<typename Source >
unique_source< Source > make_unique_source (Source *source)
 Factory function for creating unique sources.

Function Documentation

template<typename Source , typename Sink >
size_t staticlib::io::copy_all ( Source &  src,
Sink &  sink,
span< char >  span 
)

Copies data from Source to Sink using specified buffer until source will be exhausted.

Parameters
srciostreams source
sinkiostreams sink
spanbuffer span
Returns
number of bytes copied
template<typename Source , typename Sink , uint16_t BufferSize = 4096>
size_t staticlib::io::copy_all ( Source &  src,
Sink &  sink 
)

Copies data from Source to Sink using on-stack array buffer until source will be exhausted.

Parameters
srciostreams source
sinkiostreams sink
Returns
number of bytes copied
std::string staticlib::io::format_hex ( const std::string &  hexstr)
inline

Format hex-string as a hex+plain string.

Formats specified hex-string as a hex [plain] string. Non-printable characters in plain string are replaced with spaces.

Intended to be used for logging.

Parameters
hexstrstring in hexadecimal encoding
Returns
formatted string
std::string staticlib::io::format_hex_and_plain ( const std::string &  hexstr,
const std::string &  plain 
)
inline

Format hex and plain strings as a hex+plain string.

Formats specified hex-string as a hex [plain] string. Non-printable characters in plain string are replaced with spaces.

Intended to be used for logging.

Parameters
hexstrstring in hexadecimal encoding
plainplain string
Returns
formatted string
std::string staticlib::io::format_plain_as_hex ( const std::string &  plain)
inline

Format plain string as a hex+plain string.

Formats specified hex-string as a hex [plain] string. Non-printable characters in plain string are replaced with spaces.

Intended to be used for logging.

Parameters
plainplain string
Returns
formatted string
std::string staticlib::io::hex_from_string ( const std::string &  plain)
inline

Encodes the specified string as a hexadecimal string.

Alias for string_to_hex to work aroung OpenSSL macro clash

Parameters
plainplain string
Returns
hex string
template<typename AllocFun , typename FreeFun >
array_sink<AllocFun, FreeFun> staticlib::io::make_array_sink ( AllocFun  alloc_fun,
FreeFun  free_fun,
size_t  initial_capacity = 15 
)

Factory function for creating array_sink, uses "std::malloc" and "std::free".

Parameters
alloc_funallocator function
free_fundeallocator function
initial_capacityinitial buffer capacity to allocate
Returns
array_sink
array_sink<char*(*)(int), void(*)(char*)> staticlib::io::make_array_sink ( size_t  initial_capacity = 15)
inline

Factory function for creating array_sink, uses "std::malloc" and "std::free".

Parameters
initial_capacityinitial buffer capacity to allocate
Returns
array_sink
template<typename Sink , class = typename std::enable_if<!std::is_lvalue_reference<Sink>::value>::type>
buffered_sink<Sink> staticlib::io::make_buffered_sink ( Sink &&  sink)

Factory function for creating buffered sinks, created sink wrapper will own specified sink.

Parameters
sinkdestination sink
Returns
buffered sink
template<typename Sink >
buffered_sink<reference_sink<Sink> > staticlib::io::make_buffered_sink ( Sink &  sink)

Factory function for creating buffered sinks, created sink wrapper will NOT own specified sink.

Parameters
sinkdestination sink
Returns
buffered sink
template<typename Source , class = typename std::enable_if<!std::is_lvalue_reference<Source>::value>::type>
buffered_source<Source> staticlib::io::make_buffered_source ( Source &&  source)

Factory function for creating buffered sources, created source wrapper will own specified source.

Parameters
sourceinput source
Returns
buffered source
template<typename Source >
buffered_source<reference_source<Source> > staticlib::io::make_buffered_source ( Source &  source)

Factory function for creating buffered sources, created source wrapper will NOT own specified source.

Parameters
sourceinput source
Returns
buffered source
template<typename Source , typename Sink , class = typename std::enable_if<!std::is_lvalue_reference<Source>::value>::type, class = typename std::enable_if<!std::is_lvalue_reference<Sink>::value>::type>
copying_source<Source, Sink> staticlib::io::make_copying_source ( Source &&  source,
Sink &&  sink 
)

Factory function for creating copying sources, created source wrapper will own specified source and sink.

Parameters
sourceinput source
sinkcopy sink
Returns
copying source
template<typename Source , typename Sink >
copying_source<reference_source<Source>, reference_sink<Sink> > staticlib::io::make_copying_source ( Source &  source,
Sink &  sink 
)

Factory function for creating copying sources, created source wrapper will NOT own specified source and sink.

Parameters
sourceinput source
sinkcopy sink
Returns
copying source
template<typename Sink , class = typename std::enable_if<!std::is_lvalue_reference<Sink>::value>::type>
counting_sink<Sink> staticlib::io::make_counting_sink ( Sink &&  sink)

Factory function for creating counting sinks, created sink wrapper will own specified sink.

Parameters
sinkdestination sink
Returns
counting sink
template<typename Sink >
counting_sink<reference_sink<Sink> > staticlib::io::make_counting_sink ( Sink &  sink)

Factory function for creating counting sinks, created sink wrapper will NOT own specified sink.

Parameters
sinkdestination sink
Returns
counting sink
template<typename Source , class = typename std::enable_if<!std::is_lvalue_reference<Source>::value>::type>
counting_source<Source> staticlib::io::make_counting_source ( Source &&  source)

Factory function for creating counting sources, created source wrapper will own specified source.

Parameters
sourceinput source
Returns
counting source
template<typename Source >
counting_source<reference_source<Source> > staticlib::io::make_counting_source ( Source &  source)

Factory function for creating counting sources, created source wrapper will NOT own specified source.

Parameters
sourceinput source
Returns
counting source
template<typename NonFlushableSink , class = typename std::enable_if<!std::is_lvalue_reference<NonFlushableSink>::value>::type>
flushable_sink<NonFlushableSink> staticlib::io::make_flushable_sink ( NonFlushableSink &&  sink)

Factory function for creating flushable sinks, created sink wrapper will own specified sink.

Parameters
sinkdestination sink
Returns
flushable sink
template<typename NonFlushableSink >
flushable_sink<reference_sink<NonFlushableSink> > staticlib::io::make_flushable_sink ( NonFlushableSink &  sink)

Factory function for creating flushable sinks, created sink wrapper will NOT own specified sink.

Parameters
sinkdestination sink
Returns
flushable sink
template<typename Sink , class = typename std::enable_if<!std::is_lvalue_reference<Sink>::value>::type>
hex_sink<Sink> staticlib::io::make_hex_sink ( Sink &&  sink)

Factory function for creating hex sinks, created sink wrapper will own specified sink.

Parameters
sinkdestination sink
Returns
counting sink
template<typename Sink >
hex_sink<reference_sink<Sink> > staticlib::io::make_hex_sink ( Sink &  sink)

Factory function for creating hex sinks, created sink wrapper will NOT own specified sink.

Parameters
sinkdestination sink
Returns
counting sink
template<typename Source , class = typename std::enable_if<!std::is_lvalue_reference<Source>::value>::type>
hex_source<Source> staticlib::io::make_hex_source ( Source &&  source)

Factory function for creating hex sources, created source wrapper will own specified source.

Parameters
sourceinput source
Returns
counting source
template<typename Source >
hex_source<reference_source<Source> > staticlib::io::make_hex_source ( Source &  source)

Factory function for creating hex sources, created source wrapper will NOT own specified source.

Parameters
sourceinput source
Returns
counting source
template<typename Source , class = typename std::enable_if<!std::is_lvalue_reference<Source>::value>::type>
limited_source<Source> staticlib::io::make_limited_source ( Source &&  source,
size_t  limit_bytes 
)

Factory function for creating limited sources, created source wrapper will own specified source.

Parameters
sourceinput source
limit_bytesmax number of bytes allowed to be read from this source
Returns
limited source
template<typename Source >
limited_source<reference_source<Source> > staticlib::io::make_limited_source ( Source &  source,
size_t  limit_bytes 
)

Factory function for creating limited sources, created source wrapper will NOT own specified source.

Parameters
sourceinput source
limit_bytesmax number of bytes allowed to be read from this source
Returns
limited source
template<typename Range , class = typename std::enable_if<!std::is_lvalue_reference<Range>::value>::type>
multi_source<Range> staticlib::io::make_multi_source ( Range &&  range)

Factory function for creating multi sources, created source wrapper will own specified sources.

Parameters
rangeinput sources
Returns
multi source
template<typename Range >
multi_source<std::vector<reference_source<typename Range::value_type> > > staticlib::io::make_multi_source ( Range &  range)

Factory function for creating multi sources, created source wrapper will NOT own specified sources.

Parameters
rangeinput sources
Returns
multi source
template<typename Sink >
reference_sink<Sink> staticlib::io::make_reference_sink ( Sink &  sink)

Factory function for creating reference sinks.

Parameters
sinkdestination sink
Returns
reference sink
template<typename Source >
reference_source<Source> staticlib::io::make_reference_source ( Source &  source)

Factory function for creating reference sources.

Parameters
sourceinput source
Returns
reference source
template<typename Source , class = typename std::enable_if<!std::is_lvalue_reference<Source>::value>::type>
replacer_source<Source> staticlib::io::make_replacer_source ( Source &&  source,
std::map< std::string, std::string >  values,
std::function< void(const std::string &)>  on_error 
)

Factory function for creating replacer sources, created source wrapper will own specified source.

Parameters
sourceinput source
Returns
replacer source
template<typename Source >
replacer_source<reference_source<Source> > staticlib::io::make_replacer_source ( Source &  source,
std::map< std::string, std::string >  values,
std::function< void(const std::string &)>  on_error 
)

Factory function for creating replacer sources, created source wrapper will NOT own specified source.

Parameters
sourceinput source
Returns
replacer source
template<typename Sink >
shared_sink<Sink> staticlib::io::make_shared_sink ( std::shared_ptr< Sink >  sink)

Factory function for creating shared sinks.

Parameters
sinkdestination sink
Returns
shared sink
template<typename Source >
shared_source<Source> staticlib::io::make_shared_source ( std::shared_ptr< Source >  source)

Factory function for creating shared sources.

Parameters
sourceinput source
Returns
shared source
template<typename Source , class = typename std::enable_if<!std::is_lvalue_reference<Source>::value>::type>
std::unique_ptr<std::istream> staticlib::io::make_source_istream_ptr ( Source &&  source)

Factory function for creating source istream unique pointers, created source wrapper will own specified source.

Parameters
sourceinput source
Returns
source istream pointer
template<typename Source >
std::unique_ptr<std::istream> staticlib::io::make_source_istream_ptr ( Source &  source)

Factory function for creating source istream unique pointers, created source wrapper will NOT own specified source.

Parameters
sourceinput source
Returns
source istream pointer
template<typename T , typename IntType >
span<T> staticlib::io::make_span ( T *  buffer,
IntType  length 
)

Helper function, creates span instance.

Parameters
bufferspan start pointer
lengthnumber of elements
Returns
span instance
template<typename T , size_t Length>
span<T> staticlib::io::make_span ( std::array< T, Length > &  buffer)

Helper function, creates span instance from array.

Parameters
bufferarray
Returns
span instance
template<typename T >
span<T> staticlib::io::make_span ( std::vector< T > &  buffer)

Helper function, creates span instance from vector.

Parameters
buffervector
Returns
span instance
template<typename Source , class = typename std::enable_if<!std::is_lvalue_reference<Source>::value>::type>
unbuffered_istreambuf<Source> staticlib::io::make_unbuffered_istreambuf ( Source &&  source)

Factory function for creating unbuffered_istreambuf sources, created source wrapper will own specified source.

Parameters
sourceinput source
Returns
unbuffered_istreambuf source
template<typename Source >
unbuffered_istreambuf<reference_source<Source> > staticlib::io::make_unbuffered_istreambuf ( Source &  source)

Factory function for creating unbuffered_istreambuf sources, created source wrapper will NOT own specified source.

Parameters
sourceinput source
Returns
unbuffered_istreambuf source
template<typename Source , class = typename std::enable_if<!std::is_lvalue_reference<Source>::value>::type>
std::unique_ptr<unbuffered_istreambuf<Source> > staticlib::io::make_unbuffered_istreambuf_ptr ( Source &&  source)

Factory function for creating unbuffered_istreambuf sources, created source wrapper will own specified source.

Parameters
sourceinput source
Returns
unbuffered_istreambuf source
template<typename Source >
std::unique_ptr<unbuffered_istreambuf<reference_source<Source> > > staticlib::io::make_unbuffered_istreambuf_ptr ( Source &  source)

Factory function for creating unbuffered_istreambuf sources, created source wrapper will NOT own specified source.

Parameters
sourceinput source
Returns
unbuffered_istreambuf source
template<typename Sink , class = typename std::enable_if<!std::is_lvalue_reference<Sink>::value>::type>
unbuffered_ostreambuf<Sink> staticlib::io::make_unbuffered_ostreambuf ( Sink &&  sink)

Factory function for creating unbuffered_ostreambuf sinks, created sink wrapper will own specified sink.

Parameters
sinkdestination sink
Returns
unbuffered_ostreambuf sink
template<typename Sink >
unbuffered_ostreambuf<reference_sink<Sink> > staticlib::io::make_unbuffered_ostreambuf ( Sink &  sink)

Factory function for creating unbuffered_ostreambuf sinks, created sink wrapper will NOT own specified sink.

Parameters
sinkdestination sink
Returns
unbuffered_ostreambuf sink
template<typename Sink , class = typename std::enable_if<!std::is_lvalue_reference<Sink>::value>::type>
std::unique_ptr<unbuffered_ostreambuf<Sink> > staticlib::io::make_unbuffered_ostreambuf_ptr ( Sink &&  sink)

Factory function for creating unbuffered_ostreambuf sinks, created sink wrapper will own specified sink.

Parameters
sinkdestination sink
Returns
unbuffered_ostreambuf sink
template<typename Sink >
std::unique_ptr<unbuffered_ostreambuf<reference_sink<Sink> > > staticlib::io::make_unbuffered_ostreambuf_ptr ( Sink &  sink)

Factory function for creating unbuffered_ostreambuf sinks, created sink wrapper will NOT own specified sink.

Parameters
sinkdestination sink
Returns
unbuffered_ostreambuf sink
template<typename Sink >
unique_sink<Sink> staticlib::io::make_unique_sink ( Sink *  sink)

Factory function for creating unique sinks.

Parameters
sinkdestination sink
Returns
unique sink
template<typename Source >
unique_source<Source> staticlib::io::make_unique_source ( Source *  source)

Factory function for creating unique sources.

Parameters
sourceinput source
Returns
unique source
template<typename Source >
size_t staticlib::io::read_all ( Source &  src,
span< char >  span 
)

Reads specified number of bytes from the Source into the buffer.

May read less then specified bytes only if Source became exhausted.

Parameters
srciostreams source
spanbuffer span
Returns
number of bytes read
template<typename Source >
void staticlib::io::read_exact ( Source &  src,
span< char >  span 
)

Reads specified number of bytes from the Source into the buffer.

Will throw exception if exact specified amount won't be available.

Parameters
srciostreams source
spanbuffer span
template<typename Source , typename IntTypeSkip >
void staticlib::io::skip ( Source &  src,
span< char >  span,
IntTypeSkip  to_skip 
)

Skips specified number of bytes reading data repeatedly from specified source into specified buffer.

Parameters
srcinput source
spanbuffer span
to_skipnumber of bytes to skip
std::string staticlib::io::str_replace ( const std::string &  input,
std::map< std::string, std::string >  values 
)
inline

Replaces "{{placeholders}}" with specified values in specified string.

Parameters
inputtemplate string
values"key->value" mapping
Returns
string with replaced values
std::string staticlib::io::string_from_hex ( const std::string &  hexstr)
inline

Decodes the specified hexadecimal string.

Parameters
hexstrhex string
Returns
plain string
std::string staticlib::io::string_to_hex ( const std::string &  plain)
inline

Encodes the specified string as a hexadecimal string.

Parameters
plainplain string
Returns
hex string
template<typename Sink >
void staticlib::io::write_all ( Sink &  sink,
span< const char >  span 
)

Writes buffer contents to the specified Sink ensuring that the specified number of bytes are written to Sink (making multiple write calls to Sink if needed).

Parameters
sinkiostreams sink
spanbuffer span