Commit b656d3d3 authored by Olivier Bertrand's avatar Olivier Bertrand

Desesperatly trying to stop compiling failures

parent dc8f914c
......@@ -135,10 +135,10 @@ PBVAL BDOC::ParseJson(PGLOBAL g, char* js, size_t lng, int* ptyp, bool* comma) {
if (Bvp->Type != TYPE_UNKNOWN) {
Bvp->To_Val = ParseAsArray(g, i, pretty, ptyp);
Bvp->Type = TYPE_JAR;
} else if ((Bvp->To_Val = ParseObject(g, ++i)))
} else {
Bvp->To_Val = ParseObject(g, ++i);
Bvp->Type = TYPE_JOB;
else
throw 2;
} // endif Type
break;
case ' ':
......@@ -300,7 +300,7 @@ OFFSET BDOC::ParseObject(PGLOBAL g, int& i) {
} else
firstbpp = lastbpp = bpp;
level = 1;
level = 2;
} else {
sprintf(g->Message, "misplaced string near %.*s", ARGS);
throw 2;
......@@ -308,9 +308,9 @@ OFFSET BDOC::ParseObject(PGLOBAL g, int& i) {
break;
case ':':
if (level == 1) {
if (level == 2) {
lastbpp->Vlp = MOF(ParseValue(g, ++i));
level = 2;
level = 3;
} else {
sprintf(g->Message, "Unexpected ':' near %.*s", ARGS);
throw 2;
......@@ -318,15 +318,15 @@ OFFSET BDOC::ParseObject(PGLOBAL g, int& i) {
break;
case ',':
if (level < 2) {
if (level < 3) {
sprintf(g->Message, "Unexpected ',' near %.*s", ARGS);
throw 2;
} else
level = 0;
level = 1;
break;
case '}':
if (level < 2) {
if (!(level == 0 || level == 3)) {
sprintf(g->Message, "Unexpected '}' near %.*s", ARGS);
throw 2;
} // endif level
......@@ -1248,7 +1248,7 @@ PBVAL BJSON::SubAllocVal(PGLOBAL g)
/***********************************************************************/
/* Sub-allocate and initialize a BVAL as string. */
/***********************************************************************/
PBVAL BJSON::SubAllocVal(PGLOBAL g, OFFSET toval, JTYP type, short nd)
PBVAL BJSON::SubAllocVal(PGLOBAL g, OFFSET toval, int type, short nd)
{
PBVAL bvp = (PBVAL)BsonSubAlloc(g, sizeof(BVAL));
......
......@@ -77,7 +77,7 @@ class BJSON : public BLOCK {
void* BsonSubAlloc(PGLOBAL g, size_t size);
PBPR SubAllocPair(PGLOBAL g, OFFSET key, OFFSET val = 0);
PBVAL SubAllocVal(PGLOBAL g);
PBVAL SubAllocVal(PGLOBAL g, OFFSET toval, JTYP type = TYPE_UNKNOWN, short nd = 0);
PBVAL SubAllocVal(PGLOBAL g, OFFSET toval, int type = TYPE_UNKNOWN, short nd = 0);
PBVAL SubAllocVal(PGLOBAL g, PVAL valp);
PBVAL DupVal(PGLOBAL g, PBVAL bvp);
......
This diff is collapsed.
/******************** tabjson H Declares Source Code File (.H) *******************/
/* Name: bsonudf.h Version 1.0 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 2020 */
/* */
/* This file contains the BSON UDF function and class declares. */
/*********************************************************************************/
#pragma once
#include "jsonudf.h"
#include "bson.h"
/* --------------------------- New Testing BJSON Stuff --------------------------*/
typedef class BJNX* PBJNX;
/*********************************************************************************/
/* Class BJNX: BJSON access methods. */
/*********************************************************************************/
class BJNX : public BDOC {
public:
// Constructors
BJNX(PGLOBAL g, PBVAL row, int type, int len = 64, int prec = 0, my_bool wr = false);
// Implementation
int GetPrecision(void) { return Prec; }
PVAL GetValue(void) { return Value; }
// Methods
my_bool SetJpath(PGLOBAL g, char* path, my_bool jb = false);
my_bool ParseJpath(PGLOBAL g);
void ReadValue(PGLOBAL g);
PBVAL GetRowValue(PGLOBAL g, PBVAL row, int i, my_bool b = true);
PBVAL GetJson(PGLOBAL g);
my_bool CheckPath(PGLOBAL g);
my_bool WriteValue(PGLOBAL g, PBVAL jvalp);
char* Locate(PGLOBAL g, PBVAL jsp, PBVAL jvp, int k = 1);
char* LocateAll(PGLOBAL g, PBVAL jsp, PBVAL jvp, int mx = 10);
protected:
my_bool SetArrayOptions(PGLOBAL g, char* p, int i, PSZ nm);
PVAL GetColumnValue(PGLOBAL g, PBVAL row, int i);
PVAL ExpandArray(PGLOBAL g, PBVAL arp, int n);
PVAL CalculateArray(PGLOBAL g, PBVAL arp, int n);
PVAL MakeJson(PGLOBAL g, PBVAL bvp);
void SetJsonValue(PGLOBAL g, PVAL vp, PBVAL vlp);
PBVAL GetRow(PGLOBAL g);
my_bool CompareValues(PGLOBAL g, PBVAL v1, PBVAL v2);
my_bool LocateArray(PGLOBAL g, PBVAL jarp);
my_bool LocateObject(PGLOBAL g, PBPR jobp);
my_bool LocateValue(PGLOBAL g, PBVAL jvp);
my_bool LocateArrayAll(PGLOBAL g, PBVAL jarp);
my_bool LocateObjectAll(PGLOBAL g, PBPR jobp);
my_bool LocateValueAll(PGLOBAL g, PBVAL jvp);
my_bool CompareTree(PGLOBAL g, PBVAL jp1, PBVAL jp2);
my_bool AddPath(void);
// Default constructor not to be used
BJNX(void) {}
// Members
PBVAL Row;
PBVAL Bvalp;
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;
int Long;
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 BJNX
extern "C" {
DllExport my_bool json_test_bson_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char* json_test_bson(UDF_EXEC_ARGS);
DllExport void json_test_bson_deinit(UDF_INIT*);
DllExport my_bool jsonlocate_bson_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char* jsonlocate_bson(UDF_EXEC_ARGS);
DllExport void jsonlocate_bson_deinit(UDF_INIT*);
DllExport my_bool json_locate_all_bson_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char* json_locate_all_bson(UDF_EXEC_ARGS);
DllExport void json_locate_all_bson_deinit(UDF_INIT*);
} // extern "C"
......@@ -5,6 +5,7 @@
/* */
/* This file contains the JSON classes declares. */
/***********************************************************************/
#pragma once
#include <mysql_com.h>
#include "value.h"
#include "xobject.h"
......
This diff is collapsed.
......@@ -5,12 +5,13 @@
/* */
/* 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 "bson.h"
#include "json.h"
#define UDF_EXEC_ARGS \
UDF_INIT*, UDF_ARGS*, char*, unsigned long*, char*, char*
......@@ -51,6 +52,28 @@ typedef struct _jnode {
typedef class JSNX *PJSNX;
/*********************************************************************************/
/* The JSON tree node. Can be an Object or an Array. */
/*********************************************************************************/
bool IsNum(PSZ s);
char *NextChr(PSZ s, char sep);
char *GetJsonNull(void);
uint GetJsonGrpSize(void);
my_bool JsonSubSet(PGLOBAL g);
my_bool CalcLen(UDF_ARGS* args, my_bool obj, unsigned long& reslen,
unsigned long& memlen, my_bool mod = false);
my_bool JsonInit(UDF_INIT* initid, UDF_ARGS* args, char* message, my_bool mbn,
unsigned long reslen, unsigned long memlen,
unsigned long 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);
/*********************************************************************************/
/* The JSON UDF functions. */
/*********************************************************************************/
extern "C" {
DllExport my_bool jsonvalue_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char *jsonvalue(UDF_EXEC_ARGS);
......@@ -272,16 +295,16 @@ extern "C" {
DllExport my_bool countin_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport long long countin(UDF_EXEC_ARGS);
} // extern "C"
} // extern "C"
/*********************************************************************************/
/* Structure JPN. Used to make the locate path. */
/*********************************************************************************/
typedef struct _jpn {
enum JTYP Type;
PCSZ Key;
int N;
int Type;
PCSZ Key;
int N;
} JPN, *PJPN;
/*********************************************************************************/
......@@ -386,91 +409,3 @@ class JUP : public BLOCK {
uint i;
int k, recl;
}; // end of class JUP
/* --------------------------- New Testing BJSON Stuff --------------------------*/
typedef class BJNX* PBJNX;
/*********************************************************************************/
/* Class BJNX: BJSON access methods. */
/*********************************************************************************/
class BJNX : public BDOC {
public:
// Constructors
BJNX(PGLOBAL g, PBVAL row, int type, int len = 64, int prec = 0, my_bool wr = false);
// Implementation
int GetPrecision(void) { return Prec; }
PVAL GetValue(void) { return Value; }
// Methods
my_bool SetJpath(PGLOBAL g, char* path, my_bool jb = false);
my_bool ParseJpath(PGLOBAL g);
void ReadValue(PGLOBAL g);
PBVAL GetRowValue(PGLOBAL g, PBVAL row, int i, my_bool b = true);
PBVAL GetJson(PGLOBAL g);
my_bool CheckPath(PGLOBAL g);
my_bool WriteValue(PGLOBAL g, PBVAL jvalp);
char* Locate(PGLOBAL g, PBVAL jsp, PBVAL jvp, int k = 1);
char* LocateAll(PGLOBAL g, PBVAL jsp, PBVAL jvp, int mx = 10);
protected:
my_bool SetArrayOptions(PGLOBAL g, char* p, int i, PSZ nm);
PVAL GetColumnValue(PGLOBAL g, PBVAL row, int i);
PVAL ExpandArray(PGLOBAL g, PBVAL arp, int n);
PVAL CalculateArray(PGLOBAL g, PBVAL arp, int n);
PVAL MakeJson(PGLOBAL g, PBVAL bvp);
void SetJsonValue(PGLOBAL g, PVAL vp, PBVAL vlp);
PBVAL GetRow(PGLOBAL g);
my_bool CompareValues(PGLOBAL g, PBVAL v1, PBVAL v2);
my_bool LocateArray(PGLOBAL g, PBVAL jarp);
my_bool LocateObject(PGLOBAL g, PBPR jobp);
my_bool LocateValue(PGLOBAL g, PBVAL jvp);
my_bool LocateArrayAll(PGLOBAL g, PBVAL jarp);
my_bool LocateObjectAll(PGLOBAL g, PBPR jobp);
my_bool LocateValueAll(PGLOBAL g, PBVAL jvp);
my_bool CompareTree(PGLOBAL g, PBVAL jp1, PBVAL jp2);
my_bool AddPath(void);
// Default constructor not to be used
BJNX(void) {}
// Members
PBVAL Row;
PBVAL Bvalp;
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;
int Long;
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 BJNX
extern "C" {
DllExport my_bool json_test_bson_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char* json_test_bson(UDF_EXEC_ARGS);
DllExport void json_test_bson_deinit(UDF_INIT*);
DllExport my_bool jsonlocate_bson_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char* jsonlocate_bson(UDF_EXEC_ARGS);
DllExport void jsonlocate_bson_deinit(UDF_INIT*);
DllExport my_bool json_locate_all_bson_init(UDF_INIT*, UDF_ARGS*, char*);
DllExport char* json_locate_all_bson(UDF_EXEC_ARGS);
DllExport void json_locate_all_bson_deinit(UDF_INIT*);
} // extern "C"
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment