Fawkes API  Fawkes Development Version
SlotValue Class Reference

SlotValue representation for JSON transfer. More...

#include <SlotValue.h>

Public Member Functions

 SlotValue ()
 Constructor. More...
 
 SlotValue (const std::string &json)
 Constructor from JSON. More...
 
 SlotValue (const rapidjson::Value &v)
 Constructor from JSON. More...
 
virtual ~SlotValue ()
 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 > name () const
 Get name value. More...
 
void set_name (const std::string &name)
 Set name 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< bool > is_multifield () const
 Get is-multifield value. More...
 
void set_is_multifield (const bool &is_multifield)
 Set is-multifield value. More...
 
std::vector< std::string > values () const
 Get values value. More...
 
void set_values (const std::vector< std::string > &values)
 Set values value. More...
 
void addto_values (const std::string &&values)
 Add element to values array. More...
 
void addto_values (const std::string &values)
 Add element to values array. More...
 

Static Public Member Functions

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

Detailed Description

SlotValue representation for JSON transfer.

Definition at line 25 of file SlotValue.h.

Constructor & Destructor Documentation

◆ SlotValue() [1/3]

SlotValue::SlotValue ( )

Constructor.

Definition at line 22 of file SlotValue.cpp.

◆ SlotValue() [2/3]

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

Constructor from JSON.

Parameters
jsonJSON string to initialize from

Definition at line 26 of file SlotValue.cpp.

References from_json().

◆ SlotValue() [3/3]

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

Constructor from JSON.

Parameters
vRapidJSON value object to initialize from.

Definition at line 31 of file SlotValue.cpp.

References from_json_value().

◆ ~SlotValue()

SlotValue::~SlotValue ( )
virtual

Destructor.

Definition at line 36 of file SlotValue.cpp.

Member Function Documentation

◆ addto_values() [1/2]

void SlotValue::addto_values ( const std::string &&  values)
inline

Add element to values array.

Parameters
valuesnew value

Definition at line 159 of file SlotValue.h.

References values().

◆ addto_values() [2/2]

void SlotValue::addto_values ( const std::string &  values)
inline

Add element to values array.

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

Parameters
valuesnew value

Definition at line 169 of file SlotValue.h.

References values().

◆ api_version()

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

Get version of implemented API.

Returns
string representation of version

Definition at line 47 of file SlotValue.h.

◆ from_json()

void SlotValue::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 93 of file SlotValue.cpp.

References from_json_value().

Referenced by SlotValue().

◆ from_json_value()

void SlotValue::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 102 of file SlotValue.cpp.

Referenced by from_json(), Fact::from_json_value(), and SlotValue().

◆ is_multifield()

std::optional<bool> SlotValue::is_multifield ( ) const
inline

Get is-multifield value.

Returns
is-multifield value

Definition at line 125 of file SlotValue.h.

Referenced by set_is_multifield().

◆ name()

std::optional<std::string> SlotValue::name ( ) const
inline

Get name value.

Returns
name value

Definition at line 91 of file SlotValue.h.

Referenced by set_name().

◆ set_is_multifield()

void SlotValue::set_is_multifield ( const bool &  is_multifield)
inline

Set is-multifield value.

Parameters
is_multifieldnew value

Definition at line 134 of file SlotValue.h.

References is_multifield().

◆ set_name()

void SlotValue::set_name ( const std::string &  name)
inline

Set name value.

Parameters
namenew value

Definition at line 100 of file SlotValue.h.

References name().

◆ set_type()

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

Set type value.

Parameters
typenew value

Definition at line 117 of file SlotValue.h.

References type().

◆ set_values()

void SlotValue::set_values ( const std::vector< std::string > &  values)
inline

Set values value.

Parameters
valuesnew value

Definition at line 151 of file SlotValue.h.

References values().

◆ to_json()

std::string SlotValue::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 41 of file SlotValue.cpp.

References to_json_value().

◆ to_json_value()

void SlotValue::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 60 of file SlotValue.cpp.

Referenced by to_json().

◆ type()

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

Get type value.

Returns
type value

Definition at line 108 of file SlotValue.h.

Referenced by set_type().

◆ validate()

void SlotValue::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 125 of file SlotValue.cpp.

◆ values()

std::vector<std::string> SlotValue::values ( ) const
inline

Get values value.

Returns
values value

Definition at line 142 of file SlotValue.h.

Referenced by addto_values(), and set_values().


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