Fawkes API  Fawkes Development Version
Fact Class Reference

Fact representation for JSON transfer. More...

#include <Fact.h>

Public Member Functions

 Fact ()
 Constructor. More...
 
 Fact (const std::string &json)
 Constructor from JSON. More...
 
 Fact (const rapidjson::Value &v)
 Constructor from JSON. More...
 
virtual ~Fact ()
 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< int64_t > index () const
 Get index value. More...
 
void set_index (const int64_t &index)
 Set index value. More...
 
std::optional< std::string > template_name () const
 Get template_name value. More...
 
void set_template_name (const std::string &template_name)
 Set template_name value. More...
 
std::optional< std::string > formatted () const
 Get formatted value. More...
 
void set_formatted (const std::string &formatted)
 Set formatted value. More...
 
std::vector< std::shared_ptr< SlotValue > > slots () const
 Get slots value. More...
 
void set_slots (const std::vector< std::shared_ptr< SlotValue >> &slots)
 Set slots value. More...
 
void addto_slots (const std::shared_ptr< SlotValue > &&slots)
 Add element to slots array. More...
 
void addto_slots (const std::shared_ptr< SlotValue > &slots)
 Add element to slots array. More...
 
void addto_slots (const SlotValue &&slots)
 Add element to slots array. More...
 

Static Public Member Functions

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

Detailed Description

Fact representation for JSON transfer.

Definition at line 28 of file Fact.h.

Constructor & Destructor Documentation

◆ Fact() [1/3]

Fact::Fact ( )

Constructor.

Definition at line 23 of file Fact.cpp.

◆ Fact() [2/3]

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

Constructor from JSON.

Parameters
jsonJSON string to initialize from

Definition at line 27 of file Fact.cpp.

References from_json().

◆ Fact() [3/3]

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

Constructor from JSON.

Parameters
vRapidJSON value object to initialize from.

Definition at line 32 of file Fact.cpp.

References from_json_value().

◆ ~Fact()

Fact::~Fact ( )
virtual

Destructor.

Definition at line 37 of file Fact.cpp.

Member Function Documentation

◆ addto_slots() [1/3]

void Fact::addto_slots ( const SlotValue &&  slots)
inline

Add element to slots array.

Parameters
slotsnew value

Definition at line 214 of file Fact.h.

References slots().

◆ addto_slots() [2/3]

void Fact::addto_slots ( const std::shared_ptr< SlotValue > &&  slots)
inline

Add element to slots array.

Parameters
slotsnew value

Definition at line 196 of file Fact.h.

References slots().

◆ addto_slots() [3/3]

void Fact::addto_slots ( const std::shared_ptr< SlotValue > &  slots)
inline

Add element to slots array.

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

Parameters
slotsnew value

Definition at line 206 of file Fact.h.

References slots().

◆ api_version()

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

Get version of implemented API.

Returns
string representation of version

Definition at line 50 of file Fact.h.

◆ apiVersion()

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

Get apiVersion value.

Returns
apiVersion value

Definition at line 111 of file Fact.h.

Referenced by set_apiVersion().

◆ formatted()

std::optional<std::string> Fact::formatted ( ) const
inline

Get formatted value.

Returns
formatted value

Definition at line 162 of file Fact.h.

Referenced by set_formatted().

◆ from_json()

void Fact::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 104 of file Fact.cpp.

References from_json_value().

Referenced by Fact().

◆ from_json_value()

void Fact::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 113 of file Fact.cpp.

References SlotValue::from_json_value().

Referenced by Fact(), and from_json().

◆ index()

std::optional<int64_t> Fact::index ( ) const
inline

Get index value.

Returns
index value

Definition at line 128 of file Fact.h.

Referenced by set_index().

◆ kind()

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

Get kind value.

Returns
kind value

Definition at line 94 of file Fact.h.

Referenced by set_kind().

◆ set_apiVersion()

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

Set apiVersion value.

Parameters
apiVersionnew value

Definition at line 120 of file Fact.h.

References apiVersion().

◆ set_formatted()

void Fact::set_formatted ( const std::string &  formatted)
inline

Set formatted value.

Parameters
formattednew value

Definition at line 171 of file Fact.h.

References formatted().

◆ set_index()

void Fact::set_index ( const int64_t &  index)
inline

Set index value.

Parameters
indexnew value

Definition at line 137 of file Fact.h.

References index().

◆ set_kind()

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

Set kind value.

Parameters
kindnew value

Definition at line 103 of file Fact.h.

References kind().

◆ set_slots()

void Fact::set_slots ( const std::vector< std::shared_ptr< SlotValue >> &  slots)
inline

Set slots value.

Parameters
slotsnew value

Definition at line 188 of file Fact.h.

References slots().

◆ set_template_name()

void Fact::set_template_name ( const std::string &  template_name)
inline

Set template_name value.

Parameters
template_namenew value

Definition at line 154 of file Fact.h.

References template_name().

◆ slots()

std::vector<std::shared_ptr<SlotValue> > Fact::slots ( ) const
inline

Get slots value.

Returns
slots value

Definition at line 179 of file Fact.h.

Referenced by addto_slots(), and set_slots().

◆ template_name()

std::optional<std::string> Fact::template_name ( ) const
inline

Get template_name value.

Returns
template_name value

Definition at line 145 of file Fact.h.

Referenced by set_template_name().

◆ to_json()

std::string Fact::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 Fact.cpp.

References to_json_value().

◆ to_json_value()

void Fact::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 Fact.cpp.

Referenced by to_json().

◆ validate()

void Fact::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 144 of file Fact.cpp.


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