/******************** tabjson H Declares Source Code File (.H) *******************/ /* Name: jsonudf.h Version 1.4 */ /* */ /* (C) Copyright to the author Olivier BERTRAND 2015-2020 */ /* */ /* This file contains the JSON UDF function and class declares. */ /*********************************************************************************/ #pragma once #include"global.h" #include"plgdbsem.h" #include"block.h" #include"osutil.h" #include"maputil.h" #include"json.h"
/*********************************************************************************/ /* The JSON tree node. Can be an Object or an Array. */ /*********************************************************************************/ typedefstruct _jnode {
PSZ Key; // The key used for object
OPVAL Op; // Operator used for this node
PVAL CncVal; // To cont value used for OP_CNC int Rank; // The rank in array int Rx; // Read row number int Nx; // Next to read row number
} JNODE, *PJNODE;
typedefclass JSNX *PJSNX;
/*********************************************************************************/ /* The JSON utility functions. */ /*********************************************************************************/ bool IsNum(PSZ s); char *NextChr(PSZ s, char sep); char *GetJsonNull(void);
uint GetJsonGrpSize(void);
my_bool JsonSubSet(PGLOBAL g, my_bool b = false);
my_bool CalcLen(UDF_ARGS* args, my_bool obj, unsignedlong& reslen, unsignedlong& memlen, my_bool mod = false);
my_bool JsonInit(UDF_INIT* initid, UDF_ARGS* args, char* message, my_bool mbn, unsignedlong reslen, unsignedlong memlen, unsignedlong more = 0);
my_bool CheckMemory(PGLOBAL g, UDF_INIT* initid, UDF_ARGS* args, uint n,
my_bool m, my_bool obj = false, my_bool mod = false);
PSZ MakePSZ(PGLOBAL g, UDF_ARGS* args, int i); int IsJson(UDF_ARGS* args, uint i, bool b = false); char *GetJsonFile(PGLOBAL g, char* fn);
/*********************************************************************************/ /* Structure JPN. Used to make the locate path. */ /*********************************************************************************/ typedefstruct _jpn { int Type;
PCSZ Key; int N;
} JPN, *PJPN;
/*********************************************************************************/ /* Class JSNX: JSON access method. */ /*********************************************************************************/ class JSNX : public BLOCK { public: // Constructors
JSNX(PGLOBAL g, PJSON row, int type, int len = 64, int prec = 0, my_bool wr = false);
// Implementation int GetPrecision(void) {return Prec;}
PVAL GetValue(void) {return Value;}
// Default constructor not to be used
JSNX(void) = default;
// Members
PJSON Row;
PJVAL Jvalp;
PJPN Jpnp;
JOUTSTR *Jp;
JNODE *Nodes; // The intermediate objects
PVAL Value; //PVAL MulVal; // To value used by multiple column char *Jpath; // The json path int Buf_Type; intLong; int Prec; int Nod; // The number of intermediate objects int Xnod; // Index of multiple values int K; // Kth item to locate int I; // Index of JPN int Imax; // Max number of JPN's int B; // Index base
my_bool Xpd; // True for expandable column
my_bool Parsed; // True when parsed
my_bool Found; // Item found by locate
my_bool Wr; // Write mode
my_bool Jb; // Must return json item
}; // end of class JSNX
/*********************************************************************************/ /* Class JUP: used by jfile_convert to make a json file pretty = 0. */ /*********************************************************************************/ class JUP : public BLOCK { public: // Constructor
JUP(PGLOBAL g);
// Implementation void AddBuff(char c) { if (k < recl)
buff[k++] = c; else throw"Record size is too small";
} // end of AddBuff
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.