COSMOS core  1.0.2 (beta)
Comprehensive Open-architecture Solution for Mission Operations Systems
jsonlib.cpp File Reference

JSON support source file. More...

#include "support/configCosmos.h"
#include "support/jsonlib.h"
#include "support/convertlib.h"
#include "support/timelib.h"
#include "support/ephemlib.h"
#include "device/cpu/devicecpu.h"
#include "device/disk/devicedisk.h"
#include <sys/stat.h>
#include <iostream>
#include <limits>
#include <fstream>
Include dependency graph for jsonlib.cpp:

Functions

void json_init_unit (cosmosstruc *cinfo)
 
void json_init_device_type_string ()
 
void json_init_node (cosmosstruc *cinfo)
 
void json_init_reserve (cosmosstruc *cinfo)
 
cosmosstrucjson_init ()
 Initialize JSON pointer map. More...
 
void json_destroy (cosmosstruc *cinfo)
 Remove JSON pointer map. More...
 
uint16_t json_hash (string hstring)
 Calculate JSON HASH. More...
 
int32_t json_create_node (cosmosstruc *cinfo, string &node_name, uint16_t node_type)
 
int32_t json_create_cpu (string &node_name)
 
int32_t json_create_mcc (string &node_name)
 
int32_t json_createpiece (cosmosstruc *cinfo, string name, DeviceType ctype, double emi, double abs, double hcap, double hcon, double density)
 Create new piece. More...
 
int32_t json_finddev (cosmosstruc *cinfo, string name)
 
int32_t json_findcomp (cosmosstruc *cinfo, string name)
 
int32_t json_findpiece (cosmosstruc *cinfo, string name)
 
int32_t json_addpiece (cosmosstruc *cinfo, string name, DeviceType ctype, double emi, double abs, double hcap, double hcon, double density)
 Add new piece. More...
 
int32_t json_createport (cosmosstruc *cinfo, string name, PORT_TYPE type)
 
int32_t json_addentry (jsonentry entry, cosmosstruc *cinfo)
 Enter an entry into the JSON Namespace. More...
 
int32_t json_addentry (string name, uint16_t d1, uint16_t d2, ptrdiff_t offset, uint16_t type, uint16_t group, cosmosstruc *cinfo, uint16_t unit)
 Add an entry to the JSON Namespace map with units. More...
 
int32_t json_addentry (string name, uint16_t d1, uint16_t d2, uint8_t *ptr, uint16_t type, cosmosstruc *cinfo, uint16_t unit)
 
int32_t json_toggleentry (string name, uint16_t d1, uint16_t d2, cosmosstruc *cinfo, bool state)
 Toggle the enable state of an entry in the JSON Namespace map. More...
 
bool json_checkentry (string name, uint16_t d1, uint16_t d2, cosmosstruc *cinfo)
 Check the enable state of an entry in the JSON Namespace map. More...
 
size_t json_count_hash (uint16_t hash, cosmosstruc *cinfo)
 Number of items in current JSON map with a specific hash. More...
 
size_t json_count_total (cosmosstruc *cinfo)
 Number of items in the current JSON map. More...
 
int32_t json_out_handle (string &jstring, jsonhandle handle, cosmosstruc *cinfo)
 Perform JSON output for a JSON item by handle. More...
 
int32_t json_out_entry (string &jstring, const jsonentry &entry, cosmosstruc *cinfo)
 Perform JSON output for a single JSON entry. More...
 
int32_t json_out_value (string &jstring, string name, uint8_t *data, uint16_t type, cosmosstruc *cinfo)
 Output JSON Pair. More...
 
int32_t json_out_type (string &jstring, uint8_t *data, uint16_t type, cosmosstruc *cinfo)
 Output JSON Value. More...
 
int32_t json_append (string &jstring, const char *tstring)
 Extend JSON stream. More...
 
int32_t json_out_character (string &jstring, char character)
 Single character to JSON. More...
 
int32_t json_out_name (string &jstring, string name)
 Object name to JSON. More...
 
int32_t json_out_bool (string &jstring, bool value)
 Boolean to JSON. More...
 
int32_t json_out_int8 (string &jstring, int8_t value)
 Signed 8 bit integer to JSON. More...
 
int32_t json_out_int16 (string &jstring, int16_t value)
 Signed 16 bit integer to JSON. More...
 
int32_t json_out_int32 (string &jstring, int32_t value)
 Signed 32 bit integer to JSON. More...
 
