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

src/sql/wsqlfield.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 #ifndef WSQLFIELD_H
00020 #define WSQLFIELD_H
00021 
00022 #include <string>
00023 #include "wsqldatum.h"
00024 #include "wsqldatatype.h"
00025 
00026 namespace WSql
00027 {
00028 
00029 class WSqlField
00030 {
00031     public:
00032 
00033         WSqlField();
00034         WSqlField(const std::string& fieldName, const std::string& columnName=std::string());
00035 /*        WSqlField( const std::string& columnName = std::string(),
00036                    WSqlDataType::Type typeflag = WSqlDataType::NOTYPE );*/
00037         
00038         WSqlField& operator=( const WSqlField& other );
00039         bool operator==( const WSqlField& other ) const;
00040         inline bool operator!=( const WSqlField &other ) const { return !operator==( other ); }
00041         ~WSqlField();
00042 
00043         void setData( std::string s ) { _data.setData<std::string>( s );}
00044         void setData( short sh ) { _data.setData<short>( sh );}
00045         void setData( int i ) { _data.setData<int>( i );}
00046         void setData( long l ) { _data.setData<long>( l );}
00047         void setData( float f ) { _data.setData<float>( f );}
00048         void setData( double d ) { _data.setData<double>( d );}
00049 
00050         template <typename T> T data()
00051         {
00052             return _data.data<T>();
00053         };
00054 
00055         inline const WSqlDatum& rawDatum() {return _data;}
00056 
00057         void clear();
00058         void setName( const std::string& fname ) {_name = fname;}
00059         void setColumnName( const std::string& cname ) {_columnName = cname;}
00060         void setIsDirty( bool b ) { _isDirty = b;}
00061         void setPrecision( int i ) {_precision = i;}
00062 
00063         inline const bool isDirty() const {return _isDirty;}
00064         inline const std::string& name()const {return _name;};
00065         inline const std::string& columnName() const {return _columnName;};
00066         inline const int precision()const {return _precision;}
00067 
00068     private:
00069         int _precision;
00070         bool _isDirty;
00071         std::string _columnName;
00072         std::string _name;
00073         WSqlDatum _data;
00075         // the real question is whether to stay light or subclass WSqlColumn??
00076 
00077 };
00078 
00079 } //namespace WSql
00080 
00081 
00082 #endif // WSQLFIELD_H
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Defines