Skip to navigation

holoscan::config::EncodeContext

Beta
View as MarkdownOpen in Claude

Carry package-owned monotonic state for one encode call tree.

Applications receive this non-copyable object only inside ConfigCodec callbacks. A context and its children borrow top-level call state and must not escape the callback. It is not thread-safe; one top-level encode owns one independent context tree.

#include <holoscan/config/codec.hpp>

Constructors

EncodeContext

holoscan::config::EncodeContext::EncodeContext(
std::string path,
detail::CodecCallState &state,
std::uint32_t depth
)

Assignment operators

operator=

EncodeContext & holoscan::config::EncodeContext::operator=(
const EncodeContext &
) = delete

Disable copy assignment because the context borrows one call’s budget state.


Methods

path

std::string_view holoscan::config::EncodeContext::path() const noexcept

Return the owned RFC 6901 path for the value currently being encoded.

encode_child

template <class T>
ConfigResult<ConfigValue> holoscan::config::EncodeContext::encode_child(
std::string_view token,
const T &value,
const EncodeOptions &options
)

Encode one nested value under an owned child path.

Returns: The owning encoded semantic child or its structured failure.

Template parameters

T
class

Nested owning type with a visible complete codec specialization.

Parameters

token
std::string_view

Unescaped object key or decimal array index for the child.

value
const T &

Borrowed typed child value.

options
const EncodeOptions &

Immutable policy shared by the top-level invocation.

charge_allocation

ConfigResult<void> holoscan::config::EncodeContext::charge_allocation(
std::size_t bytes
) noexcept

Charge an owning result allocation against this call tree before allocating it.

Returns: Success or CONFIG_LIMIT_EXCEEDED without changing the budget on failure.

Parameters

bytes
std::size_t

Number of bytes the codec is about to allocate.

charge_string

ConfigResult<void> holoscan::config::EncodeContext::charge_string(
std::size_t bytes
) noexcept

Validate one string and charge its owning result bytes before allocating it.

Returns: Success or CONFIG_LIMIT_EXCEEDED.

Parameters

bytes
std::size_t

UTF-8 bytes the codec is about to copy.

charge_container

ConfigResult<void> holoscan::config::EncodeContext::charge_container(
std::size_t entries,
std::size_t element_bytes
) noexcept

Validate one container and charge its element storage before allocating it.

Returns: Success or CONFIG_LIMIT_EXCEEDED, including multiplication overflow.

Parameters

entries
std::size_t

Number of immediate elements.

element_bytes
std::size_t

Owning storage bytes charged per element.

charge_node

ConfigResult<void> holoscan::config::EncodeContext::charge_node() noexcept

Member variables

NameTypeDescription
path_std::string
state_detail::CodecCallState &
depth_std::uint32_t