00001
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
00024
00025 bool m_required;
00026 };
00027
00028 class Datatype {
00029 public:
00030
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,
00047 RESTRICTpos,
00048 RESTRICTinterval,
00049 RESTRICTenum,
00050 RESTRICTfile
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
00078
00079 int setType(std::string name);
00080
00081
00082
00083
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;
00091 RESTRICT m_restrict;
00092
00093
00094 Enum* m_enum;
00095 std::string m_min;
00096 std::string m_max;
00097 bool m_isInt;
00098 int m_minInt;
00099 int m_maxInt;
00100
00101 };
00102
00103
00104 }
00105 #endif
00106