Skip to navigation

holoscan::config::ConfigView

Beta
View as Markdown

Borrow an immutable semantic value for inspection and codec traversal.

A view shares ownership of its immutable node; values returned from a Document or ConfigValue remain usable after the originating object is destroyed. A default-constructed view is invalid. Concurrent reads of valid views are safe.

#include <holoscan/config/document.hpp>

Constructors

ConfigView

holoscan::config::ConfigView::ConfigView() noexcept = default

Create an invalid sentinel view.


Methods

valid

bool holoscan::config::ConfigView::valid() const noexcept

Return whether this view addresses a semantic value.

kind

ConfigValueKind holoscan::config::ConfigView::kind() const noexcept

Return the semantic alternative, or kNull for an invalid view.

size

std::size_t holoscan::config::ConfigView::size() const noexcept

Return the immediate child count for an array or object.

Returns: Zero for a scalar or invalid view.

as_bool

bool holoscan::config::ConfigView::as_bool() const

Return the Boolean value.

Returns: The stored Boolean.

Throws: ConfigException with CONFIG_TYPE_MISMATCH when this is not Boolean.

try_as_bool

ConfigResult<bool> holoscan::config::ConfigView::try_as_bool() const noexcept

Try to return the Boolean value.

Returns: The stored Boolean or CONFIG_TYPE_MISMATCH.

as_signed_integer

std::int64_t holoscan::config::ConfigView::as_signed_integer() const

Return the signed 64-bit integer value.

Returns: The stored integer.

Throws: ConfigException with CONFIG_TYPE_MISMATCH when the kind differs.

try_as_signed_integer

ConfigResult<std::int64_t> holoscan::config::ConfigView::try_as_signed_integer() const noexcept

Try to return the signed 64-bit integer value.

Returns: The stored integer or CONFIG_TYPE_MISMATCH.

as_unsigned_integer

std::uint64_t holoscan::config::ConfigView::as_unsigned_integer() const

Return the unsigned 64-bit integer value.

Returns: The stored integer.

Throws: ConfigException with CONFIG_TYPE_MISMATCH when the kind differs.

try_as_unsigned_integer

ConfigResult<std::uint64_t> holoscan::config::ConfigView::try_as_unsigned_integer() const noexcept

Try to return the unsigned 64-bit integer value.

Returns: The stored integer or CONFIG_TYPE_MISMATCH.

as_floating

double holoscan::config::ConfigView::as_floating() const

Return the finite binary64 value.

Returns: The stored number.

Throws: ConfigException with CONFIG_TYPE_MISMATCH when the kind differs.

try_as_floating

ConfigResult<double> holoscan::config::ConfigView::try_as_floating() const noexcept

Try to return the finite binary64 value.

Returns: The stored number or CONFIG_TYPE_MISMATCH.

as_string

std::string_view holoscan::config::ConfigView::as_string() const

Borrow the UTF-8 string bytes.

Do not retain the returned view from a temporary unless another object owns the node.

Returns: A view valid while this ConfigView remains alive.

Throws: ConfigException with CONFIG_TYPE_MISMATCH when the kind differs.

try_as_string

ConfigResult<std::string_view> holoscan::config::ConfigView::try_as_string() const noexcept

Try to borrow the UTF-8 string bytes.

Do not retain the returned view from a temporary unless another object owns the node.

Returns: A borrowed view or CONFIG_TYPE_MISMATCH.

element

ConfigView holoscan::config::ConfigView::element(
std::size_t index
) const

Return one array element or object value by insertion index.

Returns: A shareable child view.

Throws: ConfigException with CONFIG_PATH_NOT_FOUND or CONFIG_TYPE_MISMATCH.

Parameters

index
std::size_t

Zero-based child index.

try_element

ConfigResult<ConfigView> holoscan::config::ConfigView::try_element(
std::size_t index
) const noexcept

Try to return one child by insertion index.

Returns: A shareable child view or a structured kind/index failure.

Parameters

index
std::size_t

Zero-based child index.

key

std::string_view holoscan::config::ConfigView::key(
std::size_t index
) const

Borrow one object key by insertion index.

Do not retain the returned view from a temporary unless another object owns the node.

Returns: UTF-8 key bytes valid while this view remains alive.

Throws: ConfigException on an invalid kind or index.

Parameters

index
std::size_t

Zero-based object entry index.

try_key

ConfigResult<std::string_view> holoscan::config::ConfigView::try_key(
std::size_t index
) const noexcept

Try to borrow one object key by insertion index.

Do not retain the returned view from a temporary unless another object owns the node.

Returns: A borrowed key or a structured kind/index failure.

Parameters

index
std::size_t

Zero-based object entry index.

member

ConfigView holoscan::config::ConfigView::member(
std::string_view key
) const

Return a required object member.

Returns: A shareable child view.

Throws: ConfigException with CONFIG_PATH_NOT_FOUND or CONFIG_TYPE_MISMATCH.

Parameters

key
std::string_view

Exact UTF-8 key bytes.

try_member

ConfigResult<ConfigView> holoscan::config::ConfigView::try_member(
std::string_view key
) const noexcept

Try to return a required object member.

Returns: A shareable child view or a structured kind/missing-member failure.

Parameters

key
std::string_view

Exact UTF-8 key bytes.

find_member

std::optional<ConfigView> holoscan::config::ConfigView::find_member(
std::string_view key
) const

Find an object member without treating absence as failure.

Returns: An optional child view; absence is not an error.

Throws: ConfigException with CONFIG_TYPE_MISMATCH for a non-object or invalid view.

Parameters

key
std::string_view

Exact UTF-8 key bytes.

try_find_member

ConfigResult<std::optional<ConfigView>> holoscan::config::ConfigView::try_find_member(
std::string_view key
) const noexcept

Try to find an object member without treating absence as failure.

Returns: An optional child view or CONFIG_TYPE_MISMATCH.

Parameters

key
std::string_view

Exact UTF-8 key bytes.

to_value

ConfigValue holoscan::config::ConfigView::to_value() const noexcept

Convert this view into a value sharing the same immutable node.

Returns: The shareable owning value. An invalid view produces a null value.


Member variables

NameTypeDescription
node_std::shared_ptr< const detail::ConfigNode >
valid_bool