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>
7
8namespace 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:
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
44 enum RESTRICT {
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:
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
TYPES getType() const
Definition Datatype.h:59
bool okValue(const std::string &val) const
Definition Datatype.cxx:164
RESTRICT getRestrict() const
Definition Datatype.h:65
bool getInterval(std::string &min, std::string &max)
Definition Datatype.cxx:154
bool isCompatible(const Datatype *other) const
Definition Datatype.cxx:237
int getOutputSize() const
Definition Datatype.h:60
Enum * getEnum() const
Definition Datatype.h:64
const std::vector< std::string > & getChoices() const
Definition Datatype.h:16
bool choicesRequired() const
Definition Datatype.h:18