Kleidos API Search

In development. It changes without notice.

Topic

Fixed-Capacity Containers

Text, lists, queues and functions that keep what they hold inside themselves and never allocate.

Type Holds
kleidos::platform::str::InplaceString Text
kleidos::platform::InplaceVector A list, as std::inplace_vector does
kleidos::platform::InplaceQueue A queue of one task
kleidos::platform::InplaceFunction A function to call, with what it captured

What does not fit is refused, with a false or by leaving the container as it was. The ones that may hold a secret can wipe themselves. A queue between two tasks is RTOS Facade.

See also
Safe Strings, RTOS Facade

Files

file src/util/inplace_function.h
Fixed-size, heap-free type-erased callable (a std::function without the heap).
file src/util/inplace_queue.h
Fixed-capacity, heap-free FIFO ring buffer (in-place storage).
file src/util/inplace_string.h
Fixed-capacity, heap-free, always-NUL-terminating string value type.
file src/util/inplace_vector.h
Fixed-capacity, heap-free sequence container (in-place storage).

Classes

class kleidos::util::InplaceFunction< R(Args...), Capacity >
Fixed-size heap-free callable for signature R(Args...). More about kleidos::util::InplaceFunction< R(Args...), Capacity >
class kleidos::util::InplaceQueue< T, Capacity >
Fixed-capacity FIFO ring buffer holding up to Capacity elements. More about kleidos::util::InplaceQueue< T, Capacity >
class kleidos::util::str::InplaceString< Capacity >
Fixed-capacity, heap-free string holding up to Capacity characters. More about kleidos::util::str::InplaceString< Capacity >
class kleidos::util::InplaceVector< T, Capacity >
Fixed-capacity sequence container holding up to Capacity elements. More about kleidos::util::InplaceVector< T, Capacity >

safe_string facade overloads for InplaceString

Mirror the std::array<char,N> overloads in safe_string.h so the str:: free functions operate on an InplaceString just as uniformly, keeping existing str::copy(field, src) / str::length(field) call sites working when a buffer is migrated from std::array to InplaceString.

template<size_t Capacity>
size_tkleidos::util::str::copy (InplaceString< Capacity > &dest, const char *src) noexcept
Replace dest with src (truncating to its capacity).
template<size_t Capacity>
size_tkleidos::util::str::append (InplaceString< Capacity > &dest, const char *src) noexcept
Append src to dest (truncating to its capacity).
template<size_t Capacity>
size_tkleidos::util::str::length (const InplaceString< Capacity > &str) noexcept
Length of str in characters, excluding the terminating NUL.

Function Documentation

append() #

template<size_t Capacity>
size_t kleidos::util::str::append(InplaceString< Capacity > & dest, const char * src)
inlinenoexcept

Append src to dest (truncating to its capacity).

Template Parameters
NameMeaning
CapacityDestination capacity.
Parameters
NameMeaning
destDestination string.
srcSource C string; treated as empty if nullptr.
Returns
Resulting length, excluding the terminating NUL.

copy() #

template<size_t Capacity>
size_t kleidos::util::str::copy(InplaceString< Capacity > & dest, const char * src)
inlinenoexcept

Replace dest with src (truncating to its capacity).

Template Parameters
NameMeaning
CapacityDestination capacity.
Parameters
NameMeaning
destDestination string.
srcSource C string; treated as empty if nullptr.
Returns
Resulting length, excluding the terminating NUL.

length() #

template<size_t Capacity>
size_t kleidos::util::str::length(const InplaceString< Capacity > & str)
inlinenoexcept

Length of str in characters, excluding the terminating NUL.

Template Parameters
NameMeaning
CapacityString capacity.
Parameters
NameMeaning
strString to measure.
Returns
Current length.