MAK Data Logger API Documentation for HLA
Home
Modules
Namespaces
Classes
Files
Examples
Libraries
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
include
vlDatabase
databaseColumn.h
Go to the documentation of this file.
1
/******************************************************************************
2
** Copyright (c) 1992-2010 VT MAK
3
** All rights reserved.
4
******************************************************************************/
5
8
9
#ifndef databaseColumn_H_
10
#define databaseColumn_H_
11
12
#include "
vlDatabase.h
"
13
14
15
#include <list>
16
#include <vlutil/vlString.h>
17
#include <vector>
18
19
20
// DtDatabaseColumn represents a single column in an SQL database table. It
21
// has a storage type from the enumerated list above, plus any of several
22
// attributes such as being a primary or secondary key; a display size; default
23
// value; et. al. The class has a stringRep() method that, once the attributes
24
// of the column have been defined, will provide a string that can be used as
25
// part of an SQL CREATE TABLE query for defining the column.
26
class
DT_DLL_VLDB
DtDatabaseColumn
27
{
28
public
:
29
// enumeration of storage types supported (note that this is not an
30
// exhaustive list of what SQL can support; rather, it's a list of
31
// useful types for our application).
32
enum
DataType
33
{
34
Type_SqlNone = 0,
// Nothing (not a type)
35
Type_SqlChar = 1,
// a char treated as an 8-bit integer
36
Type_SqlShort = 2,
37
Type_SqlInt = 3,
38
Type_SqlLong = 4,
39
Type_SqlFloat = 5,
40
Type_SqlDouble = 6,
41
Type_SqlFixedString = 7,
42
Type_SqlVarString = 8,
43
Type_SqlIndex = 9,
// not really a storage type, but a special column
44
// type that refers to a multi-column index (key).
45
Type_SqlEnum8 = 10,
46
Type_SqlEnum16 = 11,
47
Type_SqlEnum32 = 12,
48
Type_SqlBool = 13,
49
Type_SqlUnsignedShort = 15,
50
Type_SqlUnsignedInt = 16,
51
Type_SqlUnsignedLong = 17
52
};
53
55
typedef
std::list<DtString>
IndexNameList
;
56
57
// Main constructor
58
DtDatabaseColumn
(
const
DtString
& columnName,
DataType
columnType );
59
60
// Destructor
61
virtual
~
DtDatabaseColumn
();
62
63
// Copy constructor
64
DtDatabaseColumn
(
const
DtDatabaseColumn
& src );
65
66
// Assignment operator
67
virtual
DtDatabaseColumn
& operator=(
const
DtDatabaseColumn
& src );
68
69
// return the name of this column
70
const
DtString
& columnName()
const
;
72
virtual
void
setColumnName(
const
DtString
&);
73
74
// return the (storage) type of this column
75
DataType
columnType()
const
;
76
virtual
void
setColumnType(
DataType
type);
77
78
// return true if this column has a display size specified
79
bool
hasDisplaySize()
const
;
80
81
// return true if this column has a default value specified
82
bool
hasDefaultValue()
const
;
83
84
// Set / get common SQL field attributes
85
86
// the width of the display field for this column
87
int
displaySize()
const
;
88
void
setDisplaySize(
int
displaySize );
89
90
// the number of decimals to show (only applies to floats / doubles)
91
int
numDecimals()
const
;
92
void
setNumDecimals(
int
numDecimals );
93
94
// is this field unsigned?
95
bool
isUnsigned()
const
;
96
void
setIsUnsigned(
bool
isUnsigned );
97
98
// can this field have un-set (null) values?
99
bool
nullAllow()
const
;
100
void
setNullAllow(
bool
nullAllow );
101
102
// Is there a default value for this field? This is specifed as
103
// a string to be type independent.
104
const
DtString
& defaultValue()
const
;
105
void
setDefaultValue(
const
DtString
& defaultValue );
106
107
// Is this an auto-increment field? (auto-increment fields automatically
108
// count up, such as a record number).
109
bool
autoIncrement()
const
;
110
void
setAutoIncrement(
bool
autoIncrement );
111
112
// Is this field a table's primary key
113
bool
isPrimaryKey()
const
;
114
void
setIsPrimaryKey(
bool
isPrimaryKey );
115
116
// Is this field a secondary key for a table?
117
bool
isSecondaryKey()
const
;
118
void
setIsSecondaryKey(
bool
isSecondaryKey );
119
120
// If the column is an index definition, this is the list of column
121
// names that makes up that index
122
const
IndexNameList
& indexNameList()
const
;
123
124
// Add a column name to an index column
125
void
addIndexName(
const
DtString
& indexName );
126
127
// clear the index name list
128
void
clearIndexNameList();
129
130
// Get the current value.
131
const
DtString
& value()
const
;
132
133
// Set the current value.
134
void
setValue(
const
DtString
& value);
135
136
// Get the number of values.
137
int
valueCount()
const
;
138
139
// Get a specific value.
140
const
DtString
& value(
size_t
index)
const
;
141
142
// Add a new value.
143
void
addValue(
const
DtString
& value);
144
145
// Get to see if the value is null.
146
bool
isNull(
size_t
index)
const
;
147
148
// Get the data type for the native C/C++ type.
149
static
DataType
dataTypeFromNativeType(
const
DtString
& naticeCType);
150
151
static
DtString
& nullString();
152
153
protected
:
154
155
static
DtString
theNullString
;
156
157
DtString
myColumnName
;
158
DtString
myDefaultValue
;
159
160
std::vector<DtString>
myStringReps
;
161
IndexNameList
myIndexNameList
;
162
163
DataType
myColumnType
;
164
165
int
myDisplaySize
;
166
int
myNumDecimals
;
167
168
bool
myAutoIncrement
;
169
bool
myHasDefaultValue
;
170
bool
myHasDisplaySize
;
171
bool
myIsPrimaryKey
;
172
bool
myIsSecondaryKey
;
173
bool
myIsUnsigned
;
174
bool
myNullAllow
;
175
176
};
177
178
179
#endif
Document ID: Generated on Wed Jun 5 18:45:18 EDT 2019 from SVN revision 198968
Copyright © 2019 VT MAK. All Rights Reserved (
www.mak.com
)