typedefstruct JPAIR *PJPR; //typedef struct VAL *PVL;
/***********************************************************************/ /* Structure JPAIR. The pairs of a json Object. */ /***********************************************************************/ struct JPAIR {
PCSZ Key; // This pair key name
PJVAL Val; // To the value of the pair
PJPR Next; // To the next pair
}; // end of struct JPAIR
// Members used when parsing and serializing private:
JOUT* js; char *s; int len, dfp; bool *pty;
}; // end of class JDOC
/***********************************************************************/ /* Class JSON. The base class for all other json classes. */ /***********************************************************************/ class JSON : public BLOCK { public: // Constructor
JSON(void) { Type = TYPE_JSON; }
JSON(int) {}
// Methods virtualint size(void) { return1; } virtualvoid Clear(void) { X } virtual PJOB GetObject(void) { return NULL; } virtual PJAR GetArray(void) { return NULL; } virtual PJVAL GetArrayValue(int i) { X return NULL; } virtualint GetSize(bool b) { X return0; } virtual PJSON GetJsp(void) { X return NULL; } virtual PJPR GetFirst(void) { X return NULL; } virtual PSZ GetText(PGLOBAL g, PSTRG text) { X return NULL; } virtualbool Merge(PGLOBAL g, PJSON jsp) { X returntrue; } virtualvoid SetValue(PJSON jsp) { X } virtualbool DeleteValue(int i) { X returntrue; } virtualbool IsNull(void) { X returntrue; }
// Members
JTYP Type;
}; // end of class JSON
/***********************************************************************/ /* Class JOBJECT: contains a list of value pairs. */ /***********************************************************************/ class JOBJECT : public JSON { friendclass JDOC; friendclass JSNX; friendclass SWAP; public:
JOBJECT(void) : JSON() { Type = TYPE_JOB; First = Last = NULL; }
JOBJECT(int i) : JSON(i) {}
// Specific
PJVAL AddArrayValue(PGLOBAL g, PJVAL jvp = NULL, int* x = NULL); void SetArrayValue(PGLOBAL g, PJVAL jvp, int i); void InitArray(PGLOBAL g);
protected: // Members int Size; // The number of items in the array int Alloc; // The Mvals allocated size
PJVAL First; // Used when constructing
PJVAL Last; // Last constructed value
PJVAL *Mvals; // Allocated when finished
}; // end of class JARRAY
protected: union {
PJSON Jsp; // To the json value char *Strp; // Ptr to a string int N; // An integer value longlong LLn; // A big integer value double F; // A (double) float value bool B; // True or false
}; //PVL Val; // To the string or numeric value
PJVAL Next; // Next value in array
JTYP DataType; // The data value type int Nd; // Decimal number bool Del; // True when deleted
}; // end of class JVALUE
/***********************************************************************/ /* Class JOUT. Used by Serialize. */ /***********************************************************************/ class JOUT : public BLOCK { public:
JOUT(PGLOBAL gp) : BLOCK() { g = gp; Pretty = 3; }
// Member
PGLOBAL g; int Pretty;
}; // end of class JOUT
/***********************************************************************/ /* Class JOUTSTR. Used to Serialize to a string. */ /***********************************************************************/ class JOUTSTR : public JOUT { public:
JOUTSTR(PGLOBAL g);
// Member char* Strp; // The serialized string
size_t N; // Position of next char
size_t Max; // String max size
}; // end of class JOUTSTR
/***********************************************************************/ /* Class JOUTFILE. Used to Serialize to a file. */ /***********************************************************************/ class JOUTFILE : public JOUT { public:
JOUTFILE(PGLOBAL g, FILE* str, int pty) : JOUT(g) { Stream = str; Pretty = pty; }
// Member
FILE* Stream;
}; // end of class JOUTFILE
/***********************************************************************/ /* Class JOUTPRT. Used to Serialize to a pretty file. */ /***********************************************************************/ class JOUTPRT : public JOUTFILE { public:
JOUTPRT(PGLOBAL g, FILE* str) : JOUTFILE(g, str, 2) { M = 0; B = false; }
bool WriteStr(constchar* s) override; bool WriteChr(constchar c) override;
// Member int M; bool B;
}; // end of class JOUTPRT
/***********************************************************************/ /* Class SWAP. Used to make or unmake a JSON tree movable. */ /* This is done by making all pointers to offsets. */ /***********************************************************************/ class SWAP : public BLOCK { public: // Constructor
SWAP(PGLOBAL g, PJSON jsp)
{
G = g, Base = (char*)jsp - 8;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.