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

SUCHI Sructure. More...

#include <jsondef.h>

Collaboration diagram for suchistruc:

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

quaternion align
 alignment quaternion More...
 
float press = 0.f
 Internal pressure. More...
 
float temps [8] = {0.f}
 Internal temperatures. More...
 

Detailed Description

SUCHI Sructure.

Member Function Documentation

json11::Json suchistruc::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
3152  {
3153  vector<float> v_temps = vector<float>(temps, temps+sizeof(temps)/sizeof(temps[0]));
3154  return json11::Json::object {
3155  { "align" , align },
3156  { "press" , press },
3157  { "temps" , v_temps }
3158  };
3159  }
float temps[8]
Internal temperatures.
Definition: jsondef.h:3146
std::map< std::string, Json > object
Definition: json11.hpp:88
float press
Internal pressure.
Definition: jsondef.h:3144
quaternion align
alignment quaternion
Definition: jsondef.h:3142
void suchistruc::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
3167  {
3168  string error;
3169  json11::Json parsed = json11::Json::parse(s,error);
3170  if(error.empty()) {
3171  if(!parsed["align"].is_null()) { align.from_json(parsed["align"].dump()); }
3172  if(!parsed["press"].is_null()) { press = parsed["press"].number_value(); }
3173  if(!parsed["temps"].is_null()) {
3174  if(!parsed["press"].is_null()) { press = parsed["press"].number_value(); }
3175  auto p_temps = parsed["temps"].array_items();
3176  for(size_t i = 0; i != p_temps.size(); ++i) {
3177  if(!p_temps[i].is_null()) { temps[i] = p_temps[i].number_value(); }
3178  }
3179  }
3180  } else {
3181  cerr<<"ERROR: <"<<error<<">"<<endl;
3182  }
3183  return;
3184  }
float temps[8]
Internal temperatures.
Definition: jsondef.h:3146
Definition: json11.hpp:79
int i
Definition: rw_test.cpp:37
float press
Internal pressure.
Definition: jsondef.h:3144
static Json parse(const std::string &in, std::string &err, JsonParse strategy=JsonParse::STANDARD)
static void dump(NullStruct, string &out)
Definition: json11.cpp:53
quaternion align
alignment quaternion
Definition: jsondef.h:3142
const array & array_items() const
Definition: json11.cpp:284
void from_json(const string &s)
Set class contents from JSON string.
Definition: vector.h:431
double number_value() const
Definition: json11.cpp:280

Member Data Documentation

quaternion suchistruc::align

alignment quaternion

float suchistruc::press = 0.f

Internal pressure.

float suchistruc::temps[8] = {0.f}

Internal temperatures.


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