COSMOS core  1.0.2 (beta)
Comprehensive Open-architecture Solution for Mission Operations Systems
userstruc Struct Reference

#include <jsondef.h>

Collaboration diagram for userstruc:

Public Member Functions

json11::Json to_json () const
 Convert class contents to JSON object. More...
 
void from_json (const string &s)
 Set class contents from JSON string. More...
 

Public Attributes

string name = ""
 
string node = ""
 
string tool = ""
 
string cpu = ""
 

Member Function Documentation

json11::Json userstruc::to_json ( ) const
inline

Convert class contents to JSON object.

Returns a json11 JSON object of the class

Returns
A json11 JSON object containing every member variable within the class
1216  {
1217  return json11::Json::object {
1218  { "name" , name },
1219  { "node", node },
1220  { "tool", tool },
1221  { "cpu", cpu }
1222  };
1223  }
std::map< std::string, Json > object
Definition: json11.hpp:88
string cpu
Definition: jsondef.h:1210
string node
Definition: jsondef.h:1208
string name
Definition: jsondef.h:1207
string tool
Definition: jsondef.h:1209
void userstruc::from_json ( const string &  s)
inline

Set class contents from JSON string.

Parses the provided JSON-formatted string and sets the class data. String should be formatted like the string returned from to_json()

Parameters
sJSON-formatted string to set class contents to
Returns
n/a
1231  {
1232  string error;
1233  json11::Json parsed = json11::Json::parse(s,error);
1234  if(error.empty()) {
1235  if(!parsed["name"].is_null()) { name = parsed["name"].string_value(); }
1236  if(!parsed["node"].is_null()) { node = parsed["node"].string_value(); }
1237  if(!parsed["tool"].is_null()) { tool = parsed["tool"].string_value(); }
1238  if(!parsed["cpu"].is_null()) { cpu = parsed["cpu"].string_value(); }
1239  } else {
1240  cerr<<"ERROR: <"<<error<<">"<<endl;
1241  }
1242  return;
1243  }
Definition: json11.hpp:79
string cpu
Definition: jsondef.h:1210
string node
Definition: jsondef.h:1208
static Json parse(const std::string &in, std::string &err, JsonParse strategy=JsonParse::STANDARD)
const std::string & string_value() const
Definition: json11.cpp:283
string name
Definition: jsondef.h:1207
string tool
Definition: jsondef.h:1209

Member Data Documentation

string userstruc::name = ""
string userstruc::node = ""
string userstruc::tool = ""
string userstruc::cpu = ""

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