summaryrefslogtreecommitdiff
path: root/src/include/xbssv.h
blob: 80da2d0d8bcc3c3f3e632594f19d7fa83d96cb5d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
/*  xbssv.h

XBase64 Software Library

Copyright (c) 1997,2003,2014,2022 Gary A Kunkel

The xb64 software library is covered under the terms of the GPL Version 3, 2007 license.

Email Contact:

    XDB-devel@lists.sourceforge.net
    XDB-users@lists.sourceforge.net

*/


#ifndef __XB_XBSSV_H__
#define __XB_XBSSV_H__

#ifdef  CMAKE_COMPILER_IS_GNUCC
#pragma interface
#endif


namespace xb{

class XBDLLEXPORT xbXBase;

///@cond DOXYOFF
struct XBDLLEXPORT xbErrorMessage{
  xbInt16    iErrorNo;
  const char *sErrorText;
};
///@endcond DOXYOFF


//! @brief Class for handling shared system variables.
/*!
This class defines static variables which are referenced across class instances.

This class is designed to have the variables set when the xbXBase class constructor is called 
(xbXBase is a derived class).  The xbXbase class is designed to be called first in an application 
programs, and it is only called once.  The static values in this class are typically initialized at
program startup and don't require additional updates.

*/


// By design, DBase allows mutliple records in a table all having the same key, but only one entry in a unique index
// XB_HALT_ON_DUP_KEY tells the library to not allow appending records which generate duplicate keys in a unique index
//
#if defined (XB_NDX_SUPPORT) || defined (XB_MDX_SUPPORT)
#define XB_HALT_ON_DUPKEY 0
#define XB_EMULATE_DBASE  1
#endif



class XBDLLEXPORT xbSsv{
 public:
  xbSsv();
  const static char *ErrorCodeText[];

  void       DisplayError              ( xbInt16 ErrorCode ) const;
  xbString&  GetDefaultDateFormat      () const;
  xbString&  GetDataDirectory          () const;
  xbInt16    GetEndianType             () const;

  const char *GetErrorMessage          ( xbInt16 ErrorCode ) const;
  void       SetDataDirectory          ( const xbString &sDataDirectory );
  void       SetDefaultDateFormat      ( const xbString &sDefaultDateFormat );


  xbBool     BitSet                    ( unsigned char c, xbInt16 iBitNo ) const;
  #ifdef XB_DEBUG_SUPPORT
  void       BitDump                   ( unsigned char c ) const;
  void       BitDump                   ( char c ) const;
  #endif

  xbBool     GetDefaultAutoCommit      () const;
  void       SetDefaultAutoCommit      ( xbBool bDefaultAutoCommit );

  xbString&  GetDefaultLogDirectory    () const;
  xbString&  GetDefaultLogFileName     () const;
  void       SetDefaultLogDirectory    ( const xbString &sDefaultLogDirectory );

  xbBool     GetMultiUser              () const;
  void       SetMultiUser              ( xbBool bMultiUser );

  #if defined (XB_NDX_SUPPORT) || defined (XB_MDX_SUPPORT)
  xbInt16    GetUniqueKeyOpt           () const;
  xbInt16    SetUniqueKeyOpt           ( xbInt16 iUniqueKeyOpt );
  #endif

  #ifdef XB_LOCKING_SUPPORT
  xbInt16    GetDefaultLockRetries     () const;
  void       SetDefaultLockRetries     ( xbInt16 iRetryCount );
  xbInt32    GetDefaultLockWait        () const;
  void       SetDefaultLockWait        ( xbInt32 lRetryWait );
  xbInt16    GetDefaultLockFlavor      () const;
  void       SetDefaultLockFlavor      ( xbInt16 iLockFlavor );
  xbBool     GetDefaultAutoLock        () const;
  void       SetDefaultAutoLock        ( xbBool bAutoLock );
  void       EnableDefaultAutoLock     ();
  void       DisableDefaultAutoLock    ();
  #endif

  #ifdef XB_MDX_SUPPORT
  xbInt16    GetCreateMdxBlockSize() const;
  xbInt16    SetCreateMdxBlockSize( xbInt16 ulBlockSize );
  #endif

 protected:

  void       SetEndianType             ();

  static xbInt16  iEndianType;             // B=Big Endian  L=Little Endian
  static xbString sNullString;             // Null String


 private:

  static xbString sDefaultDateFormat;
  static xbString sDataDirectory;          //Data file directory

  #ifdef XB_LOGGING_SUPPORT
  static xbString sDefaultLogDirectory;    //Default location to store log files
  static xbString sDefaultLogFileName;     //Default LogFileName
  #endif

  static xbInt16  iDefaultFileVersion;     // 3 = DBase 3
                                           // 4 = DBase 4
                                           // default version used in CreateTable command
                                           // can be over ridden at the Xbase level, or table level
                                           // Different versions can be open simultaneously

  static xbBool   bDefaultAutoCommit;      // Default dbf auto commit switch

  static xbBool   bMultiUser;              // True if multi user mode is turned on
                                           // Turn this off for better performance in single user mode
                                           // This needs to be turned on or off before any data tables are opened
                                           // turning this on after tables are opened, can result in out of date
                                           // file buffers if multiple users are sharing the files

#ifdef XB_LOCKING_SUPPORT
  static xbInt32  lDefaultLockWait;        // Number of milliseconds between lock retries
  static xbInt16  iDefaultLockRetries;     // Number of times to retry a lock before conceding
  static xbInt16  bDefaultAutoLock;        // Autolocking enabled?
  static xbInt16  iDefaultLockFlavor;      // 1 = DBase
                                           // 2 = Clipper   - not developed yet
                                           // 3 = FoxPro    - not developed yet
                                           // 9 = Xbase64   - not developed yet
#endif



#if defined (XB_NDX_SUPPORT) || defined (XB_MDX_SUPPORT)

  static xbInt16 iUniqueKeyOpt;

  // is one of:
  //    XB_HALT_ON_DUPKEY
  //    XB_EMULATE_DBASE

#endif


#ifdef XB_MDX_SUPPORT
  static xbInt16  iCreateMdxBlockSize;     // System level Mdx Block Size
#endif // XB_MDX_SUPPORT



};

}        /* namespace xb    */
#endif   /* __XB_XBSSV_H__ */