COSMOS core  1.0.2 (beta)
Comprehensive Open-architecture Solution for Mission Operations Systems
json_test.cpp File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "jsonlib.h"
Include dependency graph for json_test.cpp:

Functions

int main (int argc, char *argv[])
 

Variables

cosmosstruccosmos_data
 

Function Documentation

int main ( int  argc,
char *  argv[] 
)
38 {
39 
40 double result;
41 json_create(&cosmos_data);
42 if(argc == 2) {
43  const char *ptr = argv[1];
44  result = json_equation(&ptr,cosmos_data);
45  printf("%f \n", result);
46 }
47 
48 else if(argc == 1) {
49  double timestamp = 500.;
50  double node_utc = 400.;
51  char testString[128];
52  const char *strPtr = &testString[0];
53  const char testOperators[10] = {"+-*/&|><="};
54  json_set_double_name(timestamp, (char *)"timestamp",cosmos_data);
55  json_set_double_name(node_utc, (char *)"node_utc",cosmos_data);
56 
57  for(int i = 0; i < 9; i++) {
58  strPtr = testString;
59  strcpy(testString, "(\"timestamp\"");
60  testString[strlen(testString)] = testOperators[i];
61  strcat(testString, "\"node_utc\")");
62  result = json_equation(&strPtr,cosmos_data);
63  printf("%f \n", result);
64  for(int j = 0; j < 128; j++) {
65  testString[j] = 0;
66  }
67  }
68 
69 }
70 else {
71  printf("Too many arguments \n");
72  return 0;
73 }
74 }
int32_t json_set_double_name(double value, char *token, cosmosstruc *cinfo)
Set name from double.
Definition: jsonlib.cpp:4234
int i
Definition: rw_test.cpp:37
double json_equation(const char *&ptr, cosmosstruc *cinfo)
Return the results of a JSON equation.
Definition: jsonlib.cpp:4294
cosmosstruc * cosmos_data
Definition: json_test.cpp:35

Variable Documentation

cosmosstruc* cosmos_data