Describe Helpers
Public header: #include "brookesia/lib_utils/describe_helpers.hpp"
Overview
describe_helpers uses Boost.Describe and Boost.JSON for object description plus serialization and deserialization, reducing boilerplate for structs, enums, and complex types.
Features
Reflection for enums and struct members
JSON encode/decode for strings, numbers, bools, containers, optionals, etc.
Handles variant, optional, map, vector, and related composites
Debug-friendly description output
API Reference
Header File
Classes
-
class DescribeFormatManager
Singleton that stores the global default
DescribeOutputFormat.Public Functions
-
inline void set_format(const DescribeOutputFormat &fmt)
Set the process-wide default output format.
- Parameters
fmt – New global format.
-
inline const DescribeOutputFormat &get_format() const
Get the current process-wide default output format.
- Returns
Reference to the active global format.
-
inline void reset_to_default()
Restore the built-in default output format.
Public Static Functions
-
static inline DescribeFormatManager &instance()
Get the singleton instance.
- Returns
Reference to the global format manager.
-
inline void set_format(const DescribeOutputFormat &fmt)
Macros
-
BROOKESIA_DESCRIBE_STRUCT(C, Bases, Members)
Register a struct with Boost.Describe reflection.
-
BROOKESIA_DESCRIBE_ENUM(C, ...)
Register an enum with Boost.Describe reflection.
-
BROOKESIA_DESCRIBE_ENUM_TO_STR(value)
Convert a described enum value to a string.
-
BROOKESIA_DESCRIBE_ENUM_TO_NUM(value)
Convert an enum value to its underlying integer value.
-
BROOKESIA_DESCRIBE_NUM_TO_ENUM(number, ret_value)
Convert an integer value to a described enum value.
-
BROOKESIA_DESCRIBE_STR_TO_ENUM(str, ret_value)
Convert an enumerator name to a described enum value.
-
BROOKESIA_DESCRIBE_TO_JSON(value)
Convert a supported value to
boost::json::value.
-
BROOKESIA_DESCRIBE_FROM_JSON(json_value, ret_value)
Convert a
boost::json::valueto a supported C++ value.
-
BROOKESIA_DESCRIBE_JSON_SERIALIZE(value)
Serialize a supported value to JSON text.
-
BROOKESIA_DESCRIBE_JSON_DESERIALIZE(str, ret_value)
Deserialize JSON text into a supported C++ value.
-
BROOKESIA_DESCRIBE_FORMAT_VERBOSE
Verbose multi-line formatting preset.
-
BROOKESIA_DESCRIBE_FORMAT_JSON
JSON-like formatting preset.
-
BROOKESIA_DESCRIBE_FORMAT_COMPACT
Compact single-line formatting preset.
-
BROOKESIA_DESCRIBE_FORMAT_DEFAULT
Default human-readable formatting preset.
-
BROOKESIA_DESCRIBE_FORMAT_PYTHON
Python-dict-inspired formatting preset.
-
BROOKESIA_DESCRIBE_FORMAT_CPP
C++ designated-initializer-inspired formatting preset.
-
BROOKESIA_DESCRIBE_SET_GLOBAL_FORMAT(fmt)
Set the global default string formatting preset.
-
BROOKESIA_DESCRIBE_GET_GLOBAL_FORMAT()
Get the global default string formatting preset.
-
BROOKESIA_DESCRIBE_RESET_GLOBAL_FORMAT()
Reset the global default string formatting preset.
-
BROOKESIA_DESCRIBE_TO_STR(value)
Convert a supported value to a string with the global default format.
-
BROOKESIA_DESCRIBE_TO_STR_WITH_FMT(value, fmt)
Convert a supported value to a string with an explicit format preset.