int32_t json_out_uint8 (string &jstring, uint8_t value)
 Unsigned 8 bit integer to JSON. More...
 
int32_t json_out_uint16 (string &jstring, uint16_t value)
 Unsigned 16 bit integer to JSON. More...
 
int32_t json_out_uint32 (string &jstring, uint32_t value)
 Unsigned 32 bit integer to JSON. More...
 
int32_t json_out_float (string &jstring, float value)
 Single precision floating vertex32_t to JSON. More...
 
int32_t json_out_double (string &jstring, double value)
 Perform JSON output for a single nonindexed double. More...
 
int32_t json_out_string (string &jstring, string ostring, uint16_t len)
 String to JSON. More...
 
int32_t json_out_gvector (string &jstring, gvector value)
 gvector to JSON More...
 
int32_t json_out_svector (string &jstring, svector value)
 svector to JSON More...
 
int32_t json_out_avector (string &jstring, avector value)
 avector to JSON More...
 
int32_t json_out_vector (string &jstring, Vector value)
 ::Vector to JSON More...
 
int32_t json_out_rvector (string &jstring, rvector value)
 rvector to JSON More...
 
int32_t json_out_quaternion (string &jstring, quaternion value)
 quaternion to JSON More...
 
int32_t json_out_cvector (string &jstring, cvector value)
 cvector to JSON More...
 
int32_t json_out_cartpos (string &jstring, cartpos value)
 cartpos to JSON More...
 
int32_t json_out_geoidpos (string &jstring, geoidpos value)
 geoidpos to JSON More...
 
int32_t json_out_spherpos (string &jstring, spherpos value)
 spherpos to JSON More...
 
int32_t json_out_node (string &jstring, string value)
 Node name to JSON. More...
 
int32_t json_out_utcstart (string &jstring, double value)
 UTC Start to JSON. More...
 
int32_t json_out_ecipos (string &jstring, cartpos value)
 ECI position to JSON. More...
 
int32_t json_out_posstruc (string &jstring, posstruc value)
 posstruc to JSON More...
 
int32_t json_out_attstruc (string &jstring, attstruc value)
 attstruc to JSON More...
 
int32_t json_out_locstruc (string &jstring, locstruc value)
 locstruc to JSON More...
 
int32_t json_out_commandevent (string &jstring, eventstruc value)
 Command event to JSON. More...
 
int32_t json_out_dcmatt (string &jstring, dcmatt value)
 
int32_t json_out_qatt (string &jstring, qatt value)
 qatt to JSON More...
 
int32_t json_out_dcm (string &jstring, rmatrix value)
 rmatrix to JSON More...
 
int32_t json_out_rmatrix (string &jstring, rmatrix value)
 rmatrix to JSON More...
 
int32_t json_out_beatstruc (string &jstring, beatstruc value)
 beatstruc to JSON More...
 
int32_t json_out_1d (string &jstring, const char *token, uint16_t index, cosmosstruc *cinfo)
 Perform JSON output for a single element of a 1D named JSON item. More...
 
int32_t json_out_2d (string &jstring, const char *token, uint16_t row, uint16_t col, cosmosstruc *cinfo)
 Perform JSON output for a single element of a 2D named JSON item. More...
 
int32_t json_out (string &jstring, string token, cosmosstruc *cinfo)
 Perform JSON output for a single named JSON item. More...
 
int32_t json_out_list (string &jstring, string tokens, cosmosstruc *cinfo)
 Output a list of named JSON items. More...
 
int32_t json_out_wildcard (string &jstring, string wildcard, cosmosstruc *cinfo)
 Output JSON items from wildcard. More...
 
uint8_t * json_ptr_of_entry (const jsonentry &entry, cosmosstruc *cinfo)
 Address from entry. More...
 
uint8_t * json_ptr_of_offset (ptrdiff_t offset, uint16_t group, cosmosstruc *cinfo)
 Address from offset. More...
 
int32_t json_table_of_list (vector< jsonentry * > &table, string tokens, cosmosstruc *cinfo)
 Output a vector of JSON entries. More...
 
jsonentryjson_entry_of (uint8_t *ptr, cosmosstruc *cinfo)
 Info on Namespace address. More...
 
jsonentryjson_entry_of (string token, cosmosstruc *cinfo)
 Info on Namespace name. More...
 
jsonequationjson_equation_of (jsonhandle handle, cosmosstruc *cinfo)
 Info on Namespace equation. More...
 
