Advertisement
avp210159

spj.h

Jan 29th, 2014
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.90 KB | None | 0 0
  1. struct jval;
  2. #ifdef USE_OBJ_DICT
  3. struct htab; // will be implemented sometime
  4. #endif
  5.  
  6. typedef enum jValue_type {
  7.   Object,
  8.   Array,
  9.   String,
  10.   Number,
  11.   Bool,
  12.   Null
  13. } jValue_type;
  14.  
  15. typedef struct jObject {
  16.   struct jval *data; // array
  17.   int size;
  18. #ifdef USE_OBJ_DICT
  19.   struct htab *hash;
  20. #endif
  21. } jObject;
  22.  
  23. typedef struct jArray {
  24.   struct jval *data; // array
  25.   int size;
  26. } jArray;
  27.  
  28. typedef struct jString {
  29.   char *data; // nil terminating
  30.   int size;
  31. } jString;
  32.  
  33. union value {
  34.   struct jObject obj;
  35.   struct jArray arr;
  36.   struct jString str;
  37.   double number;  // Bool, Null, integer and real (all in one)
  38. };
  39.  
  40. typedef struct jval {
  41.   jValue_type type;    // try to do it without flags
  42.   struct jval *parent; // calculated AFTER the filling of the PARENT's container
  43.   char *name;          // name pairs (valid only for members of the object)
  44.   union value value;
  45. } jVal;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement