simstr 1.2.4
Yet another strings library
 
Loading...
Searching...
No Matches
simstr::chunked_string_builder< K > Class Template Reference

For constructing long dynamic strings by concatenating small pieces. More...

#include <sstring.h>

Classes

struct  portion_store
 An object that allows you to sequentially copy content into a buffer of a given size. More...
 

Public Member Functions

my_typeoperator<< (simple_str< K > data)
 Adding a piece of data.
 
my_typeoperator<< (const StrExprForType< K > auto &expr)
 Adding a string expression.
 
template<typename T>
requires std::is_same_v<T, K>
my_typeoperator<< (T data)
 Adding a symbol.
 
constexpr size_t length () const noexcept
 Length of the saved text.
 
void reset ()
 Resets the contents, but does not delete the first buffer in order to avoid allocation later.
 
template<typename Op>
void out (const Op &o) const
 Applies a functor to each stored buffer.
 
bool is_continuous () const
 Checks whether all text is located in one contiguous chunk in memory.
 
const K * begin () const
 Get a pointer to the beginning of the first buffer. It makes sense to apply only if is_continuous true.
 
void clear ()
 Clear the object, freeing all allocated buffers.
 
portion_store get_portion () const
 Get a portion_store through which data can be sequentially retrieved into an external buffer.
 
const auto & data () const
 Get internal data buffers.
 

Detailed Description

template<typename K>
class simstr::chunked_string_builder< K >

For constructing long dynamic strings by concatenating small pieces.

Selects individual blocks of a given size (or a multiple of it for large inserts) as needed. to avoid relocation of long strings. After construction, you can merge it into one line. As measurements have shown, if you then merge it into one line, it works slower than lstring +=, but more economical in memory. If you don't merge it into one line, and then iterate through buffers, it's faster. Itself is a string expression.

Member Function Documentation

◆ data()

template<typename K>
const auto & simstr::chunked_string_builder< K >::data ( ) const
inline

Get internal data buffers.

Returns
const auto&.

◆ get_portion()

template<typename K>
portion_store simstr::chunked_string_builder< K >::get_portion ( ) const
inline

Get a portion_store through which data can be sequentially retrieved into an external buffer.

Returns
portion_store.

◆ out()

template<typename K>
template<typename Op>
void simstr::chunked_string_builder< K >::out ( const Op & o) const
inline

Applies a functor to each stored buffer.

Template Parameters
Op- type of the functor, function type (const K* ptr, size_t len).
Parameters
ois a functor.

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