|
tagval 0.2.0
Modern C++23 header-only library of tagged values (open/closed enumerations with metadata)
|
Optional nlohmann::json integration. More...
#include <tagval/base.hpp>#include <tagval/error.hpp>#include <nlohmann/json.hpp>#include <concepts>#include <string>#include <string_view>
Include dependency graph for json_nlohmann.hpp:
This graph shows which files directly or indirectly include this file:Go to the source code of this file.
Namespaces | |
| namespace | tagval |
Functions | |
| template<typename T > requires std::derived_from<T, detail::TagValBaseTag> | |
| void | tagval::to_json (::nlohmann::json &j, const T &v) |
| template<typename T > requires std::derived_from<T, detail::TagValBaseTag> | |
| void | tagval::from_json (const ::nlohmann::json &j, T &v) |
Optional nlohmann::json integration.
Activates when TAGVAL_WITH_NLOHMANN_JSON is defined, or when <nlohmann/json.hpp> is on the include path.
Wire format: the bare code string.
Status::active() <-> "active"
from_json on an unknown code throws tagval::UnknownCodeError — even for open-ended kinds, deserialization never auto-creates an entry. The thrown exception propagates out of j.get<T>() exactly like a json-library error, but is the same exception type the rest of the tagval API throws, so a single catch (const tagval::UnknownCodeError&) covers both call paths.