/*************** Valblk H Declares Source Code File (.H) ***************/ /* Name: VALBLK.H Version 2.1 */ /* */ /* (C) Copyright to the author Olivier BERTRAND 2005-2014 */ /* */ /* This file contains the VALBLK and derived classes declares. */ /***********************************************************************/
/***********************************************************************/ /* Include required application header files */ /* assert.h is header required when using the assert function. */ /* block.h is header containing Block global declarations. */ /***********************************************************************/ #ifndef __VALBLK__H__ #define __VALBLK__H__ #include"value.h"
/***********************************************************************/ /* Utility used to allocate value blocks. */ /***********************************************************************/
DllExport PVBLK AllocValBlock(PGLOBAL, void*, int, int, int, int, bool, bool, bool); constchar *GetFmt(int type, bool un = false);
/***********************************************************************/ /* DB static external variables. */ /***********************************************************************/ extern MBLOCK Nmblk; /* Used to initialize MBLOCK's */
/***********************************************************************/ /* Class MBVALS is a utility class for (re)allocating VALBLK's. */ /***********************************************************************/ class MBVALS : public BLOCK { //friend class LSTBLK; friendclass ARRAY; public: // Constructors
MBVALS(void) {Vblk = NULL; Mblk = Nmblk;}
// Methods void *GetMemp(void) {return Mblk.Memp;}
PVBLK Allocate(PGLOBAL g, int type, int len, int prec, int n, bool sub = false); bool ReAllocate(PGLOBAL g, int n); void Free(void);
protected: // Members
PVBLK Vblk; // Pointer to VALBLK
MBLOCK Mblk; // The memory block
}; // end of class MBVALS
typedefclass MBVALS *PMBV;
/***********************************************************************/ /* Class VALBLK represent a base class for variable blocks. */ /***********************************************************************/ class VALBLK : public BLOCK { public: // Constructors
VALBLK(void *mp, int type, int nval, bool un = false);
// Members
PGLOBAL Global; // Used for messages and allocation
MBLOCK Mblk; // Used to allocate buffer char *To_Nulls; // Null values array void *Blkp; // To value block bool Check; // If true SetValue types must match bool Nullable; // True if values can be null boolUnsigned; // True if values are unsigned int Type; // Type of individual values int Nval; // Max number of values in block int Prec; // Precision of float values
}; // end of class VALBLK
/***********************************************************************/ /* Class TYPBLK: represents a block of typed values. */ /***********************************************************************/ template <class TYPE> class TYPBLK : public VALBLK { public: // Constructors
TYPBLK(void *mp, int size, int type, int prec = 0, bool un = false);
// Methods using VALBLK::SetValue; void SetValue(PCSZ sp, int n) override; void SetValue(constchar *sp, uint len, int n) override; void SetValue(short sval, int n) override
{UnalignedWrite(n, (TYPE)sval); SetNull(n, false);} void SetValue(ushort sval, int n) override
{UnalignedWrite(n, (TYPE)sval); SetNull(n, false);} void SetValue(int lval, int n) override
{UnalignedWrite(n, (TYPE)lval); SetNull(n, false);} void SetValue(uint lval, int n) override
{UnalignedWrite(n, (TYPE)lval); SetNull(n, false);} void SetValue(longlong lval, int n) override
{UnalignedWrite(n, (TYPE)lval); SetNull(n, false);} void SetValue(ulonglong lval, int n) override
{UnalignedWrite(n, (TYPE)lval); SetNull(n, false);} void SetValue(double fval, int n) override
{UnalignedWrite(n, (TYPE)fval); SetNull(n, false);} void SetValue(char cval, int n) override
{UnalignedWrite(n, (TYPE)cval); SetNull(n, false);} void SetValue(uchar cval, int n) override
{UnalignedWrite(n, (TYPE)cval); SetNull(n, false);} void SetValue(PVAL valp, int n) override; void SetValue(PVBLK pv, int n1, int n2) override; void SetMin(PVAL valp, int n) override; void SetMax(PVAL valp, int n) override; void Move(int i, int j) override; int CompVal(PVAL vp, int n) override; int CompVal(int i1, int i2) override; void *GetValPtr(int n) override; void *GetValPtrEx(int n) override; int Find(PVAL vp) override; int GetMaxLength(void) override;
protected: // Specialized functions static ulonglong MaxVal(void);
TYPE GetTypedValue(PVAL vp);
TYPE GetTypedValue(PVBLK blk, int n);
// Members
TYPE* const &Typp; constchar *Fmt;
// Unaligned access
TYPE UnalignedRead(int n) const {
TYPE result;
memcpy(&result, Typp + n, sizeof(TYPE)); return result;
}
void UnalignedWrite(int n, TYPE value) {
memcpy(Typp + n, &value, sizeof(TYPE));
}
}; // end of class TYPBLK
/***********************************************************************/ /* Class CHRBLK: represent a block of fixed length strings. */ /***********************************************************************/ class CHRBLK : public VALBLK { public: // Constructors
CHRBLK(void *mp, int size, int type, int len, int prec, bool b);
// Methods using VALBLK::SetValue; void SetValue(PCSZ sp, int n) override; void SetValue(constchar *sp, uint len, int n) override; void SetValue(PVAL valp, int n) override; void SetValue(PVBLK pv, int n1, int n2) override; void SetMin(PVAL valp, int n) override; void SetMax(PVAL valp, int n) override; void Move(int i, int j) override; int CompVal(PVAL vp, int n) override; int CompVal(int i1, int i2) override; void *GetValPtr(int n) override; void *GetValPtrEx(int n) override; int Find(PVAL vp) override; int GetMaxLength(void) override;
protected: // Members char* const &Chrp; // Pointer to char buffer
PSZ Valp; // Used to make a zero ended value bool Blanks; // True for right filling with blanks bool Ci; // True if case insensitive intLong; // Length of each string
}; // end of class CHRBLK
/***********************************************************************/ /* Class STRBLK: represent a block of string pointers. */ /* Currently this class is used only by the DECODE scalar function */ /* and by the MyColumn function to store date formats. */ /***********************************************************************/ class STRBLK : public VALBLK { public: // Constructors
STRBLK(PGLOBAL g, void *mp, int size, int type);
// Methods using VALBLK::SetValue; void SetValue(PCSZ sp, int n) override; void SetValue(constchar *sp, uint len, int n) override; void SetValue(PVAL valp, int n) override; void SetValue(PVBLK pv, int n1, int n2) override; void SetMin(PVAL valp, int n) override; void SetMax(PVAL valp, int n) override; void Move(int i, int j) override; int CompVal(PVAL vp, int n) override; int CompVal(int i1, int i2) override; void *GetValPtr(int n) override; void *GetValPtrEx(int n) override; int Find(PVAL vp) override; int GetMaxLength(void) override;
// Specific void SetSorted(bool b) {Sorted = b;}
protected: // Members
PSZ* const &Strp; // Pointer to PSZ buffer bool Sorted; // Values are (semi?) sorted
}; // end of class STRBLK
/***********************************************************************/ /* Class DATBLK: represents a block of time stamp values. */ /***********************************************************************/ class DATBLK : public TYPBLK<int> { public: // Constructor
DATBLK(void *mp, int size);
// Implementation bool SetFormat(PGLOBAL g, PCSZ fmt, int len, int year = 0) override; char *GetCharString(char *p, int n) override;
// Methods using TYPBLK<int>::SetValue; void SetValue(PCSZ sp, int n) override;
protected: // Members
PVAL Dvalp; // Date value used to convert string
}; // end of class DATBLK
/***********************************************************************/ /* Class PTRBLK: represent a block of char pointers. */ /* Currently this class is used only by the ARRAY class to make and */ /* sort a list of char pointers. */ /***********************************************************************/ class PTRBLK : public STRBLK { friendclass ARRAY; friend PVBLK AllocValBlock(PGLOBAL, void *, int, int, int, int, bool, bool, bool); protected: // Constructors
PTRBLK(PGLOBAL g, void *mp, int size) : STRBLK(g, mp, size, TYPE_PCHAR) {}
// Implementation
// Methods using STRBLK::SetValue; using STRBLK::CompVal; void SetValue(PCSZ p, int n) override {Strp[n] = (char*)p;} int CompVal(int i1, int i2) override;
protected: // Members
}; // end of class PTRBLK
#endif// __VALBLK__H__
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.14 Sekunden
(vorverarbeitet am 2026-10-08)
¤
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.