Fawkes API Fawkes Development Version
InterfaceData Class Reference

InterfaceData representation for JSON transfer. More...

#include <InterfaceData.h>

Public Member Functions

 InterfaceData ()
 Constructor. More...
 
 InterfaceData (const std::string &json)
 Constructor from JSON. More...
 
 InterfaceData (const rapidjson::Value &v)
 Constructor from JSON. More...
 
virtual ~InterfaceData ()
 Destructor. More...
 
virtual std::string to_json (bool pretty=false) const
 Render object to JSON. More...
 
virtual void to_json_value (rapidjson::Document &d, rapidjson::Value &v) const
 Render object to JSON. More...
 
virtual void from_json (const std::string &json)
 Retrieve data from JSON string. More...
 
virtual void from_json_value (const rapidjson::Value &v)
 Retrieve data from JSON string. More...
 
virtual void validate (bool subcall=false) const
 Validate if all required fields have been set. More...
 
std::optional< std::string > kind () const
 Get kind value. More...
 
void set_kind (const std::string &kind)
 Set kind value. More...
 
std::optional< std::string > apiVersion () const
 Get apiVersion value. More...
 
void set_apiVersion (const std::string &apiVersion)
 Set apiVersion value. More...
 
std::optional< std::string > id () const
 Get id value. More...
 
void set_id (const std::string &id)
 Set id value. More...
 
std::optional< std::string > type () const
 Get type value. More...
 
void set_type (const std::string &type)
 Set type value. More...
 
std::optional< std::string > writer () const
 Get writer value. More...
 
void set_writer (const std::string &writer)
 Set writer value. More...
 
std::vector< std::string > readers () const
 Get readers value. More...
 
void set_readers (const std::vector< std::string > &readers)
 Set readers value. More...
 
void addto_readers (const std::string &&readers)
 Add element to readers array. More...
 
void addto_readers (const std::string &readers)
 Add element to readers array. More...
 
std::shared_ptr< rapidjson::Document > data () const
 Get data value. More...
 
void set_data (const std::shared_ptr< rapidjson::Document > &data)
 Set data value. More...
 
std::optional< std::string > timestamp () const
 Get timestamp value. More...
 
void set_timestamp (const std::string &timestamp)
 Set timestamp value. More...
 

Static Public Member Functions

static std::string api_version ()
 Get version of implemented API. More...
 

Detailed Description

InterfaceData representation for JSON transfer.

Definition at line 26 of file InterfaceData.h.

Constructor & Destructor Documentation

◆ InterfaceData() [1/3]

InterfaceData::InterfaceData ( )

Constructor.

Definition at line 23 of file InterfaceData.cpp.

◆ InterfaceData() [2/3]

InterfaceData::InterfaceData ( const std::string &  json)

Constructor from JSON.

Parameters
jsonJSON string to initialize from

Definition at line 27 of file InterfaceData.cpp.

References from_json().

◆ InterfaceData() [3/3]

InterfaceData::InterfaceData ( const rapidjson::Value &  v)

Constructor from JSON.

Parameters
vRapidJSON value object to initialize from.

Definition at line 32 of file InterfaceData.cpp.

References from_json_value().

◆ ~InterfaceData()

InterfaceData::~InterfaceData ( )
virtual

Destructor.

Definition at line 37 of file InterfaceData.cpp.

Member Function Documentation

◆ addto_readers() [1/2]

void InterfaceData::addto_readers ( const std::string &&  readers)
inline

Add element to readers array.

Parameters
readersnew value

Definition at line 194 of file InterfaceData.h.

References readers().

◆ addto_readers() [2/2]

void InterfaceData::addto_readers ( const std::string &  readers)
inline

Add element to readers array.

The move-semantics version (std::move) should be preferred.

Parameters
readersnew value

Definition at line 204 of file InterfaceData.h.

References readers().

◆ api_version()

static std::string InterfaceData::api_version ( )
inlinestatic

Get version of implemented API.

Returns
string representation of version

Definition at line 48 of file InterfaceData.h.

◆ apiVersion()

std::optional< std::string > InterfaceData::apiVersion ( ) const
inline

Get apiVersion value.

Returns
apiVersion value

Definition at line 109 of file InterfaceData.h.

Referenced by set_apiVersion().

◆ data()

std::shared_ptr< rapidjson::Document > InterfaceData::data ( ) const
inline

Get data value.

Returns
data value

Definition at line 212 of file InterfaceData.h.

Referenced by set_data().

◆ from_json()

void InterfaceData::from_json ( const std::string &  json)
virtual

Retrieve data from JSON string.