jsonentryjson_entry_of (jsonhandle handle, cosmosstruc *cinfo)
 Info on Namespace name. More...
 
uint16_t json_type_of_name (string token, cosmosstruc *cinfo)
 Type of namespace name. More...
 
uint8_t * json_ptrto (string token, cosmosstruc *cinfo)
 Return the data pointer that matches a JSON name. More...
 
uint8_t * json_ptrto_1d (string token, uint16_t index1, cosmosstruc *cinfo)
 Return the data pointer that matches a singly indexed JSON name. More...
 
uint8_t * json_ptrto_2d (string token, uint16_t index1, uint16_t index2, cosmosstruc *cinfo)
 Return the data pointer that matches a doubly indexed JSON name. More...
 
int32_t json_get_int (jsonhandle &handle, cosmosstruc *cinfo)
 Return integer from handle. More...
 
int32_t json_get_int (const jsonentry &entry, cosmosstruc *cinfo)
 Return integer from entry. More...
 
int32_t json_get_int (string token, cosmosstruc *cinfo)
 Return integer from name. More...
 
int32_t json_get_int (string token, uint16_t index1, cosmosstruc *cinfo)
 Return integer from 1d name. More...
 
int32_t json_get_int (string token, uint16_t index1, uint16_t index2, cosmosstruc *cinfo)
 Return integer from 2d name. More...
 
uint32_t json_get_uint (jsonhandle &handle, cosmosstruc *cinfo)
 Return unsigned integer from handle. More...
 
uint32_t json_get_uint (const jsonentry &entry, cosmosstruc *cinfo)
 Return unsigned integer from entry. More...
 
uint32_t json_get_uint (string token, cosmosstruc *cinfo)
 Return unsigned integer from name. More...
 
uint32_t json_get_uint (string token, uint16_t index1, cosmosstruc *cinfo)
 Return unsigned integer from 1d name. More...
 
uint32_t json_get_uint (string token, uint16_t index1, uint16_t index2, cosmosstruc *cinfo)
 Return unsigned integer from 2d name. More...
 
double json_get_double (jsonhandle &handle, cosmosstruc *cinfo)
 Return double from handle. More...
 
double json_get_double (string token, cosmosstruc *cinfo)
 Return double from name. More...
 
double json_get_double (const jsonentry &entry, cosmosstruc *cinfo)
 Return double from entry. More...
 
rvector json_get_rvector (const jsonentry &entry, cosmosstruc *cinfo)
 Return rvector from entry. More...
 
quaternion json_get_quaternion (const jsonentry &entry, cosmosstruc *cinfo)
 Return quaternion from entry. More...
 
double json_get_double (string token, uint16_t index1, cosmosstruc *cinfo)
 Return double from 1d name. More...
 
double json_get_double (string token, uint16_t index1, uint16_t index2, cosmosstruc *cinfo)
 Return double from 2d name. More...
 
string json_get_string (string token, cosmosstruc *cinfo)
 Return string from name. More...
 
string json_get_string (const jsonentry &entry, cosmosstruc *cinfo)
 Return string from entry. More...
 
posstruc json_get_posstruc (const jsonentry &entry, cosmosstruc *cinfo)
 Return posstruc from entry. More...
 
int32_t json_set_double_name (double value, char *token, cosmosstruc *cinfo)
 Set name from double. More...
 
double json_equation (const char *&ptr, cosmosstruc *cinfo)
 Return the results of a JSON equation. More...
 
double json_equation (jsonhandle *handle, cosmosstruc *cinfo)
 Return the results of a known JSON equation handle. More...
 
double json_equation (jsonequation *ptr, cosmosstruc *cinfo)
 Return the results of a known JSON equation entry. More...
 
string json_extract_namedmember (string json, string token)
 Extract JSON value matching name. More...
 
int32_t json_extract_value (const char *&ptr, string &value)
 Extract next JSON value. More...
 
string json_convert_string (string object)
 Convert JSON to string. More...
 
double json_convert_double (string object)
 Convert JSON to double. More...
 
int32_t json_tokenize (string jstring, cosmosstruc *cinfo, vector< jsontoken > &tokens)
 Tokenize using JSON Name Space. More...
 
int32_t json_tokenize_namedmember (const char *&ptr, cosmosstruc *cinfo, jsontoken &token)
 Tokenize next JSON Named Pair. More...
 
int32_t json_parse (string jstring, cosmosstruc *cinfo)
 Parse JSON using Name Space. More...
 
int32_t json_parse_namedmember (const char *&ptr, cosmosstruc *cinfo)
 Parse next JSON Named Pair. More...
 
int32_t json_skip_character (const char *&ptr, const char character)
 Skip over a specific character in a JSON stream. More...
 
int32_t json_extract_name (const char *&ptr, string &ostring)
 Parse the next variable name out of a JSON stream. More...
 
int32_t json_parse_equation (const char *&ptr, string &equation)
 Parse the next JSON equation out of a JSON stream. More...
 
int32_t json_parse_operand (const char *&ptr, jsonoperand *operand, cosmosstruc *cinfo)
 Parse the next JSON equation operand out of a JSON stream. More...
 
int32_t json_extract_string (const char *&ptr, string &ostring)
 Parse the next JSON string out of a JSON stream. More...
 
int32_t json_parse_number (const char *&ptr, double *number)
 Parse the next number out of a JSON stream. More...
 
int32_t json_skip_white (const char *&ptr)
 Skip white space in JSON string. More...
 
int32_t json_skip_to_next_member (const char *&ptr)
 Skip to next COSMOS name in JSON string. More...
 
int32_t json_set_string (string val, const jsonentry &entry, cosmosstruc *cinfo)
 
int32_t json_set_number (double val, const jsonentry &entry, cosmosstruc *cinfo)
 
int32_t json_parse_value (const char *&ptr, const jsonentry &entry, cosmosstruc *cinfo)
 
int32_t json_parse_value (const char *&ptr, uint16_t type, ptrdiff_t offset, uint16_t group, cosmosstruc *cinfo)
 
int32_t json_parse_value (const char *&ptr, uint16_t type, uint8_t *data, cosmosstruc *cinfo)
 
int32_t json_clear_cosmosstruc (int32_t type, cosmosstruc *cinfo)
 Clear global data structure. More...
 
int32_t json_load_node (string node, jsonnode &json)
 Map Name Space to global data structure components and pieces. More...
 
int32_t json_recenter_node (cosmosstruc *cinfo)
 
int32_t json_pushdevspec (uint16_t cidx, cosmosstruc *cinfo)
 
int32_t json_setup_node (jsonnode json, cosmosstruc *cinfo, bool create_flag)
 Setup JSON Namespace using Node description JSON. More...
 
int32_t json_setup_node (string &node, cosmosstruc *cinfo)
 Setup JSON Namespace using file. More...
 
int32_t json_dump_node (cosmosstruc *cinfo)
 Save Node entries to disk. More...
 
int32_t json_mapentries (cosmosstruc *cinfo)
 
int32_t json_mapbaseentries (cosmosstruc *cinfo)
 Add base entries to JMAP. More...
 
int32_t json_mapvertexentry (uint16_t vidx, cosmosstruc *cinfo)
 Add vertex entry. More...
 
int32_t json_mapfaceentry (uint16_t fidx, cosmosstruc *cinfo)
 Add face entry. More...
 
int32_t json_mappieceentry (uint16_t pidx, cosmosstruc *cinfo)
 Add piece entry. More...
 
int32_t json_togglepieceentry (uint16_t pidx, cosmosstruc *cinfo, bool state)
 Toggle piece entry. More...
 
int32_t json_mapcompentry (uint16_t cidx, cosmosstruc *cinfo)
 Add component entry. More...
 
int32_t json_togglecompentry (uint16_t cidx, cosmosstruc *cinfo, bool state)
 Toggle component entry. More...
 
uint16_t json_mapdeviceentry (const devicestruc &device, cosmosstruc *cinfo)
 Add device entry. More...
 
int32_t json_toggledeviceentry (uint16_t didx, DeviceType type, cosmosstruc *cinfo, bool state)
 Toggle device entry. More...
 
uint16_t json_mapportentry (uint16_t portidx, cosmosstruc *cinfo)
 Add port entry. More...
 
int32_t json_toggleportentry (uint16_t portidx, cosmosstruc *cinfo, bool state)
 Toggle port entry. More...
 
const char * json_of_wildcard (string &jstring, string wildcard, cosmosstruc *cinfo)
 Create JSON stream from wildcard. More...
 
const char * json_of_list (string &jstring, string list, cosmosstruc *cinfo)
 Create JSON stream from list. More...
 
const char * json_of_table (string &jstring, vector< jsonentry * > table, cosmosstruc *cinfo)
 Create JSON stream from entries. More...
 
