Fawkes API  Fawkes Development Version
InterfaceFieldType Class Reference

InterfaceFieldType representation for JSON transfer. More...

#include <InterfaceFieldType.h>

Public Member Functions

 InterfaceFieldType ()
 Constructor. More...
 
 InterfaceFieldType (const std::string &json)
 Constructor from JSON. More...
 
 InterfaceFieldType (const rapidjson::Value &v)
 Constructor from JSON. More...
 
virtual ~InterfaceFieldType ()
 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_array () const
 Get is_array value. More...
 
void set_is_array (const bool &is_array)
 Set is_array value. More...
 
std::vector< std::string > enums () const
 possible enum values for this field More...
 
void set_enums (const std::vector< std::string > &enums)
 Set enums value. More...
 
void addto_enums (const std::string &&enums)
 Add element to enums array. More...
 
void addto_enums (const std::string &enums)
 Add element to enums array. More...
 

Static Public Member Functions

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

Detailed Description

InterfaceFieldType representation for JSON transfer.

Definition at line 26 of file InterfaceFieldType.h.

Constructor & Destructor Documentation

◆ InterfaceFieldType() [1/3]

InterfaceFieldType::InterfaceFieldType ( )

Constructor.

Definition at line 23 of file InterfaceFieldType.cpp.

◆ InterfaceFieldType() [2/3]

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

Constructor from JSON.

Parameters
jsonJSON string to initialize from

Definition at line 27 of file InterfaceFieldType.cpp.

References from_json().

◆ InterfaceFieldType() [3/3]

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

Constructor from JSON.

Parameters
vRapidJSON value object to initialize from.

Definition at line 32 of file InterfaceFieldType.cpp.

References from_json_value().

◆ ~InterfaceFieldType()

InterfaceFieldType::~InterfaceFieldType ( )
virtual

Destructor.

Definition at line 37 of file InterfaceFieldType.cpp.

Member Function Documentation

◆ addto_enums() [1/2]

void InterfaceFieldType::addto_enums ( const std::string &&  enums)
inline

Add element to enums array.

Parameters
enumsnew value

Definition at line 160 of file InterfaceFieldType.h.

References enums().

◆ addto_enums() [2/2]

void InterfaceFieldType::addto_enums ( const std::string &  enums)
inline

Add element to enums array.

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

Parameters
enumsnew value

Definition at line 170 of file InterfaceFieldType.h.

References enums().

◆ api_version()

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

Get version of implemented API.

Returns
string representation of version

Definition at line 48 of file InterfaceFieldType.h.

◆ enums()

std::vector<std::string> InterfaceFieldType::enums ( ) const
inline

possible enum values for this field

Returns
enums value

Definition at line 143 of file InterfaceFieldType.h.

Referenced by addto_enums(), and set_enums().

◆ from_json()

void InterfaceFieldType::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 94 of file InterfaceFieldType.cpp.

References from_json_value().

Referenced by InterfaceFieldType().

◆ from_json_value()

void InterfaceFieldType::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 103 of file InterfaceFieldType.cpp.

Referenced by from_json(), InterfaceInfo::from_json_value(), InterfaceMessageType::from_json_value(), and InterfaceFieldType().

◆ is_array()

std::optional<bool> InterfaceFieldType::is_array ( ) const
inline

Get is_array value.

Returns
is_array value

Definition at line 126 of file InterfaceFieldType.h.

Referenced by set_is_array().

◆ name()

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

Get name value.

Returns
name value

Definition at line 92 of file InterfaceFieldType.h.

Referenced by set_name().

◆ set_enums()

void InterfaceFieldType::set_enums ( const std::vector< std::string > &  enums)
inline

Set enums value.

Parameters
enumsnew value

Definition at line 152 of file InterfaceFieldType.h.

References enums().

◆ set_is_array()

void InterfaceFieldType::set_is_array ( const bool &  is_array)
inline

Set is_array value.

Parameters
is_arraynew value

Definition at line 135 of file InterfaceFieldType.h.

References is_array().

◆ set_name()

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

Set name value.

Parameters
namenew value

Definition at line 101 of file InterfaceFieldType.h.

References name().

◆ set_type()

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

Set type value.

Parameters
typenew value

Definition at line 118 of file InterfaceFieldType.h.

References type().

◆ to_json()

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

References to_json_value().

◆ to_json_value()

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

Referenced by to_json().

◆ type()

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

Get type value.

Returns
type value

Definition at line 109 of file InterfaceFieldType.h.

Referenced by set_type().

◆ validate()

void InterfaceFieldType::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 126 of file InterfaceFieldType.cpp.


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