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

src/sql/wsqlresult.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 WSQLRESULT_H
00020 #define WSQLRESULT_H
00021 
00022 #include <vector>
00023 #include "wsql.h"
00024 #include "wsqlrecord.h"
00025 
00026 namespace WSql {
00027 
00028 class WSqlDriver;
00029 
00030 class WSqlResult
00031 {
00032 
00033 public:
00034     WSqlResult(const WSqlDriver *driver);
00035     WSqlResult( const WSql::WSqlResult& other);
00036     virtual ~WSqlResult();
00037     virtual WSqlResult& operator=(const WSqlResult& other);
00039 //     inline bool operator!=( const WSqlResult &other ) const { return !operator==( other ); }
00040 
00041     void addRecord(WSqlRecord& r){_records.push_back(r);}
00042     void setIsCached(bool b){ _isCached = b; }  
00043     void setIsValid(bool b){_isValid=b;}
00044     
00045     bool isValid()const{return _isValid;}
00046     bool isCached()const{return _isCached; }
00047     
00048     virtual int size()const {return _records.size(); }
00049     virtual int count()const {return size(); }
00050     virtual bool empty()const{ return _records.empty();}
00051     virtual bool hasOutValues() const { return !empty();}
00052     
00053     virtual void clear(){ _records.clear(); }
00054     
00055     virtual WSqlRecord current();
00056     virtual WSqlRecord fetch(int i = -1);
00057     virtual WSqlRecord fetchFirst();
00058     virtual WSqlRecord fetchLast();
00059     virtual WSqlRecord fetchNext();
00060     virtual WSqlRecord fetchPrevious();
00061 
00062 protected:
00063     virtual bool seek(int i, bool relative = false);
00064     virtual bool next();
00065     virtual bool previous();
00066     virtual bool first();
00067     virtual bool last();
00068     
00069     std::vector<WSqlRecord>::const_iterator const_cur_record_it;
00070     std::vector<WSqlRecord>::iterator record_it;
00071     const WSqlDriver *_driver;
00072     std::vector<WSqlRecord> _records;
00073     bool _isCached;
00074     private:
00075     bool _isValid;
00076 };
00077 
00078 } //namespace WSql
00079 
00080 #endif // WSQLRESULT_H
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Defines