const char * json_of_target (string &jstring, cosmosstruc *cinfo, uint16_t num)
 Create JSON Track string. More...
 
const char * json_of_node (string &jstring, cosmosstruc *cinfo)
 Create JSON Node string. More...
 
const char * json_of_agent (string &jstring, cosmosstruc *cinfo)
 Create JSON Agent string. More...
 
const char * json_of_time (string &jstring, cosmosstruc *cinfo)
 Create JSON Time string. More...
 
const char * json_of_beat (string &jstring, cosmosstruc *cinfo)
 Create JSON Heart Beat string. More...
 
const char * json_of_beacon (string &jstring, cosmosstruc *cinfo)
 Create JSON Beacon string. More...
 
const char * json_of_imu (string &jstring, uint16_t num, cosmosstruc *cinfo)
 Create JSON IMU string. More...
 
const char * json_of_ephemeris (string &jstring, cosmosstruc *cinfo)
 
const char * json_of_utc (string &jstring, cosmosstruc *cinfo)
 
string json_list_of_all (cosmosstruc *cinfo)
 Get list of all Namespace names. More...
 
string json_list_of_soh (cosmosstruc *cinfo)
 
string json_list_of_fullsoh (cosmosstruc *cinfo)
 
const char * json_of_soh (string &jstring, cosmosstruc *cinfo)
 
const char * json_of_event (string &jstring, cosmosstruc *cinfo)
 Create JSON for an event. More...
 
const char * json_of_groundcontact (string &jstring, cosmosstruc *cinfo)
 
const char * json_of_mtr (string &jstring, uint16_t index, cosmosstruc *cinfo)
 
const char * json_of_rw (string &jstring, uint16_t index, cosmosstruc *cinfo)
 
const char * json_of_state_eci (string &jstring, cosmosstruc *cinfo)
 
const char * json_of_state_geoc (string &jstring, cosmosstruc *cinfo)
 
const char * json_node (string &jstring, cosmosstruc *cinfo)
 Dump Node description. More...
 
const char * json_vertices (string &jstring, cosmosstruc *cinfo)
 Dump Vertex description. More...
 
const char * json_faces (string &jstring, cosmosstruc *cinfo)
 Dump Face description. More...
 
const char * json_pieces (string &jstring, cosmosstruc *cinfo)
 Dump Piece description. More...
 
const char * json_devices_general (string &jstring, cosmosstruc *cinfo)
 Dump General Device description. More...
 
const char * json_devices_specific (string &jstring, cosmosstruc *cinfo)
 Dump Specific Device description. More...
 
const char * json_ports (string &jstring, cosmosstruc *cinfo)
 Dump Port description. More...
 
void json_test (cosmosstruc *cinfo)
 
int32_t json_name_map (string name, cosmosstruc *cinfo, jsonhandle &handle)
 Get hash and index in JSON Namespace map. More...
 
int32_t json_equation_map (string equation, cosmosstruc *cinfo, jsonhandle *handle)
 Get hash and index in JSON Equation map. More...
 
int32_t json_clone (cosmosstruc *cinfo1, cosmosstruc *cinfo2)
 Clone cosmosstruc data areas, direct. More...
 
uint32_t json_get_name_list_count (cosmosstruc *cinfo)
 
int32_t node_init (string node, cosmosstruc *cinfo)
 Initialize Node configuration. More...
 
int32_t node_calc (cosmosstruc *cinfo)
 Calculate Satellite configuration values. More...
 
void create_databases (cosmosstruc *cinfo)
 Dump tab delimited database files. More...
 
int32_t load_target (cosmosstruc *cinfo)
 Load Track list. More...
 
int32_t update_target (cosmosstruc *cinfo)
 Update Track list. More...
 
int32_t update_target (locstruc source, targetstruc &target)
 
size_t load_dictionary (vector< eventstruc > &dict, cosmosstruc *cinfo, const char *file)
 Load Event Dictionary. More...
 
size_t calc_events (vector< eventstruc > &dictionary, cosmosstruc *cinfo, vector< eventstruc > &events)
 Calculate current Events. More...
 
uint16_t device_type_index (string name)
 
string device_type_name (uint32_t type)
 
std::ostream & operator<< (std::ostream &out, const beatstruc &b)
 

Variables

static vector< string > device_type_string
 

Detailed Description

JSON support source file.

Variable Documentation

vector<string> device_type_string
static