commons 0.1.5
Header-only C++23 library of common/shared types for the C++ libraries
Loading...
Searching...
No Matches
comms::Icon Struct Reference

An Iconify icon identifier — a set:name pair such as mdi:abacus. More...

#include <icon.hpp>

Public Member Functions

constexpr std::string_view value () const noexcept
 The whole set:name string.
 
constexpr std::string_view set () const noexcept
 The set prefix (before the :), e.g. mdi.
 
constexpr std::string_view name () const noexcept
 The icon name (after the :), e.g. abacus.
 
std::string to_string () const
 The canonical set:name string as a std::string.
 

Static Public Member Functions

static constexpr Icon from (const std::string_view value)
 Build from a whole set:name value, e.g.
 
static constexpr Icon from (const std::string_view set, const std::string_view name)
 Build by joining set and name with a :.
 
static constexpr std::optional< Iconparse (const std::string_view value)
 Non-throwing validation: returns the Icon for a well-formed value (exactly one :, non-empty set and name, total length <= capacity) or std::nullopt.
 

Static Public Attributes

static constexpr usize capacity = 64
 Inline buffer capacity.
 

Detailed Description

An Iconify icon identifier — a set:name pair such as mdi:abacus.

The full set:name string is stored inline in buf_; len_ is its length. Bytes past len_ stay zero (the buffer is value-initialized and the factories only ever write len_ bytes), which keeps the defaulted == well-behaved.

Member Function Documentation

◆ from() [1/2]

static constexpr Icon comms::Icon::from ( const std::string_view  set,
const std::string_view  name 
)
inlinestaticconstexpr

Build by joining set and name with a :.

Same validation and failure modes as the single-argument from.

◆ from() [2/2]

static constexpr Icon comms::Icon::from ( const std::string_view  value)
inlinestaticconstexpr

Build from a whole set:name value, e.g.

"mdi:abacus". Throws on malformed input (std::invalid_argument) or one too long to fit (std::length_error); in a constant-evaluated context either becomes a compile error.

Member Data Documentation

◆ capacity

constexpr usize comms::Icon::capacity = 64
staticconstexpr

Inline buffer capacity.

The longest MDI set:name is 46 chars; 64 leaves headroom for other sets and custom identifiers.


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