DotNameLib
Loading...
Searching...
No Matches
dotnamecpp::utils::JsonSerializer Class Referencefinal

#include <JsonSerializer.hpp>

Inheritance diagram for dotnamecpp::utils::JsonSerializer:
Collaboration diagram for dotnamecpp::utils::JsonSerializer:

Public Member Functions

 JsonSerializer (std::shared_ptr< IFileReader > fileReader, std::shared_ptr< IFileWriter > fileWriter)
 JsonSerializer (const JsonSerializer &)=delete
JsonSerializeroperator= (const JsonSerializer &)=delete
 JsonSerializer (JsonSerializer &&)=delete
JsonSerializeroperator= (JsonSerializer &&)=delete
 ~JsonSerializer () override=default
Result< nlohmann::json, JsonErrorloadFromFile (const std::filesystem::path &filePath) const override
 Load JSON from file.
Result< void, JsonErrorsaveToFile (const std::filesystem::path &filePath, const nlohmann::json &jsonData, int indent=2) const override
 Save JSON to file.
Result< nlohmann::json, JsonErrorparse (const std::string &jsonString) const override
 Parse JSON from string.
Result< std::string, JsonErrortoString (const nlohmann::json &jsonData, int indent=2) const override
 Convert JSON to string.
Public Member Functions inherited from dotnamecpp::utils::IJsonSerializer
virtual ~IJsonSerializer ()=default

Constructor & Destructor Documentation

◆ JsonSerializer() [1/3]

dotnamecpp::utils::JsonSerializer::JsonSerializer ( std::shared_ptr< IFileReader > fileReader,
std::shared_ptr< IFileWriter > fileWriter )
Here is the caller graph for this function:

◆ JsonSerializer() [2/3]

dotnamecpp::utils::JsonSerializer::JsonSerializer ( const JsonSerializer & )
delete
Here is the call graph for this function:

◆ JsonSerializer() [3/3]

dotnamecpp::utils::JsonSerializer::JsonSerializer ( JsonSerializer && )
delete
Here is the call graph for this function:

◆ ~JsonSerializer()

dotnamecpp::utils::JsonSerializer::~JsonSerializer ( )
overridedefault

Member Function Documentation

◆ loadFromFile()

Result< nlohmann::json, JsonError > dotnamecpp::utils::JsonSerializer::loadFromFile ( const std::filesystem::path & filePath) const
nodiscardoverridevirtual

Load JSON from file.

Parameters
filePath
Returns
Result<nlohmann::json, JsonError>

Implements dotnamecpp::utils::IJsonSerializer.

Here is the call graph for this function:

◆ operator=() [1/2]

JsonSerializer & dotnamecpp::utils::JsonSerializer::operator= ( const JsonSerializer & )
delete
Here is the call graph for this function:

◆ operator=() [2/2]

JsonSerializer & dotnamecpp::utils::JsonSerializer::operator= ( JsonSerializer && )
delete
Here is the call graph for this function:

◆ parse()

Result< nlohmann::json, JsonError > dotnamecpp::utils::JsonSerializer::parse ( const std::string & jsonString) const
nodiscardoverridevirtual

Parse JSON from string.

Parameters
jsonString
Returns
Result<nlohmann::json, JsonError>

Implements dotnamecpp::utils::IJsonSerializer.

Here is the caller graph for this function:

◆ saveToFile()

Result< void, JsonError > dotnamecpp::utils::JsonSerializer::saveToFile ( const std::filesystem::path & filePath,
const nlohmann::json & jsonData,
int indent = 2 ) const
nodiscardoverridevirtual

Save JSON to file.

Parameters
filePath
jsonData
indentIndentation level (default: 2)
Returns
Result<void, JsonError>

Implements dotnamecpp::utils::IJsonSerializer.

Here is the call graph for this function:

◆ toString()

Result< std::string, JsonError > dotnamecpp::utils::JsonSerializer::toString ( const nlohmann::json & jsonData,
int indent = 2 ) const
nodiscardoverridevirtual

Convert JSON to string.

Parameters
jsonData
indentIndentation level (default: 2)
Returns
Result<std::string, JsonError>

Implements dotnamecpp::utils::IJsonSerializer.

Here is the caller graph for this function:

The documentation for this class was generated from the following files: