libcdoc 0.5.0
libcdoc::JSONConfiguration Struct Reference

A Configuration object implementation that reads values from JSON file. More...

#include <Configuration.h>

Inherits libcdoc::Configuration.

Public Member Functions

 JSONConfiguration ()
 Construct a new empty JSONConfiguration object.
 JSONConfiguration (std::istream &ifs)
 Construct a new JSONConfiguration object from input stream.
 JSONConfiguration (const std::string &file)
 Construct a new JSONConfiguration object from file.
 JSONConfiguration (const std::vector< uint8_t > &data)
 Construct a new JSONConfiguration object from bytes.
 ~JSONConfiguration ()
bool parse (std::istream &ifs)
 Read configuration data from input stream.
bool parse (const std::string &file)
 Read configuration data from file.
bool parse (const std::vector< uint8_t > &data)
 Read configuration data from byte vector.
std::string getValue (std::string_view domain, std::string_view param) const override
 get a value of configuration parameter
Public Member Functions inherited from libcdoc::Configuration
 Configuration ()=default
virtual ~Configuration () noexcept=default
 Configuration (const Configuration &)=delete
Configurationoperator= (const Configuration &)=delete
 CDOC_DISABLE_MOVE (Configuration)
std::string getValue (std::string_view param) const
 get a value of configuration parameter from the default domain
bool getBoolean (std::string_view param, bool def_val=false) const
 get boolean value of configuration parameter from the default domain
int getInt (std::string_view param, int def_val=0) const
 get integer value of configuration parameter from the default domain

Additional Inherited Members

Static Public Attributes inherited from libcdoc::Configuration
static constexpr char const * KEYSERVER_SEND_URL = "KEYSERVER_SEND_URL"
 Send URL of keyserver (Domain is server id).
static constexpr char const * KEYSERVER_FETCH_URL = "KEYSERVER_FETCH_URL"
 Fetch URL of keyserver (Domain is server id).

Detailed Description

A Configuration object implementation that reads values from JSON file.

The file should represent a single object with key/value pairs Domains are sub-objects with corresponding key/value pairs Strings are returned unquoted, everything else is returned as JSON

Constructor & Destructor Documentation

◆ JSONConfiguration() [1/4]

libcdoc::JSONConfiguration::JSONConfiguration ( )

Construct a new empty JSONConfiguration object.

◆ JSONConfiguration() [2/4]

libcdoc::JSONConfiguration::JSONConfiguration ( std::istream & ifs)

Construct a new JSONConfiguration object from input stream.

Parameters
ifsinput stream

◆ JSONConfiguration() [3/4]

libcdoc::JSONConfiguration::JSONConfiguration ( const std::string & file)

Construct a new JSONConfiguration object from file.

Parameters
filefile name

◆ JSONConfiguration() [4/4]

libcdoc::JSONConfiguration::JSONConfiguration ( const std::vector< uint8_t > & data)

Construct a new JSONConfiguration object from bytes.

Parameters
datainput data

◆ ~JSONConfiguration()

libcdoc::JSONConfiguration::~JSONConfiguration ( )

Member Function Documentation

◆ getValue()

std::string libcdoc::JSONConfiguration::getValue ( std::string_view domain,
std::string_view param ) const
overridevirtual

get a value of configuration parameter

Get a string value of configuration parameter.

Parameters
domainthe parameter domain. For keyservers this is the server ID.
paramthe parameter name.
Returns
a string value or empty string if parameter is not defined.

Reimplemented from libcdoc::Configuration.

◆ parse() [1/3]

bool libcdoc::JSONConfiguration::parse ( const std::string & file)

Read configuration data from file.

Existing values are replaced

Parameters
filefile name
Returns
true if successful

◆ parse() [2/3]

bool libcdoc::JSONConfiguration::parse ( const std::vector< uint8_t > & data)

Read configuration data from byte vector.

Existing values are replaced

Parameters
datainput data
Returns
true if successful

◆ parse() [3/3]

bool libcdoc::JSONConfiguration::parse ( std::istream & ifs)

Read configuration data from input stream.

Existing values are replaced

Parameters
ifsinput stream
Returns
true if successful

The documentation for this struct was generated from the following file:
  • Configuration.h