Fawkes API Fawkes Development Version
WebviewRestArray< M > Class Template Reference

Container to return array via REST. More...

#include <rest_array.h>

Inheritance diagram for WebviewRestArray< M >:

Public Member Functions

 WebviewRestArray ()
 Empty array constructor. More...
 
 WebviewRestArray (std::vector< M > &items)
 Constructor. More...
 
 WebviewRestArray (std::vector< M > &&items)
 Constructor. More...
 
std::string to_json (bool pretty=false) const
 Render object to JSON. More...
 
void from_json (const std::string &json)
 Retrieve data from JSON string. More...
 
void validate (bool subcall=false)
 Validate if all required fields have been set. More...
 
std::vector< M > & items ()
 Accessor for items. More...
 
void push_back (M &m)
 Add item at the back of the container. More...
 
void push_back (M &&m)
 Add item at the back of the container. More...
 

Detailed Description

template<class M>
class WebviewRestArray< M >

Container to return array via REST.

Author
Tim Niemueller

Definition at line 35 of file rest_array.h.

Constructor & Destructor Documentation

◆ WebviewRestArray() [1/3]

template<class M >
WebviewRestArray< M >::WebviewRestArray ( )
inline

Empty array constructor.

Definition at line 39 of file rest_array.h.

◆ WebviewRestArray() [2/3]

template<class M >
WebviewRestArray< M >::WebviewRestArray ( std::vector< M > &  items)
inline

Constructor.

Parameters
itemsvector of values to copy

Definition at line 45 of file rest_array.h.

◆ WebviewRestArray() [3/3]

template<class M >
WebviewRestArray< M >::WebviewRestArray ( std::vector< M > &&  items)
inline

Constructor.

Parameters
itemsvector of values to move to this array.

Definition at line 52 of file rest_array.h.

Member Function Documentation

◆ from_json()

template<class M >
void WebviewRestArray< M >::from_json ( const std::string &  json)
inline

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 80 of file rest_array.h.

◆ items()

template<class M >
std::vector< M > & WebviewRestArray< M >::items ( )
inline

Accessor for items.

Returns
item vector

Definition at line 114 of file rest_array.h.

◆ push_back() [1/2]

template<class M >
void WebviewRestArray< M >::push_back ( M &&  m)
inline

Add item at the back of the container.

Parameters
melement to move

Definition at line 132 of file rest_array.h.

◆ push_back() [2/2]

template<class M >
void WebviewRestArray< M >::push_back ( M &  m)
inline

Add item at the back of the container.

Parameters
melement to copy

Definition at line 123 of file rest_array.h.

Referenced by BackendInfoRestApi::init().

◆ to_json()

template<class M >
std::string WebviewRestArray< M >::to_json ( bool  pretty = false) const
inline

Render object to JSON.

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

Definition at line 61 of file rest_array.h.

◆ validate()

template<class M >
void WebviewRestArray< M >::validate ( bool  subcall = false)
inline

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 103 of file rest_array.h.


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