BOSS
7.1.2
BESIII Offline Software System
Loading...
Searching...
No Matches
Datatype.h
Go to the documentation of this file.
1
// $Header: /bes/bes/BossCvs/Calibration/rdbModel/rdbModel/Tables/Datatype.h,v 1.1.1.1 2005/10/17 06:10:53 maqm Exp $
2
#ifndef RDBMODEL_DATATYPE_H
3
#define RDBMODEL_DATATYPE_H
4
#include <vector>
5
#include <string>
6
#include "
rdbModel/Management/Visitor.h
"
7
8
namespace
rdbModel
{
9
10
class
XercesBuilder;
11
12
/// Extra little class for datatypes with values (preferred or
13
/// required) coming from an enumerated list
14
class
Enum
{
15
public
:
16
const
std::vector<std::string>&
getChoices
()
const
{
17
return
m_choices;}
18
bool
choicesRequired
()
const
{
return
m_required;}
19
20
private
:
21
friend
class
rdbModel::XercesBuilder
;
22
std::vector<std::string> m_choices;
23
// sometimes column *must* have one of the enumerated values;
24
// other times they're just suggestions
25
bool
m_required;
26
};
27
28
class
Datatype
{
29
public
:
30
// Include MySQL-supported types we might conceivably use
31
enum
TYPES
{
32
TYPEnotFound
= -1,
33
TYPEenum
= 0,
34
TYPEdatetime
,
35
TYPEtimestamp
,
36
TYPEint
,
37
TYPEmediumint
,
38
TYPEsmallint
,
39
TYPEreal
,
40
TYPEdouble
,
41
TYPEvarchar
,
42
TYPEchar
43
};
44
enum
RESTRICT
{
45
RESTRICTnone
= 0,
46
RESTRICTnonneg
,
// value must be non-negative
47
RESTRICTpos
,
// value must be strictly positive
48
RESTRICTinterval
,
// value (numeric or datetime) must be in interval
49
RESTRICTenum
,
// restrict to, or suggest, enumerated set
50
RESTRICTfile
// value must have valid file path syntax
51
};
52
53
Datatype
() : m_restrict(
RESTRICTnone
), m_enum(0), m_isInt(
false
) {}
54
~Datatype
() {
if
(m_enum)
delete
m_enum;}
55
/// Check that supplied string has proper syntax for our type and
56
/// is in accord with restriction, if any
57
bool
okValue
(
const
std::string& val)
const
;
58
bool
isCompatible
(
const
Datatype
* other)
const
;
59
TYPES
getType
()
const
{
return
m_type;}
60
int
getOutputSize
()
const
{
return
m_outputSize;}
61
62
/// Return pointer to Enum object owned by datatype (if none, return
63
/// null pointer).
64
Enum
*
getEnum
()
const
{
return
m_enum;}
65
RESTRICT
getRestrict
()
const
{
return
m_restrict;}
66
67
/** User-supplied strings min and max will be set to min and max values,
68
if any, for the Datatype object.
69
@ret true if there is a min & max, false otherwise
70
*/
71
bool
getInterval
(std::string&
min
, std::string&
max
);
72
73
74
private
:
75
friend
class
rdbModel::XercesBuilder
;
76
77
// Bring all internal data specific to type up to date.
78
// Return type discovered, or -1 if unrecognized
79
int
setType(std::string name);
80
81
// In case restriction type is RESTRICTinterval, bring internal data
82
// up to date. Return true if strings represent valid min and
83
// max for column datatype
84
bool
setInterval(
const
std::string&
min
,
const
std::string&
max
);
85
86
std::string m_typename;
87
88
int
m_outputSize;
89
90
TYPES
m_type;
// Do we want this or is string rep. good enough?
91
RESTRICT
m_restrict;
92
// which, if any, of the following have interesting contents depends
93
// on value of m_restrict
94
Enum
* m_enum;
95
std::string m_min;
// form of these depends on value of m_type
96
std::string m_max;
97
bool
m_isInt;
98
int
m_minInt;
// applies only to integer types
99
int
m_maxInt;
100
101
};
102
103
104
}
105
#endif
106
false
#define false
Definition
BesCxxPolicy/BesCxxPolicy-00-02-00/CxxFeatures/config.h:22
min
#define min(a, b)
Definition
Eepipi/Eepipi-00-01-00/src/ee2eepp/basesv5.1/f2c.h:153
max
#define max(a, b)
Definition
Eepipi/Eepipi-00-01-00/src/ee2eepp/basesv5.1/f2c.h:154
Visitor.h
rdbModel::Datatype
Definition
Datatype.h:28
rdbModel::Datatype::~Datatype
~Datatype()
Definition
Datatype.h:54
rdbModel::Datatype::getType
TYPES getType() const
Definition
Datatype.h:59
rdbModel::Datatype::okValue
bool okValue(const std::string &val) const
Definition
Datatype.cxx:164
rdbModel::Datatype::getRestrict
RESTRICT getRestrict() const
Definition
Datatype.h:65
rdbModel::Datatype::RESTRICT
RESTRICT
Definition
Datatype.h:44
rdbModel::Datatype::RESTRICTnone
@ RESTRICTnone
Definition
Datatype.h:45
rdbModel::Datatype::RESTRICTfile
@ RESTRICTfile
Definition
Datatype.h:50
rdbModel::Datatype::RESTRICTinterval
@ RESTRICTinterval
Definition
Datatype.h:48
rdbModel::Datatype::RESTRICTenum
@ RESTRICTenum
Definition
Datatype.h:49
rdbModel::Datatype::RESTRICTnonneg
@ RESTRICTnonneg
Definition
Datatype.h:46
rdbModel::Datatype::RESTRICTpos
@ RESTRICTpos
Definition
Datatype.h:47
rdbModel::Datatype::TYPES
TYPES
Definition
Datatype.h:31
rdbModel::Datatype::TYPEnotFound
@ TYPEnotFound
Definition
Datatype.h:32
rdbModel::Datatype::TYPEenum
@ TYPEenum
Definition
Datatype.h:33
rdbModel::Datatype::TYPEsmallint
@ TYPEsmallint
Definition
Datatype.h:38
rdbModel::Datatype::TYPEvarchar
@ TYPEvarchar
Definition
Datatype.h:41
rdbModel::Datatype::TYPEdatetime
@ TYPEdatetime
Definition
Datatype.h:34
rdbModel::Datatype::TYPEreal
@ TYPEreal
Definition
Datatype.h:39
rdbModel::Datatype::TYPEint
@ TYPEint
Definition
Datatype.h:36
rdbModel::Datatype::TYPEdouble
@ TYPEdouble
Definition
Datatype.h:40
rdbModel::Datatype::TYPEmediumint
@ TYPEmediumint
Definition
Datatype.h:37
rdbModel::Datatype::TYPEchar
@ TYPEchar
Definition
Datatype.h:42
rdbModel::Datatype::TYPEtimestamp
@ TYPEtimestamp
Definition
Datatype.h:35
rdbModel::Datatype::Datatype
Datatype()
Definition
Datatype.h:53
rdbModel::Datatype::getInterval
bool getInterval(std::string &min, std::string &max)
Definition
Datatype.cxx:154
rdbModel::Datatype::isCompatible
bool isCompatible(const Datatype *other) const
Definition
Datatype.cxx:237
rdbModel::Datatype::getOutputSize
int getOutputSize() const
Definition
Datatype.h:60
rdbModel::Datatype::getEnum
Enum * getEnum() const
Definition
Datatype.h:64
rdbModel::Enum
Definition
Datatype.h:14
rdbModel::Enum::getChoices
const std::vector< std::string > & getChoices() const
Definition
Datatype.h:16
rdbModel::Enum::choicesRequired
bool choicesRequired() const
Definition
Datatype.h:18
rdbModel::XercesBuilder
Definition
XercesBuilder.h:26
rdbModel
Definition
Metadata.h:11
7.1.2
Calibration
rdbModel
rdbModel-00-01-01
rdbModel
Tables
Datatype.h
Generated by
1.12.0