MAK Data Logger API Documentation for HLA
Home
Modules
Namespaces
Classes
Files
Examples
Libraries
File List
File Members
libsrc
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
protected
:
152
153
static
DtString
theNullString
;
154
155
DtString
myColumnName
;
156
DtString
myDefaultValue
;
157
158
std::vector<DtString>
myStringReps
;
159
IndexNameList
myIndexNameList
;
160
161
DataType
myColumnType
;
162
163
int
myDisplaySize
;
164
int
myNumDecimals
;
165
166
bool
myAutoIncrement
;
167
bool
myHasDefaultValue
;
168
bool
myHasDisplaySize
;
169
bool
myIsPrimaryKey
;
170
bool
myIsSecondaryKey
;
171
bool
myIsUnsigned
;
172
bool
myNullAllow
;
173
174
};
175
176
177
#endif
Document ID: Generated on Mon Jan 19 08:20:14 EST 2015 from SVN revision 149581
Copyright © 2005-2012 VT MÄK. All Rights Reserved (
www.mak.com
)