Parameters
jsonJSON representation suitable for this object. Will allow partial assignment and not validate automaticaly.
See also
validate()

Definition at line 112 of file InterfaceData.cpp.

References from_json_value().

Referenced by InterfaceData().

◆ from_json_value()

void InterfaceData::from_json_value ( const rapidjson::Value &  v)
virtual

Retrieve data from JSON string.

Parameters
vRapidJSON value suitable for this object. Will allow partial assignment and not validate automaticaly.
See also
validate()

Definition at line 121 of file InterfaceData.cpp.

Referenced by from_json(), and InterfaceData().

◆ id()

std::optional< std::string > InterfaceData::id ( ) const
inline

Get id value.

Returns
id value

Definition at line 126 of file InterfaceData.h.

Referenced by set_id().

◆ kind()

std::optional< std::string > InterfaceData::kind ( ) const
inline

Get kind value.

Returns
kind value

Definition at line 92 of file InterfaceData.h.

Referenced by set_kind().

◆ readers()

std::vector< std::string > InterfaceData::readers ( ) const
inline

Get readers value.

Returns
readers value

Definition at line 177 of file InterfaceData.h.

Referenced by addto_readers(), and set_readers().

◆ set_apiVersion()

void InterfaceData::set_apiVersion ( const std::string &  apiVersion)
inline

Set apiVersion value.

Parameters
apiVersionnew value

Definition at line 118 of file InterfaceData.h.

References apiVersion().

◆ set_data()

void InterfaceData::set_data ( const std::shared_ptr< rapidjson::Document > &  data)
inline

Set data value.

Parameters
datanew value

Definition at line 221 of file InterfaceData.h.

References data().

◆ set_id()

void InterfaceData::set_id ( const std::string &  id)
inline

Set id value.

Parameters
idnew value

Definition at line 135 of file InterfaceData.h.

References id().

◆ set_kind()

void InterfaceData::set_kind ( const std::string &  kind)
inline

Set kind value.

Parameters
kindnew value

Definition at line 101 of file InterfaceData.h.

References kind().

◆ set_readers()

void InterfaceData::set_readers ( const std::vector< std::string > &  readers)
inline

Set readers value.

Parameters
readersnew value

Definition at line 186 of file InterfaceData.h.

References readers().

◆ set_timestamp()

void InterfaceData::set_timestamp ( const std::string &  timestamp)
inline

Set timestamp value.

Parameters
timestampnew value

Definition at line 238 of file InterfaceData.h.

References timestamp().

◆ set_type()

void InterfaceData::set_type ( const std::string &  type)
inline

Set type value.

Parameters
typenew value

Definition at line 152 of file InterfaceData.h.

References type().

◆ set_writer()

void InterfaceData::set_writer ( const std::string &  writer)
inline

Set writer value.

Parameters
writernew value

Definition at line 169 of file InterfaceData.h.

References writer().

◆ timestamp()

std::optional< std::string > InterfaceData::timestamp ( ) const
inline

Get timestamp value.

Returns
timestamp value

Definition at line 229 of file InterfaceData.h.

Referenced by set_timestamp().

◆ to_json()

std::string InterfaceData::to_json ( bool  pretty = false) const
virtual

Render object to JSON.

Parameters
prettytrue to enable pretty printing (readable spacing)
Returns
JSON string

Definition at line 42 of file InterfaceData.cpp.

References to_json_value(), and writer().

◆ to_json_value()

void InterfaceData::to_json_value ( rapidjson::Document &  d,
rapidjson::Value &  v 
) const
virtual

Render object to JSON.

Parameters
dRapidJSON document to retrieve allocator from
vRapidJSON value to add data to

Definition at line 61 of file InterfaceData.cpp.

Referenced by to_json().

◆ type()

std::optional< std::string > InterfaceData::type ( ) const
inline

Get type value.

Returns
type value

Definition at line 143 of file InterfaceData.h.

Referenced by set_type().

◆ validate()

void InterfaceData::validate ( bool  subcall = false) const
virtual

Validate if all required fields have been set.

Parameters
subcalltrue if this is called from another class, e.g., a sub-class or array holder. Will modify the kind of exception thrown.
Exceptions
std::vector<std::string>thrown if required information is missing and subcall is set to true. Contains a list of missing fields.
std::runtime_errorinformative message describing the missing fields

Definition at line 157 of file InterfaceData.cpp.

◆ writer()

std::optional< std::string > InterfaceData::writer ( ) const
inline

Get writer value.

Returns
writer value

Definition at line 160 of file InterfaceData.h.

Referenced by set_writer(), and to_json().


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