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

Disk information. More...

#include <jsondef.h>

Collaboration diagram for diskstruc:

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

float maxgib = 0.f
 Maximum disk capacity in GiB. More...
 
float gib = 0.f
 Current disk usage in GiB. More...
 
char path [40] = ""
 Path. More...
 

Detailed Description

Disk information.

Member Function Documentation

json11::Json diskstruc::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
2128  {
2129  return json11::Json::object {
2130  { "maxgib" , maxgib },
2131  { "gib" , gib },
2132  { "path" , path }
2133  };
2134  }
std::map< std::string, Json > object
Definition: json11.hpp:88
float maxgib
Maximum disk capacity in GiB.
Definition: jsondef.h:2118
float gib
Current disk usage in GiB.
Definition: jsondef.h:2120
char path[40]
Path.
Definition: jsondef.h:2122
void diskstruc::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
2142  {
2143  string error;
2144  json11::Json parsed = json11::Json::parse(s,error);
2145  if(error.empty()) {
2146  if(!parsed["maxgib"].is_null()) { maxgib = parsed["maxgib"].number_value(); }
2147  if(!parsed["gib"].is_null()) { gib = parsed["gib"].number_value(); }
2148  if(!parsed["path"].is_null()) { strcpy(path, parsed["gib"].string_value().c_str()); }
2149  } else {
2150  cerr<<"ERROR: <"<<error<<">"<<endl;
2151  }
2152  return;
2153  }
Definition: json11.hpp:79
float maxgib
Maximum disk capacity in GiB.
Definition: jsondef.h:2118
static Json parse(const std::string &in, std::string &err, JsonParse strategy=JsonParse::STANDARD)
float gib
Current disk usage in GiB.
Definition: jsondef.h:2120
char path[40]
Path.
Definition: jsondef.h:2122
double number_value() const
Definition: json11.cpp:280

Member Data Documentation

float diskstruc::maxgib = 0.f

Maximum disk capacity in GiB.

float diskstruc::gib = 0.f

Current disk usage in GiB.

char diskstruc::path[40] = ""

Path.


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