BOSS 7.0.4
BESIII Offline Software System
Loading...
Searching...
No Matches
rdbModel::Datatype Class Reference

#include <Datatype.h>

Public Types

enum  TYPES {
  TYPEnotFound = -1 , TYPEenum = 0 , TYPEdatetime , TYPEtimestamp ,
  TYPEint , TYPEmediumint , TYPEsmallint , TYPEreal ,
  TYPEdouble , TYPEvarchar , TYPEchar , TYPEnotFound = -1 ,
  TYPEenum = 0 , TYPEdatetime , TYPEtimestamp , TYPEint ,
  TYPEmediumint , TYPEsmallint , TYPEreal , TYPEdouble ,
  TYPEvarchar , TYPEchar
}
 
enum  RESTRICT {
  RESTRICTnone = 0 , RESTRICTnonneg , RESTRICTpos , RESTRICTinterval ,
  RESTRICTenum , RESTRICTfile , RESTRICTnone = 0 , RESTRICTnonneg ,
  RESTRICTpos , RESTRICTinterval , RESTRICTenum , RESTRICTfile
}
 
enum  TYPES {
  TYPEnotFound = -1 , TYPEenum = 0 , TYPEdatetime , TYPEtimestamp ,
  TYPEint , TYPEmediumint , TYPEsmallint , TYPEreal ,
  TYPEdouble , TYPEvarchar , TYPEchar , TYPEnotFound = -1 ,
  TYPEenum = 0 , TYPEdatetime , TYPEtimestamp , TYPEint ,
  TYPEmediumint , TYPEsmallint , TYPEreal , TYPEdouble ,
  TYPEvarchar , TYPEchar
}
 
enum  RESTRICT {
  RESTRICTnone = 0 , RESTRICTnonneg , RESTRICTpos , RESTRICTinterval ,
  RESTRICTenum , RESTRICTfile , RESTRICTnone = 0 , RESTRICTnonneg ,
  RESTRICTpos , RESTRICTinterval , RESTRICTenum , RESTRICTfile
}
 

Public Member Functions

 Datatype ()
 
 ~Datatype ()
 
bool okValue (const std::string &val) const
 
bool isCompatible (const Datatype *other) const
 
TYPES getType () const
 
int getOutputSize () const
 
EnumgetEnum () const
 
RESTRICT getRestrict () const
 
bool getInterval (std::string &min, std::string &max)
 
 Datatype ()
 
 ~Datatype ()
 
bool okValue (const std::string &val) const
 
bool isCompatible (const Datatype *other) const
 
TYPES getType () const
 
int getOutputSize () const
 
EnumgetEnum () const
 
RESTRICT getRestrict () const
 
bool getInterval (std::string &min, std::string &max)
 

Friends

class rdbModel::XercesBuilder
 

Detailed Description

Member Enumeration Documentation

◆ RESTRICT [1/2]

Enumerator
RESTRICTnone 
RESTRICTnonneg 
RESTRICTpos 
RESTRICTinterval 
RESTRICTenum 
RESTRICTfile 
RESTRICTnone 
RESTRICTnonneg 
RESTRICTpos 
RESTRICTinterval 
RESTRICTenum 
RESTRICTfile 

Definition at line 44 of file Calibration/rdbModel/rdbModel-00-01-01/rdbModel/Tables/Datatype.h.

◆ RESTRICT [2/2]

Enumerator
RESTRICTnone 
RESTRICTnonneg 
RESTRICTpos 
RESTRICTinterval 
RESTRICTenum 
RESTRICTfile 
RESTRICTnone 
RESTRICTnonneg 
RESTRICTpos 
RESTRICTinterval 
RESTRICTenum 
RESTRICTfile 

Definition at line 44 of file InstallArea/include/rdbModel/rdbModel/Tables/Datatype.h.

44 {
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 };

◆ TYPES [1/2]

Enumerator
TYPEnotFound 
TYPEenum 
TYPEdatetime 
TYPEtimestamp 
TYPEint 
TYPEmediumint 
TYPEsmallint 
TYPEreal 
TYPEdouble 
TYPEvarchar 
TYPEchar 
TYPEnotFound 
TYPEenum 
TYPEdatetime 
TYPEtimestamp 
TYPEint 
TYPEmediumint 
TYPEsmallint 
TYPEreal 
TYPEdouble 
TYPEvarchar 
TYPEchar 

