/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Calibration/rdbModel/rdbModel-00-01-01/rdbModel/Tables/Datatype.h

Go to the documentation of this file.
00001 // $Header: /bes/bes/BossCvs/Calibration/rdbModel/rdbModel/Tables/Datatype.h,v 1.1.1.1 2005/10/17 06:10:53 maqm Exp $
00002 #ifndef RDBMODEL_DATATYPE_H
00003 #define RDBMODEL_DATATYPE_H
00004 #include <vector>
00005 #include <string>
00006 #include "rdbModel/Management/Visitor.h"
00007 
00008 namespace rdbModel{
00009 
00010   class XercesBuilder;
00011 
00014   class Enum {
00015   public: 
00016     const std::vector<std::string>& getChoices() const {
00017       return m_choices;}
00018     bool choicesRequired() const {return m_required;}
00019 
00020   private:
00021     friend class rdbModel::XercesBuilder;
00022     std::vector<std::string> m_choices;
00023     // sometimes column *must* have one of the enumerated values; 
00024     // other times they're just suggestions
00025     bool m_required;  
00026   };
00027 
00028   class Datatype {
00029   public:
00030     // Include MySQL-supported types we might conceivably use
00031     enum TYPES {
00032       TYPEnotFound = -1,
00033       TYPEenum = 0,
00034       TYPEdatetime,
00035       TYPEtimestamp,
00036       TYPEint,
00037       TYPEmediumint,
00038       TYPEsmallint,
00039       TYPEreal,
00040       TYPEdouble,
00041       TYPEvarchar,
00042       TYPEchar
00043     };
00044     enum RESTRICT {
00045       RESTRICTnone = 0,
00046       RESTRICTnonneg,   // value must be non-negative
00047       RESTRICTpos,      // value must be strictly positive
00048       RESTRICTinterval, // value (numeric or datetime) must be in interval    
00049       RESTRICTenum,     // restrict to, or suggest, enumerated set
00050       RESTRICTfile      // value must have valid file path syntax
00051     };
00052 
00053     Datatype() : m_restrict(RESTRICTnone), m_enum(0), m_isInt(false)  {}
00054     ~Datatype() {if (m_enum) delete m_enum;}
00057     bool okValue(const std::string& val) const;
00058     bool isCompatible(const Datatype* other) const;
00059     TYPES getType() const {return m_type;}
00060     int   getOutputSize() const {return m_outputSize;}
00061 
00064     Enum* getEnum() const {return m_enum;}
00065     RESTRICT getRestrict() const {return m_restrict;}
00066 
00071     bool getInterval(std::string& min, std::string& max);
00072 
00073 
00074   private:
00075     friend class rdbModel::XercesBuilder;
00076 
00077     // Bring all internal data specific to type up to date.  
00078     // Return type discovered, or -1 if unrecognized
00079     int setType(std::string name);
00080 
00081     // In case restriction type is RESTRICTinterval, bring internal data
00082     // up to date.  Return true if strings represent valid min and
00083     // max for column datatype
00084     bool setInterval(const std::string& min, const std::string& max);
00085 
00086     std::string m_typename;
00087 
00088     int m_outputSize;
00089 
00090     TYPES m_type;    // Do we want this or is string rep. good enough?
00091     RESTRICT m_restrict;
00092     // which, if any, of the following have interesting contents depends
00093     // on value of m_restrict
00094     Enum* m_enum;
00095     std::string m_min;   // form of these depends on value of m_type
00096     std::string m_max;   
00097     bool m_isInt;
00098     int m_minInt;         // applies only to integer types
00099     int m_maxInt; 
00100 
00101   };
00102 
00103 
00104 }
00105 #endif
00106 

Generated on Tue Nov 29 22:57:56 2016 for BOSS_7.0.2 by  doxygen 1.4.7