1 /**************** mongo H Declares Source Code File (.H) ***************/
2 /*  Name: mongo.h   Version 1.1                                        */
3 /*                                                                     */
4 /*  (C) Copyright to the author Olivier BERTRAND          2021         */
5 /*                                                                     */
6 /*  This file contains the common MongoDB classes declares.            */
7 /***********************************************************************/
8 #ifndef __MONGO_H
9 #define __MONGO_H
10 
11 #include "osutil.h"
12 #include "block.h"
13 #include "colblk.h"
14 
15 typedef class MGODEF *PMGODEF;
16 
17 typedef struct _bncol {
18 	struct _bncol *Next;
19 	char *Name;
20 	char *Fmt;
21 	int   Type;
22 	int   Len;
23 	int   Scale;
24 	bool  Cbn;
25 	bool  Found;
26 } BCOL, *PBCOL;
27 
28 /***********************************************************************/
29 /*  Class used to get the columns of a mongo collection.               */
30 /***********************************************************************/
31 class MGODISC : public BLOCK {
32 public:
33 	// Constructor
34 	MGODISC(PGLOBAL g, int *lg);
35 
36 	// Methods
37 	virtual bool Init(PGLOBAL g) { return false; }
38 	virtual void GetDoc(void) {}
39 	virtual bool Find(PGLOBAL g) = 0;
40 
41 	// Functions
42 	int  GetColumns(PGLOBAL g, PCSZ db, PCSZ uri, PTOS topt);
43 	void AddColumn(PGLOBAL g, PCSZ colname, PCSZ fmt, int k);
44 
45 	// Members
46 	BCOL    bcol;
47 	PBCOL   bcp, fbcp, pbcp;
48 	PMGODEF tdp;
49 	PTDB    tmgp;
50 	PCSZ    drv;
51 	int    *length;
52 	int     i, ncol, lvl;
53 	bool    all;
54 }; // end of MGODISC
55 
56 /***********************************************************************/
57 /*  MongoDB table.                                                     */
58 /***********************************************************************/
59 class DllExport MGODEF : public EXTDEF {          /* Table description */
60 	friend class TDBCMG;
61 	friend class TDBJMG;
62 	friend class TDBGOL;
63 	friend class TDBJGL;
64 	friend class CMGFAM;
65 	friend class MGODISC;
66 	friend DllExport PQRYRES MGOColumns(PGLOBAL, PCSZ, PCSZ, PTOS, bool);
67 public:
68 	// Constructor
69 	MGODEF(void);
70 
71 	// Implementation
72 	virtual const char *GetType(void) { return "MONGO"; }
73 
74 	// Methods
75 	virtual bool DefineAM(PGLOBAL g, LPCSTR am, int poff);
76 	virtual PTDB GetTable(PGLOBAL g, MODE m);
77 
78 protected:
79 	// Members
80 	PCSZ  Driver;						      /* MongoDB Driver (C or JAVA)          */
81 	PCSZ  Uri;							      /* MongoDB connection URI              */
82 	PSZ   Wrapname;               /* Java wrapper name                   */
83 	PCSZ  Colist;                 /* Options list                        */
84 	PCSZ  Filter;									/* Filtering query                     */
85 	PCSZ  Strfy;									/* The stringify columns               */
86 	int   Base;                   /* The array index base                */
87 	int   Version;                /* The Java driver version             */
88 	bool  Pipe;                   /* True is Colist is a pipeline        */
89 }; // end of MGODEF
90 
91 #endif // __MONGO_H
92