Definition at line 31 of file Calibration/rdbModel/rdbModel-00-01-01/rdbModel/Tables/Datatype.h.

31 {
32 TYPEnotFound = -1,
33 TYPEenum = 0,
36 TYPEint,
43 };

◆ TYPES [2/2]

Enumerator
TYPEnotFound 
TYPEenum 
TYPEdatetime 
TYPEtimestamp 
TYPEint 
TYPEmediumint 
TYPEsmallint 
TYPEreal 
TYPEdouble 
TYPEvarchar 
TYPEchar 
TYPEnotFound 
TYPEenum 
TYPEdatetime 
TYPEtimestamp 
TYPEint 
TYPEmediumint 
TYPEsmallint 
TYPEreal 
TYPEdouble 
TYPEvarchar 
TYPEchar 

Definition at line 31 of file InstallArea/include/rdbModel/rdbModel/Tables/Datatype.h.

Constructor & Destructor Documentation

◆ Datatype() [1/2]

rdbModel::Datatype::Datatype ( )
inline

Definition at line 53 of file Calibration/rdbModel/rdbModel-00-01-01/rdbModel/Tables/Datatype.h.

53: m_restrict(RESTRICTnone), m_enum(0), m_isInt(false) {}

◆ ~Datatype() [1/2]

rdbModel::Datatype::~Datatype ( )
inline

Definition at line 54 of file Calibration/rdbModel/rdbModel-00-01-01/rdbModel/Tables/Datatype.h.

54{if (m_enum) delete m_enum;}

◆ Datatype() [2/2]

rdbModel::Datatype::Datatype ( )
inline

Definition at line 53 of file InstallArea/include/rdbModel/rdbModel/Tables/Datatype.h.

53: m_restrict(RESTRICTnone), m_enum(0), m_isInt(false) {}

◆ ~Datatype() [2/2]

rdbModel::Datatype::~Datatype ( )
inline

Definition at line 54 of file InstallArea/include/rdbModel/rdbModel/Tables/Datatype.h.

54{if (m_enum) delete m_enum;}

Member Function Documentation

◆ getEnum() [1/2]

Enum * rdbModel::Datatype::getEnum ( ) const
inline

Return pointer to Enum object owned by datatype (if none, return null pointer).

Definition at line 64 of file Calibration/rdbModel/rdbModel-00-01-01/rdbModel/Tables/Datatype.h.

64{return m_enum;}

Referenced by rdbModel::Column::getEnum().

◆ getEnum() [2/2]

Enum * rdbModel::Datatype::getEnum ( ) const
inline

Return pointer to Enum object owned by datatype (if none, return null pointer).

Definition at line 64 of file InstallArea/include/rdbModel/rdbModel/Tables/Datatype.h.

64{return m_enum;}

◆ getInterval() [1/2]

bool rdbModel::Datatype::getInterval ( std::string &  min,
std::string &  max 
)

User-supplied strings min and max will be set to min and max values, if any, for the Datatype object.
@ret true if there is a min & max, false otherwise

Definition at line 154 of file Datatype.cxx.

154 {
155 if (m_restrict == RESTRICTinterval) {
156 min = m_min;
157 max = m_max;
158 return true;
159 }
160 return false;
161 }

Referenced by main().

◆ getInterval() [2/2]

bool rdbModel::Datatype::getInterval ( std::string &  min,
std::string &  max 
)

User-supplied strings min and max will be set to min and max values, if any, for the Datatype object.
@ret true if there is a min & max, false otherwise

◆ getOutputSize() [1/2]

int rdbModel::Datatype::getOutputSize ( ) const
inline

Definition at line 60 of file Calibration/rdbModel/rdbModel-00-01-01/rdbModel/Tables/Datatype.h.

60{return m_outputSize;}

◆ getOutputSize() [2/2]

int rdbModel::Datatype::getOutputSize ( ) const
inline

Definition at line 60 of file InstallArea/include/rdbModel/rdbModel/Tables/Datatype.h.

60{return m_outputSize;}

◆ getRestrict() [1/2]

RESTRICT rdbModel::Datatype::getRestrict ( ) const
inline

Definition at line 65 of file Calibration/rdbModel/rdbModel-00-01-01/rdbModel/Tables/Datatype.h.

65{return m_restrict;}

◆ getRestrict() [2/2]

RESTRICT rdbModel::Datatype::getRestrict ( ) const
inline

Definition at line 65 of file InstallArea/include/rdbModel/rdbModel/Tables/Datatype.h.

65{return m_restrict;}

◆ getType() [1/2]

TYPES rdbModel::Datatype::getType ( ) const
inline

Definition at line 59 of file Calibration/rdbModel/rdbModel-00-01-01/rdbModel/Tables/Datatype.h.

59{return m_type;}

Referenced by rdbModel::Column::interpret().

◆ getType() [2/2]

TYPES rdbModel::Datatype::getType ( ) const
inline

Definition at line 59 of file InstallArea/include/rdbModel/rdbModel/Tables/Datatype.h.

59{return m_type;}

◆ isCompatible() [1/2]

bool rdbModel::Datatype::isCompatible ( const Datatype other) const

Definition at line 237 of file Datatype.cxx.

237 {
238 // The ten distinct types can be partitioned into 4 sorts: integer,
239 // real, character, and date. Call two types compatible if they're
240 // in the same partition.
241 return (findTOT(m_type) == findTOT(other->m_type));
242 }
Index other(Index i, Index j)
Definition: EvtCyclic3.cc:118

Referenced by rdbModel::Column::isCompatible().

◆ isCompatible() [2/2]

bool rdbModel::Datatype::isCompatible ( const Datatype other) const

◆ okValue() [1/2]

bool rdbModel::Datatype::okValue ( const std::string &  val) const

Check that supplied string has proper syntax for our type and is in accord with restriction, if any

Definition at line 164 of file Datatype.cxx.

164 {
165 using facilities::Util;
166
167 switch (m_type) {
168 case TYPEreal:
169 case TYPEdouble: {
170 double doubleVal;
171 try {
172 doubleVal = Util::stringToDouble(val);
173 }
174 catch (facilities::WrongType ex) {
175 return false;
176 }
177 if (m_restrict == RESTRICTnonneg) return (doubleVal >= 0.0 );
178 else if (m_restrict == RESTRICTpos) return (doubleVal > 0.0);
179 else if (m_restrict == RESTRICTinterval) {
180 double min = Util::stringToDouble(m_min);
181 double max = Util::stringToDouble(m_max);
182 return ((min <= doubleVal) && (doubleVal <= max));
183 }
184 return true;
185
186 }
187
188 case TYPEint:
189 case TYPEmediumint:
190 case TYPEsmallint: {
191 int intVal;
192
193 try {
194 intVal = Util::stringToInt(val);
195 }
196 catch (facilities::WrongType ex) {
197 return false;
198 }
199 return ((intVal >= m_minInt) && (intVal <= m_maxInt));
200 }
201 case TYPEvarchar:
202 case TYPEchar:
203 if (m_restrict == RESTRICTnone) return true;
204 // for now, don't attempt to parse file path
205 if (m_restrict == RESTRICTfile) return true;
206 if (!m_enum->choicesRequired()) return true;
207 case TYPEenum: {
208 unsigned nChoice = m_enum->getChoices().size();
209 for (unsigned i = 0; i < nChoice; i++) {
210 if (val == m_enum->getChoices()[i]) return true;
211 }
212 return false;
213 }
214 case TYPEdatetime:
215 case TYPEtimestamp: {
216 try {
217 facilities::Timestamp aTime(val);
218 if (m_restrict == RESTRICTinterval) {
221 return ((min <= aTime) && (aTime <= max));
222 }
223 return true;
224 }
225 catch (facilities::BadTimeInput ex) {
226 std::cerr << "From rdbModel::Datatype::okValue" << std::endl;
227 std::cerr << ex.complaint << std::endl;
228 return false;
229 }
230
231 }
232 default:
233 return false;
234 }
235 }
Exception class used when converting from string to numeric type.
const std::vector< std::string > & getChoices() const

Referenced by rdbModel::Column::okValue().

◆ okValue() [2/2]

bool rdbModel::Datatype::okValue ( const std::string &  val) const

Check that supplied string has proper syntax for our type and is in accord with restriction, if any

Friends And Related Function Documentation

◆ rdbModel::XercesBuilder


The documentation for this class was generated from the following files: