header_utils
Loading...
Searching...
No Matches
Buffers

Buffers and stuff. More...

template<typename BUFFER >
using ghassanpl::buffer_element_type = typename decltype(detail::deduce_buffer_element_type< BUFFER >())::type
 
template<typename BUFFER , typename T >
bool ghassanpl::buffer_append (BUFFER &&buffer, T &&val)
 Primary function to append a value (preferably the buffer element type) to the buffer.
 
template<typename BUFFER >
bool ghassanpl::buffer_reserve (BUFFER &buffer, size_t additional)
 Reserves additional elements in the buffer, if possible.
 
template<typename BUFFER , typename RANGE >
requires output_buffer<BUFFER, std::ranges::range_value_t<RANGE>>
size_t ghassanpl::buffer_append_range (BUFFER &buffer, RANGE &&range)
 Appends elements in the range to the buffer
 
template<typename BUFFER , typename CHAR_TYPE >
requires output_buffer<BUFFER, CHAR_TYPE>
size_t ghassanpl::buffer_append_cstring_ptr (BUFFER &buffer, const CHAR_TYPE *cstr)
 Appends characters in the cstr to the buffer
 
template<typename BUFFER , typename CHAR_TYPE >
requires output_buffer<BUFFER, CHAR_TYPE>
size_t ghassanpl::buffer_append_cstring_ptr (BUFFER &buffer, const CHAR_TYPE *cstr, size_t max_len)
 Appends at most max_len characters in the cstr to the buffer
 
template<typename BUFFER , size_t N, typename CHAR_TYPE >
requires output_buffer<BUFFER, CHAR_TYPE>
size_t ghassanpl::buffer_append_cstring (BUFFER &buffer, const CHAR_TYPE(&cstr)[N])
 Appends characters in the cstr literal array to the buffer
 
template<typename BUFFER , typename ELEMENT_TYPE = buffer_element_type<BUFFER>>
requires output_buffer<BUFFER, ELEMENT_TYPE>
size_t ghassanpl::buffer_append_utf8 (BUFFER &buffer, char32_t cp)
 Appends UTF-8 codeunits that represent the Unicode code-point cp to the buffer. Assumes the codepoint is a valid Unicode codepoint that represents a character.
 
template<typename BUFFER , typename STRING_TYPE , typename ELEMENT_TYPE = buffer_element_type<BUFFER>>
requires output_buffer<BUFFER, ELEMENT_TYPE> && std::ranges::range<STRING_TYPE> && std::same_as<std::ranges::range_value_t<STRING_TYPE>, char32_t>
size_t ghassanpl::buffer_append_utf8 (BUFFER &buffer, STRING_TYPE &&str)
 Appends UTF-8 codeunits that represent the UTF-32 range str to the buffer.
 
template<typename BUFFER , typename POD >
requires std::is_trivially_copyable_v<POD> && bytelike<buffer_element_type<BUFFER>>
size_t ghassanpl::buffer_append_pod (BUFFER &buffer, POD const &pod)
 Appends a POD values internal object representation to a buffer.
 
template<typename BUFFER , typename CALLBACK >
requires std::invocable<CALLBACK, size_t, std::string_view, BUFFER&>
void ghassanpl::callback_format_to (BUFFER &buffer, std::string_view fmt, CALLBACK &&callback)
 TODO: Make this work - currently needs string_ops
 

Detailed Description

Buffers and stuff.

Typedef Documentation

◆ buffer_element_type

template<typename BUFFER >
using ghassanpl::buffer_element_type = typedef typename decltype(detail::deduce_buffer_element_type<BUFFER>())::type

Resolves to the destination element type of the buffer

Definition at line 31 of file buffers.h.

Function Documentation

◆ buffer_append()

template<typename BUFFER , typename T >
bool ghassanpl::buffer_append ( BUFFER &&  buffer,
T &&  val 
)

Primary function to append a value (preferably the buffer element type) to the buffer.

Definition at line 35 of file buffers.h.

◆ buffer_append_cstring()

template<typename BUFFER , size_t N, typename CHAR_TYPE >
requires output_buffer<BUFFER, CHAR_TYPE>
size_t ghassanpl::buffer_append_cstring ( BUFFER buffer,
const CHAR_TYPE(&)  cstr[N] 
)

Appends characters in the cstr literal array to the buffer

Definition at line 156 of file buffers.h.

◆ buffer_append_cstring_ptr() [1/2]

template<typename BUFFER , typename CHAR_TYPE >
requires output_buffer<BUFFER, CHAR_TYPE>
size_t ghassanpl::buffer_append_cstring_ptr ( BUFFER buffer,
const CHAR_TYPE cstr 
)

Appends characters in the cstr to the buffer

Definition at line 140 of file buffers.h.

◆ buffer_append_cstring_ptr() [2/2]

template<typename BUFFER , typename CHAR_TYPE >
requires output_buffer<BUFFER, CHAR_TYPE>
size_t ghassanpl::buffer_append_cstring_ptr ( BUFFER buffer,
const CHAR_TYPE cstr,
size_t  max_len 
)

Appends at most max_len characters in the cstr to the buffer

Definition at line 148 of file buffers.h.

◆ buffer_append_pod()

template<typename BUFFER , typename POD >
requires std::is_trivially_copyable_v<POD> && bytelike<buffer_element_type<BUFFER>>
size_t ghassanpl::buffer_append_pod ( BUFFER buffer,
POD const pod 
)

Appends a POD values internal object representation to a buffer.

Note
If, for some reason, you want to append the pod as a certain type of bytelikes

Definition at line 206 of file buffers.h.

◆ buffer_append_range()

template<typename BUFFER , typename RANGE >
requires output_buffer<BUFFER, std::ranges::range_value_t<RANGE>>
size_t ghassanpl::buffer_append_range ( BUFFER buffer,
RANGE &&  range 
)

Appends elements in the range to the buffer

Definition at line 86 of file buffers.h.

◆ buffer_append_utf8() [1/2]

template<typename BUFFER , typename ELEMENT_TYPE = buffer_element_type<BUFFER>>
requires output_buffer<BUFFER, ELEMENT_TYPE>
size_t ghassanpl::buffer_append_utf8 ( BUFFER buffer,
char32_t  cp 
)

Appends UTF-8 codeunits that represent the Unicode code-point cp to the buffer. Assumes the codepoint is a valid Unicode codepoint that represents a character.

Definition at line 164 of file buffers.h.

◆ buffer_append_utf8() [2/2]

template<typename BUFFER , typename STRING_TYPE , typename ELEMENT_TYPE = buffer_element_type<BUFFER>>
requires output_buffer<BUFFER, ELEMENT_TYPE> && std::ranges::range<STRING_TYPE> && std::same_as<std::ranges::range_value_t<STRING_TYPE>, char32_t>
size_t ghassanpl::buffer_append_utf8 ( BUFFER buffer,
STRING_TYPE &&  str 
)

Appends UTF-8 codeunits that represent the UTF-32 range str to the buffer.

Assumes all codepoints in str are valid.

See also
buffer_append_utf8(BUFFER& buffer, char32_t cp)

Definition at line 193 of file buffers.h.

◆ buffer_reserve()

template<typename BUFFER >
bool ghassanpl::buffer_reserve ( BUFFER buffer,
size_t  additional 
)

Reserves additional elements in the buffer, if possible.

Definition at line 72 of file buffers.h.

◆ callback_format_to()

template<typename BUFFER , typename CALLBACK >
requires std::invocable<CALLBACK, size_t, std::string_view, BUFFER&>
void ghassanpl::callback_format_to ( BUFFER buffer,
std::string_view  fmt,
CALLBACK &&  callback 
)

TODO: Make this work - currently needs string_ops

Definition at line 214 of file buffers.h.