• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

spl/data/DataColumn.h

00001 /*
00002  *   This file is part of the Standard Portable Library (SPL).
00003  *
00004  *   SPL is free software: you can redistribute it and/or modify
00005  *   it under the terms of the GNU General Public License as published by
00006  *   the Free Software Foundation, either version 3 of the License, or
00007  *   (at your option) any later version.
00008  *
00009  *   SPL is distributed in the hope that it will be useful,
00010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *   GNU General Public License for more details.
00013  *
00014  *   You should have received a copy of the GNU General Public License
00015  *   along with SPL.  If not, see <http://www.gnu.org/licenses/>.
00016  */
00017 #ifndef _datacolumn_h
00018 #define _datacolumn_h
00019 
00020 #include <spl/Debug.h>
00021 #include <spl/RefCountPtr.h>
00022 #include <spl/String.h>
00023 #include <spl/Variant.h>
00024 
00031 class DbSqlType
00032 {
00033 public:
00034         enum
00035         {
00036                 SQL_TYPE_UNASSIGNED = 0,
00037                 SQL_TYPE_INT8 = 1,
00038                 SQL_TYPE_INT16 = 2,
00039                 SQL_TYPE_INT32 = 3,
00040                 SQL_TYPE_INT64 = 4,
00041                 SQL_TYPE_DECIMAL = 5,   /* MYSQL: 65 digit fixed point */
00042                 SQL_TYPE_FLOAT32 = 6,
00043                 SQL_TYPE_FLOAT64 = 7,
00044                 SQL_TYPE_FLAG = 8,
00045                 SQL_TYPE_TIMESTAMP = 9,
00046                 SQL_TYPE_DATE = 10,
00047                 SQL_TYPE_DATETIME = 11,
00048                 SQL_TYPE_CHAR = 12,
00049                 SQL_TYPE_VARCHAR = 13,
00050                 SQL_TYPE_BLOB = 14
00051         };
00052 };
00053 
00054 class DataColumn;
00055 typedef RefCountPtr<DataColumn> DataColumnPtr;
00056 
00057 class DataColumn : public IMemoryValidate
00058 {
00059 private:
00060         String m_name;
00061         int m_colType;
00062         int m_dataLen;
00063         int m_index;
00064 
00065 public:
00066         DataColumn();
00067         DataColumn(const DataColumn& col);
00068         DataColumn(const String& name, int index = 0, int colType = DbSqlType::SQL_TYPE_UNASSIGNED, int dataLen = 0);
00069         virtual ~DataColumn();
00070 
00071         DataColumn& operator =(const DataColumn& col);
00072 
00073         inline String& Name() { return m_name; }
00074         inline int& Type() { return m_colType; }
00075         inline int& Length() { return m_dataLen; }
00076         inline int& Index() { return m_index; }
00077 
00078         DataColumnPtr Clone() const;
00079 
00080 #if defined(DEBUG)
00081         virtual void CheckMem() const;
00082         virtual void ValidateMem() const;
00083 #endif
00084 };
00085 
00088 #endif