ezconfig
Create C++ Objects from Yaml and Json
|
Json factory. More...
Go to the source code of this file.
Concepts | |
concept | ezconfig::json::JsonParseable |
Macros | |
#define | EZ_JSON_DEFINE(Base) |
Define a global json factory for a base class. | |
#define | EZ_JSON_REGISTER(Base, tag, Derived, ...) |
Register a tagged conversion with a json factory. | |
Functions | |
template<typename Base , typename Derived , typename Intermediate = Derived> requires ( std::is_base_of_v<Base, Derived> && JsonParseable<Intermediate> && std::is_constructible_v<Derived, Intermediate &&>) | |
void | ezconfig::json::Add (const std::string &tag) |
Add a factory method. | |
template<typename Base > | |
std::unique_ptr< Base > | ezconfig::json::Create (const nlohmann::json &j) |
Create an object using the factory. | |
Json factory.
Include this file in implementation file for the base class and any derived classes.
Definition in file json.hpp.
#define EZ_JSON_DEFINE | ( | Base | ) |
Define a global json factory for a base class.
Do this in the base class implementation file.
Base | factory base class. |
Example: Define a MyBase yaml factory.
#define EZ_JSON_REGISTER | ( | Base, | |
tag, | |||
Derived, | |||
... ) |
Register a tagged conversion with a json factory.
Do this in the implementation files for derived classes.
Base | factory base class. |
tag | conversion identifier (string). |
Derived | factory derived class. |
Intermediate | optional intermediate class. |
Example: Register a creator for MyDerived with tag "mytag".
void ezconfig::json::Add | ( | const std::string & | tag | ) |
std::unique_ptr< Base > ezconfig::json::Create | ( | const nlohmann::json & | j | ) |