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

#include <jsondef.h>

Collaboration diagram for jsonnode:

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 state = ""
 
string utcstart = ""
 
string vertexs = ""
 
string faces = ""
 
string pieces = ""
 
string devgen = ""
 
string devspec = ""
 
string ports = ""
 
string targets = ""
 

Detailed Description

JSON Node description strings Structure containing the JSON strings that describe the various aspects of a node. These can be loaded from disk, or transferred from another agent.

Member Function Documentation

json11::Json jsonnode::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
742  {
743  return json11::Json::object {
744  { "name" , name },
745  { "node" , node },
746  { "state" , state },
747  { "utcstart" , utcstart },
748  { "vertexs" , vertexs },
749  { "faces" , faces },
750  { "pieces" , pieces },
751  { "devgen" , devgen },
752  { "devspec" , devspec },
753  { "ports" , ports },
754  { "targets" , targets },
755  };
756  }
std::map< std::string, Json > object
Definition: json11.hpp:88
string devspec
Definition: jsondef.h:734
string faces
Definition: jsondef.h:731
string node
Definition: jsondef.h:727
string pieces
Definition: jsondef.h:732
string targets
Definition: jsondef.h:736
string utcstart
Definition: jsondef.h:729
string ports
Definition: jsondef.h:735
string name
Definition: jsondef.h:726
string state
Definition: jsondef.h:728
string devgen
Definition: jsondef.h:733
string vertexs
Definition: jsondef.h:730
void jsonnode::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
764  {
765  string error;
766  json11::Json parsed = json11::Json::parse(s,error);
767  if(error.empty()) {
768  if(!parsed["name"].is_null()) { name = parsed["name"].string_value(); }
769  if(!parsed["node"].is_null()) { node = parsed["node"].string_value(); }
770  if(!parsed["state"].is_null()) { state = parsed["state"].string_value(); }
771  if(!parsed["utcstart"].is_null()) { utcstart = parsed["utcstart"].string_value(); }
772  if(!parsed["vertexs"].is_null()) { vertexs = parsed["vertexs"].string_value(); }
773  if(!parsed["faces"].is_null()) { faces = parsed["faces"].string_value(); }
774  if(!parsed["pieces"].is_null()) { pieces = parsed["pieces"].string_value(); }
775  if(!parsed["devgen"].is_null()) { devgen = parsed["devgen"].string_value(); }
776  if(!parsed["devspec"].is_null()) { devspec = parsed["devspec"].string_value(); }
777  if(!parsed["ports"].is_null()) { ports = parsed["ports"].string_value(); }
778  if(!parsed["targets"].is_null()) { targets = parsed["targets"].string_value(); }
779  } else {
780  cerr<<"ERROR: <"<<error<<">"<<endl;
781  }
782  return;
783  }
Definition: json11.hpp:79
string devspec
Definition: jsondef.h:734
string faces
Definition: jsondef.h:731
string node
Definition: jsondef.h:727
static Json parse(const std::string &in, std::string &err, JsonParse strategy=JsonParse::STANDARD)
string pieces
Definition: jsondef.h:732
const std::string & string_value() const
Definition: json11.cpp:283
string targets
Definition: jsondef.h:736
string utcstart
Definition: jsondef.h:729
string ports
Definition: jsondef.h:735
string name
Definition: jsondef.h:726
string state
Definition: jsondef.h:728
string devgen
Definition: jsondef.h:733
string vertexs
Definition: jsondef.h:730

Member Data Documentation

string jsonnode::name = ""
string jsonnode::node = ""
string jsonnode::state = ""
string jsonnode::utcstart = ""
string jsonnode::vertexs = ""
string jsonnode::faces = ""
string jsonnode::pieces = ""
string jsonnode::devgen = ""
string jsonnode::devspec = ""
string jsonnode::ports = ""
string jsonnode::targets = ""

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