ezconfig
Create C++ Objects from Yaml and Json
Loading...
Searching...
No Matches
json_fwd.hpp File Reference

Json factory forward declarations. More...

#include <nlohmann/json_fwd.hpp>
#include "factory.hpp"
#include "macro.hpp"
Include dependency graph for json_fwd.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  nlohmann::adl_serializer< std::shared_ptr< Base > >
 Converter json -> std::shared_ptr<Base> using json::Create(). More...
 
struct  nlohmann::adl_serializer< std::unique_ptr< Base > >
 Converter json -> std::unique_ptr<Base> using json::Create(). More...
 

Concepts

concept  ezconfig::json::Constructible
 

Macros

#define EZ_JSON_DECLARE(Base)
 Declare a json factory for a base class.
 

Functions

template<typename Base >
std::unique_ptr< Base > ezconfig::json::Create (const nlohmann::json &j)
 Create an object using the factory.
 

Detailed Description

Json factory forward declarations.

Include this file in the header for the base class.

Definition in file json_fwd.hpp.

Macro Definition Documentation

◆ EZ_JSON_DECLARE

#define EZ_JSON_DECLARE ( Base)
Value:
EZ_FACTORY_DECLARE(Base, const nlohmann::json &)

Declare a json factory for a base class.

Parameters
Basefactory base class.

The factory creates pointers to Base.

Example: Declare a MyBase json factory.

#define EZ_JSON_DECLARE(Base)
Declare a json factory for a base class.
Definition json_fwd.hpp:50

Definition at line 50 of file json_fwd.hpp.

Function Documentation

◆ Create()

template<typename Base >
std::unique_ptr< Base > ezconfig::json::Create ( const nlohmann::json & j)

Create an object using the factory.

Template Parameters
Basefactory base class
Parameters
jjson data
auto obj = JsonCreate<MyBase>(nlohmann::json::parse(data));

Definition at line 89 of file json.hpp.