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

#include <jsondef.h>

Collaboration diagram for camstruc:

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 pwidth = 0
 
uint16_t pheight = 0
 
float width = 0.f
 
float height = 0.f
 
float flength = 0.f
 

Member Function Documentation

json11::Json camstruc::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
3199  {
3200  return json11::Json::object {
3201  { "pwidth" , pwidth },
3202  { "pheight", pheight },
3203  { "width" , width },
3204  { "height" , height },
3205  { "flength", flength }
3206  };
3207  }
std::map< std::string, Json > object
Definition: json11.hpp:88
uint16_t pwidth
Definition: jsondef.h:3189
float height
Definition: jsondef.h:3192
float width
Definition: jsondef.h:3191
uint16_t pheight
Definition: jsondef.h:3190
float flength
Definition: jsondef.h:3193
void camstruc::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
3215  {
3216  string error;
3217  json11::Json parsed = json11::Json::parse(s,error);
3218  if(error.empty()) {
3219  if(!parsed["pwidth"].is_null()) { pwidth = parsed["pwidth"].int_value(); }
3220  if(!parsed["pheight"].is_null()) { pheight = parsed["pheight"].int_value(); }
3221  if(!parsed["width"].is_null()) { width = parsed["width"].number_value(); }
3222  if(!parsed["height"].is_null()) { height = parsed["height"].number_value(); }
3223  if(!parsed["flength"].is_null()) { flength = parsed["flength"].number_value(); }
3224  } else {
3225  cerr<<"ERROR: <"<<error<<">"<<endl;
3226  }
3227  return;
3228  }
Definition: json11.hpp:79
uint16_t pwidth
Definition: jsondef.h:3189
float height
Definition: jsondef.h:3192
float width
Definition: jsondef.h:3191
static Json parse(const std::string &in, std::string &err, JsonParse strategy=JsonParse::STANDARD)
uint16_t pheight
Definition: jsondef.h:3190
float flength
Definition: jsondef.h:3193
int int_value() const
Definition: json11.cpp:281
double number_value() const
Definition: json11.cpp:280

Member Data Documentation

uint16_t camstruc::pwidth = 0
uint16_t camstruc::pheight = 0
float camstruc::width = 0.f
float camstruc::height = 0.f
float camstruc::flength = 0.f

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