commons 0.1.5
Header-only C++23 library of common/shared types for the C++ libraries
Loading...
Searching...
No Matches
icon.hpp File Reference

A tiny value type carrying an Iconify icon identifier such as mdi:abacus (a set:name pair). More...

#include <commons/fixed_string.hpp>
#include <commons/types.hpp>
#include <format>
#include <optional>
#include <ostream>
#include <stdexcept>
#include <string>
#include <string_view>
Include dependency graph for icon.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  comms::Icon
 An Iconify icon identifier — a set:name pair such as mdi:abacus. More...
 
struct  comms::IconifySet< Set >
 Base for a predefined Iconify set: carries the set name as a string_view. More...
 
struct  std::formatter< comms::Icon >
 Formats comms::Icon as its set:name string. Takes no format spec. More...
 

Functions

std::string comms::to_string (const Icon &i)
 Icon as its canonical set:name string.
 

Detailed Description

A tiny value type carrying an Iconify icon identifier such as mdi:abacus (a set:name pair).

comms::Icon stores the canonical set:name string inline in a fixed char buffer (no heap), so it is a constexpr literal type, trivially copyable, and usable in constexpr/static_assert contexts — much like comms::Color. Construct one from a whole value (Icon::from("mdi:abacus")) or from the two parts (Icon::from("mdi", "abacus")); both validate and reject malformed or oversize input. Icon::parse is the non-throwing variant used by the JSON integration.

Predefined catalogs (e.g. comms::Icons::mdi::abacus) are opt-in and live behind #include <commons/icons.hpp>; this header carries only the core type and the IconifySet<Set> base.

Serialization (in commons/json.hpp, gated by COMMONS_WITH_NLOHMANN_JSON): Icon travels as its set:name string.

Text output (always available): to_string, operator<<, and std::format all emit the canonical set:name string.