ColumnType.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #pragma once
  2. namespace OTSSQLITE
  3. {
  4. class ColumnType
  5. {
  6. public:
  7. enum class ID
  8. {
  9. MIN = 0,
  10. INT = 0,
  11. FLOAT = 1,
  12. STRING = 2,
  13. BLOB = 3,
  14. NONE = 4,
  15. MAX = 4
  16. };
  17. public:
  18. ColumnType(const ID a_nTypeId,
  19. const BOOL a_bIsPrimaryKey = FALSE,
  20. const BOOL a_bIsNotNull = FALSE,
  21. const BOOL a_bIsUnique = FALSE)
  22. : m_nTypeId(a_nTypeId)
  23. , m_bIsPrimaryKey(a_bIsPrimaryKey)
  24. , m_bIsNotNull(a_bIsNotNull)
  25. , m_bIsUnique(a_bIsUnique)
  26. {
  27. }
  28. ~ColumnType()
  29. {}
  30. ID GetTypeId() const { return m_nTypeId; }
  31. BOOL IsPrimaryKey() const { return m_bIsPrimaryKey; }
  32. BOOL IsIsNotNull() const { return m_bIsNotNull; }
  33. BOOL IsIsUnique() const { return m_bIsUnique; }
  34. static CString GetName(const int a_nId);
  35. static CString GetName(const ColumnType a_type);
  36. static CString GetFormat(const int a_nId);
  37. static CString GetFormat(const ColumnType a_type);
  38. static const CString PrimaryKeyString() { return m_sPrimaryKeyString; }
  39. static const CString NotNullString() { return m_sNotNullString; }
  40. static const CString UniqueString() { return m_sUniqueString; }
  41. protected:
  42. const ID m_nTypeId;
  43. const BOOL m_bIsPrimaryKey;
  44. const BOOL m_bIsNotNull;
  45. const BOOL m_bIsUnique;
  46. static const CString m_sPrimaryKeyString;
  47. static const CString m_sNotNullString;
  48. static const CString m_sUniqueString;
  49. static const CString m_strNames[(int)ID::MAX - (int)ID::MIN + 1];
  50. };
  51. typedef std::pair<CString, ColumnType> ColumnDefine;
  52. }