rllib  1
Macros | Functions
rljson.cpp File Reference
#include "rljson.h"
Include dependency graph for rljson.cpp:

Go to the source code of this file.

Macros

#define TESTING
 

Functions

int main ()
 

Macro Definition Documentation

◆ TESTING

#define TESTING

Definition at line 179 of file rljson.cpp.

Function Documentation

◆ main()

int main ( )

Definition at line 181 of file rljson.cpp.

182 {
183  printf("Test rljson begin:\n");
184  rlJSON rljson;
185  rlJSONrecord record;
186  int ret = rljson.initRecord(&record);
187  printf("rljson.initRecord ret=%d\n", ret);
188 
189  record.startsWithText = 1;
190  record.text.setText("id");
191  record.optColon = 1;
192  record.optOpenBracket = 1;
193  record.optParamType = 1; // 0=default=text 1=integer 2=float
194  record.param.setText("overture:places:place:1");
195  record.optComma = 0;
196 
197  printf("startsWithText=%d\n", record.startsWithText);
198  printf("startsWithOpenBracket=%d\n", record.startsWithOpenBracket);
199  printf("startsWithCloseBracket=%d\n", record.startsWithCloseBracket);
200  printf("startsWithEndArray=%d\n", record.startsWithEndArray);
201  printf("optColon=%d\n", record.optColon);
202  printf("optOpenBracket=%d\n", record.optOpenBracket);
203  printf("optBeginArray=%d\n", record.optBeginArray);
204  printf("optComma=%d\n", record.optComma);
205  printf("optParamType=%d (0=default=text 1=integer 2=float)\n", record.optParamType);
206 
207  rljson.print(stdout,&record);
208  printf("rljson.print ret=%d\n", ret);
209 
210  FILE *fin = fopen("/home/lehrig/temp/json1.txt","r");
211  if(fin == NULL)
212  {
213  printf("could not open /home/lehrig/temp/json1.txt\n");
214  }
215  else
216  {
217  char line[1024];
218  while(fgets(line,1023,fin) != NULL)
219  {
220  printf("json1.txt: %s", line);
221  rljson.interpret(line, &record);
222  printf("DEBUG: text=%s param=%s withText=%d\n"
223  "startsWith: openBracket=%d closeBracket=%d endArray=%d\n"
224  "opt: colon=%d openBracket=%d beginArray=%d paramType=%d comma=%d\n",
225  record.text.text(), record.param.text(), record.startsWithText,
227  record.optColon, record.optOpenBracket, record.optBeginArray, record.optParamType, record.optComma
228  );
229  /*
230  int startsWithText; // "text"
231  int startsWithOpenBracket; // {
232  int startsWithCloseBracket; // }
233  int startsWithEndArray; // ]
234  rlString text; // white space in front of the tag name is ignored
235  int optColon; // a colon must follow when text is a tag
236  int optOpenBracket; // a openBracket { might follow
237  int optBeginArray; // a beginArray [ might follow
238  int optParamType; // 0=default=text 1=integer 2=float
239  rlString param; // the parameter in text form
240  int intParam; // 0 if there is no integer number
241  float floatParam; // 0.0 if there is no floating point number
242  int optComma; // tells us that more elements follow
243  */
244  }
245  }
246  fclose(fin);
247  return 0;
248 }
int print(FILE *fout, rlJSONrecord *record, const char *indent="")
Definition: rljson.cpp:121
rlString text
Definition: rljson.h:33
int startsWithText
Definition: rljson.h:29
int interpret(const char *line, rlJSONrecord *record)
Definition: rljson.cpp:44
int startsWithOpenBracket
Definition: rljson.h:30
int optOpenBracket
Definition: rljson.h:35
char * text()
Definition: rlstring.cpp:126
rlString param
Definition: rljson.h:38
int optComma
Definition: rljson.h:41
int setText(const char *text)
Definition: rlstring.cpp:136
int optBeginArray
Definition: rljson.h:36
int startsWithEndArray
Definition: rljson.h:32
int startsWithCloseBracket
Definition: rljson.h:31
int optParamType
Definition: rljson.h:37
int initRecord(rlJSONrecord *record)
Definition: rljson.cpp:26
int optColon
Definition: rljson.h:34
Definition: rljson.h:47