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

JSON handle. More...

#include <jsondef.h>

Collaboration diagram for jsonhandle:

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

uint16_t hash
 
uint16_t index
 

Detailed Description

JSON handle.

Structure representing the location of a single JSON Equation or Name in its respective hash table.

Member Function Documentation

json11::Json jsonhandle::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
802  {
803  return json11::Json::object {
804  { "hash" , hash },
805  { "index", index }
806  };
807  }
std::map< std::string, Json > object
Definition: json11.hpp:88
uint16_t hash
Definition: jsondef.h:794
uint16_t index
Definition: jsondef.h:796
void jsonhandle::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
815  {
816  string error;
818  if(error.empty()) {
819  if(!p["hash"].is_null()) { hash = p["hash"].int_value(); }
820  if(!p["index"].is_null()) { index = p["index"].int_value(); }
821  } else {
822  cerr<<"ERROR: <"<<error<<">"<<endl;
823  }
824  return;
825  }
Definition: json11.hpp:79
uint16_t hash
Definition: jsondef.h:794
static double * p
Definition: gauss_jackson_test.cpp:42
static Json parse(const std::string &in, std::string &err, JsonParse strategy=JsonParse::STANDARD)
uint16_t index
Definition: jsondef.h:796
int int_value() const
Definition: json11.cpp:281

Member Data Documentation

uint16_t jsonhandle::hash
uint16_t jsonhandle::index

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