WORM 0.2
A C++ DAL/ORM code generation framework

src/sql/wsqlcolumn.h

Go to the documentation of this file.
00001 /*
00002     WORM - a DAL/ORM code generation framework
00003     Copyright (C) 2011  Erik Winn <erikwinnmail@yahoo.com>
00004 
00005     This program is free software: you can redistribute it and/or modify
00006     it under the terms of the GNU General Public License as published by
00007     the Free Software Foundation, either version 3 of the License, or
00008     (at your option) any later version.
00009 
00010     This program is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013     GNU General Public License for more details.
00014 
00015     You should have received a copy of the GNU General Public License
00016     along with this program.  If not, see <http://www.gnu.org/licenses/>.
00017 */
00018 
00019 
00020 #ifndef WSQLCOLUMN_H
00021 #define WSQLCOLUMN_H
00022 
00023 
00024 #include <string>
00025 
00026 #include "wsqldatatype.h"
00027 #include "wsqldatum.h"
00028 
00029 namespace WSql{
00030 
00031 class WSqlColumn
00032 {
00033 
00034     public:
00035         WSqlColumn();
00036         WSqlColumn( const WSqlColumn& other );
00037         virtual ~WSqlColumn();
00038         virtual WSqlColumn& operator=( const WSqlColumn& other );
00039         virtual bool operator==( const WSqlColumn& other ) const;
00040         inline bool operator!=(const WSqlColumn &other) const { return !operator==(other); }
00041         
00042         template <typename T> void setDefaultValue( const T t)
00043         {
00044             _default.setData(t);
00045         };
00046         template <typename T> T defaultValue()
00047         {
00048             return _default.data<T>();
00049         };
00050         
00051         void setVariableName( const std::string& name );
00052         void setColumnName( const std::string& name );
00053         void setMaxLength( int length ){_maxLength=length;}
00054         void setPrecision( int precision );
00055         void setDataType( WSqlDataType::Type type );
00056         void setIsAutoIncremented( bool b ) { _isAutoIncremented = b; }
00057         void setCanBeNull( bool b ) {_canBeNull = b;}
00058         void setIsPrimaryKey( bool b ) {_isPrimaryKey = b;}
00059         void setIsUnsigned(bool b){_isUnsigned=b;}
00060         
00061         const std::string& columnName() const;
00062         const std::string& variableName() const;
00063         std::string typeDeclaration()const;
00064         const int maxLength() const;
00065         const int precision() const;
00066         const WSqlDataType::Type type() const;
00067         bool isAutoIncremented() const {return _isAutoIncremented; }
00068         bool canBeNull() const;
00069         bool isPrimaryKey() const {return _isPrimaryKey;}
00070         bool isUnsigned() const {return _isUnsigned;}
00071         
00072         bool typeIsSupported()const;
00073 
00074     private:
00075         
00076         bool _canBeNull;
00077         bool _isAutoIncremented;
00078         bool _isPrimaryKey;
00079         bool _isUnsigned;
00080         int _maxLength;
00081         int _precision; 
00082         std::string _columnName;
00083         std::string _variableName;
00084         WSqlDatum _default;
00085         WSqlDataType::Type _type;
00086 };
00087 
00088 }//namespace WSql
00089 #endif // WSQLCOLUMN_H
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Defines