Service representation for JSON transfer.
More...
#include <Service.h>
Service representation for JSON transfer.
Definition at line 26 of file Service.h.
◆ Service() [1/3]
◆ Service() [2/3]
Service::Service |
( |
const std::string & |
json | ) |
|
Constructor from JSON.
- Parameters
-
json | JSON string to initialize from |
Definition at line 27 of file Service.cpp.
References from_json().
◆ Service() [3/3]
Service::Service |
( |
const rapidjson::Value & |
v | ) |
|
Constructor from JSON.
- Parameters
-
v | RapidJSON value object to initialize from. |
Definition at line 32 of file Service.cpp.
References from_json_value().
◆ ~Service()
◆ api_version()
static std::string Service::api_version |
( |
| ) |
|
|
inlinestatic |
Get version of implemented API.
- Returns
- string representation of version
Definition at line 48 of file Service.h.
◆ from_json()
void Service::from_json |
( |
const std::string & |
json | ) |
|
|
virtual |
Retrieve data from JSON string.
- Parameters
-
json | JSON representation suitable for this object. Will allow partial assignment and not validate automaticaly. |
- See also
- validate()
Definition at line 81 of file Service.cpp.
References from_json_value().
Referenced by Service().
◆ from_json_value()
void Service::from_json_value |
( |
const rapidjson::Value & |
v | ) |
|
|
virtual |
◆ name()
std::optional<std::string> Service::name |
( |
| ) |
const |
|
inline |
◆ set_name()
void Service::set_name |
( |
const std::string & |
name | ) |
|
|
inline |
◆ set_url()
void Service::set_url |
( |
const std::string & |
url | ) |
|
|
inline |
Set url value.
- Parameters
-
Definition at line 118 of file Service.h.
References url().
◆ to_json()
std::string Service::to_json |
( |
bool |
pretty = false | ) |
const |
|
virtual |
Render object to JSON.
- Parameters
-
pretty | true to enable pretty printing (readable spacing) |
- Returns
- JSON string
Definition at line 42 of file Service.cpp.
References to_json_value().
◆ to_json_value()
void Service::to_json_value |
( |
rapidjson::Document & |
d, |
|
|
rapidjson::Value & |
v |
|
) |
| const |
|
virtual |
Render object to JSON.
- Parameters
-
d | RapidJSON document to retrieve allocator from |
v | RapidJSON value to add data to |
Definition at line 61 of file Service.cpp.
Referenced by to_json().
◆ url()
std::optional<std::string> Service::url |
( |
| ) |
const |
|
inline |
◆ validate()
void Service::validate |
( |
bool |
subcall = false | ) |
const |
|
virtual |
Validate if all required fields have been set.
- Parameters
-
subcall | true 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_error | informative message describing the missing fields |
Definition at line 101 of file Service.cpp.
The documentation for this class was generated from the following files:
- src/plugins/webview/backendinfo-rest-api/model/Service.h
- src/plugins/webview/backendinfo-rest-api/model/Service.cpp