libdisplaydevice v2026.322.2407
C++ library to modify display devices.
json.h File Reference

Declarations for JSON conversion functions. More...

#include <set>
#include "types.h"
Include dependency graph for json.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define DD_JSON_DECLARE_CONVERTER(Type)
 Helper MACRO to declare the toJson and fromJson converters for a type.
 

Functions

bool display_device::fromJson (const std::string &string, bool &obj, std::string *error_message=nullptr)
 
bool display_device::fromJson (const std::string &string, EdidData &obj, std::string *error_message=nullptr)
 
bool display_device::fromJson (const std::string &string, EnumeratedDevice &obj, std::string *error_message=nullptr)
 
bool display_device::fromJson (const std::string &string, EnumeratedDeviceList &obj, std::string *error_message=nullptr)
 
bool display_device::fromJson (const std::string &string, SingleDisplayConfiguration &obj, std::string *error_message=nullptr)
 
bool display_device::fromJson (const std::string &string, std::set< std::string > &obj, std::string *error_message=nullptr)
 
bool display_device::fromJson (const std::string &string, std::string &obj, std::string *error_message=nullptr)
 
std::string display_device::toJson (const bool &obj, const std::optional< unsigned int > &indent=2u, bool *success=nullptr)
 
std::string display_device::toJson (const EdidData &obj, const std::optional< unsigned int > &indent=2u, bool *success=nullptr)
 
std::string display_device::toJson (const EnumeratedDevice &obj, const std::optional< unsigned int > &indent=2u, bool *success=nullptr)
 
std::string display_device::toJson (const EnumeratedDeviceList &obj, const std::optional< unsigned int > &indent=2u, bool *success=nullptr)
 
std::string display_device::toJson (const SingleDisplayConfiguration &obj, const std::optional< unsigned int > &indent=2u, bool *success=nullptr)
 
std::string display_device::toJson (const std::set< std::string > &obj, const std::optional< unsigned int > &indent=2u, bool *success=nullptr)
 
std::string display_device::toJson (const std::string &obj, const std::optional< unsigned int > &indent=2u, bool *success=nullptr)
 

Variables

const std::optional< unsigned int > display_device::JSON_COMPACT {std::nullopt}
 

Detailed Description

Declarations for JSON conversion functions.

Macro Definition Documentation

◆ DD_JSON_DECLARE_CONVERTER

#define DD_JSON_DECLARE_CONVERTER ( Type)
Value:
[[nodiscard]] std::string toJson(const Type &obj, const std::optional<unsigned int> &indent = 2u, bool *success = nullptr); \
[[nodiscard]] bool fromJson(const std::string &string, Type &obj, std::string *error_message = nullptr);

Helper MACRO to declare the toJson and fromJson converters for a type.

*Examples**

EnumeratedDeviceList devices;
DD_LOG(info) << "Got devices:\n" << toJson(devices);
#define DD_LOG(level)
Helper MACRO that disables output string computation if log level is not enabled.
Definition logging.h:153