Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

osqlresult.cpp

Go to the documentation of this file.
00001 
00002 #include "osqlresult.h"
00003 
00004 using namespace Opie::DB;
00005 
00006 OSQLResultItem::OSQLResultItem( const TableString& string,
00007                                 const TableInt& Int)
00008     : m_string( string ), m_int( Int )
00009 {
00010 
00011 }
00012 OSQLResultItem::~OSQLResultItem() {
00013 }
00014 OSQLResultItem::OSQLResultItem( const OSQLResultItem& item) {
00015     *this = item;
00016 }
00017 OSQLResultItem &OSQLResultItem::operator=( const OSQLResultItem& other) {
00018     m_string = other.m_string;
00019     m_int = other.m_int;
00020     return *this;
00021 }
00022 OSQLResultItem::TableString OSQLResultItem::tableString()const{
00023     return m_string;
00024 }
00025 OSQLResultItem::TableInt OSQLResultItem::tableInt()const {
00026     return m_int;
00027 }
00028 QString OSQLResultItem::data( const QString& columnName, bool *ok ) const {
00029     TableString::ConstIterator it = m_string.find( columnName );
00030 
00031     /* if found */
00032     if ( it != m_string.end() ) {
00033         if ( ok ) *ok = true;
00034         return it.data();
00035     }else{
00036         if ( ok )  *ok = false;
00037         return QString::null;
00038     }
00039 
00040 }
00041 QString OSQLResultItem::data( int column, bool *ok ) const {
00042     TableInt::ConstIterator it = m_int.find( column );
00043 
00044     /* if found */
00045     if ( it != m_int.end() ) {
00046         if ( ok ) *ok = true;
00047         return it.data();
00048     }else{
00049         if ( ok )  *ok = false;
00050         return QString::null;
00051     }
00052 }
00053 /*
00054  * DateFormat is 'YYYY-MM-DD'
00055  */
00056 QDate OSQLResultItem::dataToDate( const QString& column, bool *ok ) {
00057     QDate date = QDate::currentDate();
00058     QString str = data( column,  ok );
00059     if (!str.isEmpty() ) {
00060       ;// convert
00061     }
00062     return date;
00063 }
00064 QDate OSQLResultItem::dataToDate( int column,  bool *ok ) {
00065     QDate date = QDate::currentDate();
00066     QString str = data( column,  ok );
00067     if (!str.isEmpty() ) {
00068       ;// convert
00069     }
00070     return date;
00071 
00072 }
00073 QDateTime OSQLResultItem::dataToDateTime( const QString& column, bool *ok ) {
00074 //    #FIXME xxx
00075     QDateTime time = QDateTime::currentDateTime();
00076     return time;
00077 }
00078 QDateTime OSQLResultItem::dataToDateTime( int column, bool *ok ) {
00079 //   #FIXME xxx
00080     QDateTime time = QDateTime::currentDateTime();
00081     return time;
00082 }
00083 
00084 OSQLResult::OSQLResult( enum State state,
00085                         const OSQLResultItem::ValueList& list,
00086                         const OSQLError::ValueList& error )
00087     : m_state( state ), m_list( list ), m_error( error )
00088 {
00089 
00090 }
00091 OSQLResult::~OSQLResult() {
00092 
00093 }
00094 OSQLResult::State OSQLResult::state()const {
00095     return m_state;
00096 }
00097 void OSQLResult::setState( OSQLResult::State state ) {
00098     m_state = state;
00099 }
00100 OSQLError::ValueList OSQLResult::errors()const {
00101     return m_error;
00102 }
00103 void OSQLResult::setErrors( const OSQLError::ValueList& err ) {
00104     m_error = err;
00105 }
00106 OSQLResultItem::ValueList OSQLResult::results()const {
00107     return m_list;
00108 }
00109 void OSQLResult::setResults( const OSQLResultItem::ValueList& result ) {
00110     m_list = result;
00111 }
00112 OSQLResultItem OSQLResult::first() {
00113     it = m_list.begin();
00114     return (*it);
00115 }
00116 OSQLResultItem OSQLResult::next(){
00117     ++it;
00118     return (*it);
00119 }
00120 bool OSQLResult::atEnd(){
00121     if ( it == m_list.end() )
00122         return true;
00123 
00124     return false;
00125 }
00126 OSQLResultItem::ValueList::ConstIterator OSQLResult::iterator()const {
00127     OSQLResultItem::ValueList::ConstIterator it;
00128     it = m_list.begin();
00129     return it;
00130 }

Generated on Sat Nov 5 16:16:11 2005 for OPIE by  doxygen 1.4.2