1/**************** Array H Declares Source Code File (.H) ***************/
2/* Name: ARRAY.H Version 3.1 */
3/* */
4/* (C) Copyright to the author Olivier BERTRAND 2005-2017 */
5/* */
6/* This file contains the ARRAY and VALBASE derived classes declares. */
7/***********************************************************************/
8#ifndef __ARRAY_H
9#define __ARRAY_H
10
11
12/***********************************************************************/
13/* Include required application header files */
14/***********************************************************************/
15#include "xobject.h"
16#include "valblk.h"
17#include "csort.h"
18
19typedef class ARRAY *PARRAY;
20
21/***********************************************************************/
22/* Definition of class ARRAY with all its method functions. */
23/* Note: This is not a general array class that could be defined as */
24/* a template class, but rather a specific object containing a list */
25/* of values to be processed by the filter IN operator. */
26/* In addition it must act as a metaclass by being able to give back */
27/* the type of values it contains. */
28/* It must also be able to convert itself from some type to another. */
29/***********************************************************************/
30class DllExport ARRAY : public XOBJECT, public CSORT { // Array descblock
31 friend class MULAR;
32//friend class VALLST;
33//friend class SFROW;
34 public:
35 // Constructors
36 ARRAY(PGLOBAL g, int type, int size, int len = 1, int prec = 0);
37//ARRAY(PGLOBAL g, PQUERY qryp);
38//ARRAY(PGLOBAL g, PARRAY par, int k);
39
40 // Implementation
41 virtual int GetType(void) {return TYPE_ARRAY;}
42 virtual int GetResultType(void) {return Type;}
43 virtual int GetLength(void) {return Len;}
44 virtual int GetLengthEx(void) {return Len;}
45 virtual int GetScale() {return 0;}
46 int GetNval(void) {return Nval;}
47 int GetSize(void) {return Size;}
48// PVAL GetValp(void) {return Valp;}
49 void SetType(int atype) {Type = atype;}
50// void SetCorrel(bool b) {Correlated = b;}
51
52 // Methods
53 using XOBJECT::GetIntValue;
54 virtual void Reset(void) {Bot = -1;}
55 virtual int Qcompare(int *, int *);
56 virtual bool Compare(PXOB) {assert(false); return false;}
57 virtual bool SetFormat(PGLOBAL, FORMAT&) {assert(false); return false;}
58//virtual int CheckSpcCol(PTDB, int) {return 0;}
59 virtual void Printf(PGLOBAL g, FILE *f, uint n);
60 virtual void Prints(PGLOBAL g, char *ps, uint z);
61// void Empty(void);
62 void SetPrecision(PGLOBAL g, int p);
63 bool AddValue(PGLOBAL g, PSZ sp);
64 bool AddValue(PGLOBAL g, void *p);
65 bool AddValue(PGLOBAL g, short n);
66 bool AddValue(PGLOBAL g, int n);
67 bool AddValue(PGLOBAL g, double f);
68 bool AddValue(PGLOBAL g, PXOB xp);
69 bool AddValue(PGLOBAL g, PVAL vp);
70 void GetNthValue(PVAL valp, int n);
71 int GetIntValue(int n);
72 char *GetStringValue(int n);
73 BYTE Vcompare(PVAL vp, int n);
74 void Save(int);
75 void Restore(int);
76 void Move(int, int);
77 bool Sort(PGLOBAL g);
78 void *GetSortIndex(PGLOBAL g);
79 bool Find(PVAL valp);
80 bool FilTest(PGLOBAL g, PVAL valp, OPVAL opc, int opm);
81 int Convert(PGLOBAL g, int k, PVAL vp = NULL);
82 int BlockTest(PGLOBAL g, int opc, int opm,
83 void *minp, void *maxp, bool s);
84 PSZ MakeArrayList(PGLOBAL g);
85 bool CanBeShort(void);
86 bool GetSubValue(PGLOBAL g, PVAL valp, int *kp);
87
88 protected:
89 // Members
90 PMBV Valblk; // To the MBVALS class
91 PVBLK Vblp; // To Valblock of the data array
92//PVAL Valp; // The value used for Save and Restore is Value
93 int Size; // Size of value array
94 int Nval; // Total number of items in array
95 int Ndif; // Total number of distinct items in array
96 int Xsize; // Size of Index (used for correlated arrays)
97 int Type; // Type of individual values in the array
98 int Len; // Length of character string
99 int Bot; // Bottom of research index
100 int Top; // Top of research index
101 int X, Inf, Sup; // Used for block optimization
102//bool Correlated; // -----------> Temporary
103 }; // end of class ARRAY
104
105/***********************************************************************/
106/* Definition of class MULAR with all its method functions. */
107/* This class is used when constructing the arrays of constants used */
108/* for indexing. Its only purpose is to provide a way to sort, reduce */
109/* and reorder the arrays of multicolumn indexes as one block. Indeed */
110/* sorting the arrays independantly would break the correspondance of */
111/* column values. */
112/***********************************************************************/
113class MULAR : public CSORT, public BLOCK { // No need to be an XOBJECT
114 public:
115 // Constructor
116 MULAR(PGLOBAL g, int n);
117
118 // Implementation
119 void SetPars(PARRAY par, int i) {Pars[i] = par;}
120
121 // Methods
122 virtual int Qcompare(int *i1, int *i2); // Sort compare routine
123 bool Sort(PGLOBAL g);
124
125 protected:
126 // Members
127 int Narray; // The number of sub-arrays
128 PARRAY *Pars; // To the block of real arrays
129 }; // end of class ARRAY
130
131#endif // __ARRAY_H
132