BOSS 8.0.0
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 , 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 ,
  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 , 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 ,
  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 , 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 ,
  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)
 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/3]

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

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

◆ RESTRICT [2/3]

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

Definition at line 44 of file InstallArea/x86_64-el9-gcc13-dbg/include/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 };

◆ RESTRICT [3/3]

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

Definition at line 44 of file InstallArea/x86_64-el9-gcc13-opt/include/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/3]

Enumerator
TYPEnotFound 
TYPEenum 
TYPEdatetime 
TYPEtimestamp 
TYPEint 
TYPEmediumint 
TYPEsmallint 
TYPEreal 
TYPEdouble 
TYPEvarchar 
TYPEchar 
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/include/rdbModel/Tables/Datatype.h.

◆ TYPES [2/3]

Enumerator
TYPEnotFound 
TYPEenum 
TYPEdatetime 
TYPEtimestamp 
TYPEint 
TYPEmediumint 
TYPEsmallint 
TYPEreal 
TYPEdouble 
TYPEvarchar 
TYPEchar 
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/x86_64-el9-gcc13-dbg/include/rdbModel/Tables/Datatype.h.

◆ TYPES [3/3]

Enumerator
TYPEnotFound 
TYPEenum 
TYPEdatetime 
TYPEtimestamp 
TYPEint 
TYPEmediumint 
TYPEsmallint 
TYPEreal 
TYPEdouble 
TYPEvarchar 
TYPEchar 
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/x86_64-el9-gcc13-opt/include/rdbModel/Tables/Datatype.h.

Constructor & Destructor Documentation

◆ Datatype() [1/3]

rdbModel::Datatype::Datatype ( )
inline

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

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

Referenced by isCompatible().

◆ ~Datatype() [1/3]

rdbModel::Datatype::~Datatype ( )
inline

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

54 {
55 if ( m_enum ) delete m_enum;
56 }

◆ Datatype() [2/3]

rdbModel::Datatype::Datatype ( )
inline

Definition at line 53 of file InstallArea/x86_64-el9-gcc13-dbg/include/rdbModel/Tables/Datatype.h.

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

◆ ~Datatype() [2/3]

rdbModel::Datatype::~Datatype ( )
inline

Definition at line 54 of file InstallArea/x86_64-el9-gcc13-dbg/include/rdbModel/Tables/Datatype.h.

54 {
55 if ( m_enum ) delete m_enum;
56 }

◆ Datatype() [3/3]

rdbModel::Datatype::Datatype ( )
inline

Definition at line 53 of file InstallArea/x86_64-el9-gcc13-opt/include/rdbModel/Tables/Datatype.h.

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

◆ ~Datatype() [3/3]

rdbModel::Datatype::~Datatype ( )
inline

Definition at line 54 of file InstallArea/x86_64-el9-gcc13-opt/include/rdbModel/Tables/Datatype.h.

54 {
55 if ( m_enum ) delete m_enum;
56 }

Member Function Documentation

◆ getEnum() [1/3]

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

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

Definition at line 66 of file Calibration/rdbModel/include/rdbModel/Tables/Datatype.h.

66{ return m_enum; }

◆ getEnum() [2/3]

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

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

Definition at line 66 of file InstallArea/x86_64-el9-gcc13-dbg/include/rdbModel/Tables/Datatype.h.

66{ return m_enum; }

◆ getEnum() [3/3]

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

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

Definition at line 66 of file InstallArea/x86_64-el9-gcc13-opt/include/rdbModel/Tables/Datatype.h.

66{ return m_enum; }

◆ getInterval() [1/3]

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 {
157 min = m_min;
158 max = m_max;
159 return true;
160 }
161 return false;
162 }
#define min(a, b)
#define max(a, b)

Referenced by main().

◆ getInterval() [2/3]

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

◆ getInterval() [3/3]

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/3]

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

Definition at line 62 of file Calibration/rdbModel/include/rdbModel/Tables/Datatype.h.

62{ return m_outputSize; }

◆ getOutputSize() [2/3]

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

Definition at line 62 of file InstallArea/x86_64-el9-gcc13-dbg/include/rdbModel/Tables/Datatype.h.

62{ return m_outputSize; }

◆ getOutputSize() [3/3]

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

Definition at line 62 of file InstallArea/x86_64-el9-gcc13-opt/include/rdbModel/Tables/Datatype.h.

62{ return m_outputSize; }

◆ getRestrict() [1/3]

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

Definition at line 67 of file Calibration/rdbModel/include/rdbModel/Tables/Datatype.h.

67{ return m_restrict; }

◆ getRestrict() [2/3]

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

Definition at line 67 of file InstallArea/x86_64-el9-gcc13-dbg/include/rdbModel/Tables/Datatype.h.

67{ return m_restrict; }

◆ getRestrict() [3/3]

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

Definition at line 67 of file InstallArea/x86_64-el9-gcc13-opt/include/rdbModel/Tables/Datatype.h.

67{ return m_restrict; }

◆ getType() [1/3]

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

Definition at line 61 of file Calibration/rdbModel/include/rdbModel/Tables/Datatype.h.

61{ return m_type; }

◆ getType() [2/3]

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

Definition at line 61 of file InstallArea/x86_64-el9-gcc13-dbg/include/rdbModel/Tables/Datatype.h.

61{ return m_type; }

◆ getType() [3/3]

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

Definition at line 61 of file InstallArea/x86_64-el9-gcc13-opt/include/rdbModel/Tables/Datatype.h.

61{ return m_type; }

◆ isCompatible() [1/3]

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

Definition at line 233 of file Datatype.cxx.

233 {
234 // The ten distinct types can be partitioned into 4 sorts: integer,
235 // real, character, and date. Call two types compatible if they're
236 // in the same partition.
237 return ( findTOT( m_type ) == findTOT( other->m_type ) );
238 }
Index other(Index i, Index j)

◆ isCompatible() [2/3]

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

◆ isCompatible() [3/3]

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

◆ okValue() [1/3]

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

◆ okValue() [2/3]

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

◆ okValue() [3/3]

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

◆ rdbModel::XercesBuilder


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