MySQL 9.1.0
Source Code Documentation
keyring_common::json_data::Json_reader Class Reference

Base Json_reader. More...

#include <json_reader.h>

Public Member Functions

 Json_reader (const std::string &schema, const std::string &data, std::string version_key="version", std::string array_key="elements")
 Constructor. More...
 
 Json_reader (const std::string &data)
 Constructor. More...
 
 Json_reader ()
 
virtual ~Json_reader ()=default
 Destructor. More...
 
std::string version () const
 Get version info. More...
 
size_t num_elements () const
 Get number of elements in the document. More...
 
virtual bool get_element (size_t index, meta::Metadata &metadata, data::Data &data, std::unique_ptr< Json_data_extension > &json_data_extension) const
 Fetch element from given position. More...
 
virtual bool get_elements (output_vector &output) const
 Get all elements. More...
 
bool valid () const
 
std::string property (const std::string property_key) const
 Get property from the main JSON object. More...
 

Private Attributes

rapidjson::Document document_
 Data in JSON DOM format. More...
 
const std::string version_key_
 Version key. More...
 
const std::string array_key_
 user specific elements array key More...
 
bool valid_
 Validity of the data. More...
 

Detailed Description

Base Json_reader.

Expected format for version 1.0 { "version": "1.0", "elements": [ { "user": "<user_name>", "data_id": "<name>", "data_type": "<data_type>", "data": "<hex_of_data>", "extension": [ ] }, ... ... ] }

Constructor & Destructor Documentation

◆ Json_reader() [1/3]

keyring_common::json_data::Json_reader::Json_reader ( const std::string &  schema,
const std::string &  data,
std::string  version_key = "version",
std::string  array_key = "elements" 
)

Constructor.

Parameters
[in]schemaJSON schema in string format
[in]dataJSON data in string format
[in]version_keyJSON schema version information
[in]array_keyKey for array of elements

◆ Json_reader() [2/3]

keyring_common::json_data::Json_reader::Json_reader ( const std::string &  data)

Constructor.

Parameters
[in]dataJSON Data in string format

Initializes JSON document with given data and sets validity state.

◆ Json_reader() [3/3]

keyring_common::json_data::Json_reader::Json_reader ( )

◆ ~Json_reader()

virtual keyring_common::json_data::Json_reader::~Json_reader ( )
virtualdefault

Destructor.

Member Function Documentation

◆ get_element()

bool keyring_common::json_data::Json_reader::get_element ( size_t  index,
meta::Metadata metadata,
data::Data data,
std::unique_ptr< Json_data_extension > &  json_data_extension 
) const
virtual

Fetch element from given position.

Parameters
[in]indexElement position
[out]metadataData identifier
[out]dataData
[out]json_data_extensionBackend specific extension
Returns
status of operation
Return values
falseSuccess
trueFailure

◆ get_elements()

bool keyring_common::json_data::Json_reader::get_elements ( output_vector output) const
virtual

Get all elements.

Parameters
[out]outputOutput vector
Returns
status of extracting elements
Return values
falseSuccess
trueFailure

◆ num_elements()

size_t keyring_common::json_data::Json_reader::num_elements ( ) const

Get number of elements in the document.

Returns
number elements in the document

◆ property()

std::string keyring_common::json_data::Json_reader::property ( const std::string  property_key) const

Get property from the main JSON object.

Get property value.

It is intended to be used for some specific, data file-wide properties.

Returns
value of the property
Parameters
[in]property_keykey (name) of the property
Returns
property value string in case property is present, empty string otherwise.

◆ valid()

bool keyring_common::json_data::Json_reader::valid ( ) const
inline

◆ version()

std::string keyring_common::json_data::Json_reader::version ( ) const
inline

Get version info.

Returns
version string in case same is present, empty string otherwise.

Member Data Documentation

◆ array_key_

const std::string keyring_common::json_data::Json_reader::array_key_
private

user specific elements array key

◆ document_

rapidjson::Document keyring_common::json_data::Json_reader::document_
private

Data in JSON DOM format.

◆ valid_

bool keyring_common::json_data::Json_reader::valid_
private

Validity of the data.

◆ version_key_

const std::string keyring_common::json_data::Json_reader::version_key_
private

Version key.


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