COSMOS core  1.0.2 (beta)
Comprehensive Open-architecture Solution for Mission Operations Systems
Cosmos::wavefront::point Struct Reference

#include <objlib.h>

Collaboration diagram for Cosmos::wavefront::point:

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

vector< size_t > groups
 
size_t vertex = 0
 

Member Function Documentation

json11::Json Cosmos::wavefront::point::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
65  {
66  vector<double> d_groups(groups.begin(), groups.end());
67  return json11::Json::object {
68  { "groups" , d_groups },
69  { "vertex" , static_cast<double>(vertex) }
70  };
71  }
std::map< std::string, Json > object
Definition: json11.hpp:88
size_t vertex
Definition: objlib.h:59
vector< size_t > groups
Definition: objlib.h:58
void Cosmos::wavefront::point::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
79  {
80  string error;
82  if(error.empty()) {
83  for(size_t i = 0; i < groups.size(); ++i) {
84  if(!p["groups"][i].is_null())
85  groups[i] = static_cast<size_t>(p["groups"][i].number_value());
86  }
87  if(!p["vertex"].is_null()) vertex = static_cast<size_t>(p["vertex"].number_value());
88  } else {
89  cerr<<"ERROR: <"<<error<<">"<<endl;
90  }
91  return;
92  }
Definition: json11.hpp:79
int i
Definition: rw_test.cpp:37
size_t vertex
Definition: objlib.h:59
static double * p
Definition: gauss_jackson_test.cpp:42
static Json parse(const std::string &in, std::string &err, JsonParse strategy=JsonParse::STANDARD)
vector< size_t > groups
Definition: objlib.h:58

Member Data Documentation

vector<size_t> Cosmos::wavefront::point::groups
size_t Cosmos::wavefront::point::vertex = 0

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