You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
143 lines
3.9 KiB
143 lines
3.9 KiB
/***************************************************************************
|
|
* *
|
|
* Copyright (C) 2003 *
|
|
* by Unai Garro (ugarro@users.sourceforge.net) *
|
|
* Martin Imobersteg <imm@gmx.ch> *
|
|
* and opie project *
|
|
* *
|
|
* *
|
|
* This code was originally developed by the opie project, on which *
|
|
* Martin Imobersteg based his work. *
|
|
* This file is adds a small extension, necessary to perform some minimum *
|
|
* SQL actions *
|
|
* *
|
|
* (this project is different from that in qsqlite.sf.net) *
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
* it under the terms of the GNU General Public License as published by *
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
* (at your option) any later version. *
|
|
***************************************************************************/
|
|
|
|
#ifndef TQSQLITERESULT_H
|
|
#define TQSQLITERESULT_H
|
|
|
|
#include <ntqdatetime.h>
|
|
#include <ntqmap.h>
|
|
#include <ntqvaluelist.h>
|
|
|
|
/**
|
|
* ResultRow represents one row of the resulting answer
|
|
*/
|
|
class TQSQLiteResultRow
|
|
{
|
|
public:
|
|
/**
|
|
* TableString is used to establish the relations
|
|
* between the column name and the real item
|
|
*/
|
|
typedef TQMap<TQString, TQCString> TableString;
|
|
|
|
/**
|
|
* TableInt is used to establish a relation between a
|
|
* position of a column and the row value
|
|
*/
|
|
typedef TQMap<int, TQCString> TableInt;
|
|
|
|
/**
|
|
* Default c'tor. It has a TableString and a TableInt
|
|
*/
|
|
TQSQLiteResultRow( const TableString& = TableString(),
|
|
const TableInt& = TableInt() );
|
|
TQSQLiteResultRow( const TQSQLiteResultRow& );
|
|
~TQSQLiteResultRow();
|
|
TQSQLiteResultRow &operator=( const TQSQLiteResultRow& );
|
|
|
|
/**
|
|
* returns the TableString
|
|
*/
|
|
TableString tableString() const;
|
|
|
|
/**
|
|
* returns the TableInt
|
|
*/
|
|
TableInt tableInt() const;
|
|
|
|
/**
|
|
* retrieves the Data from columnName
|
|
*
|
|
*/
|
|
TQCString data( const TQString& columnName, bool *ok = 0 );
|
|
|
|
/**
|
|
* TQString for column number
|
|
*/
|
|
TQCString data( int columnNumber, bool *ok = 0 );
|
|
|
|
/**
|
|
* Date conversion from columnName
|
|
*/
|
|
TQDate dataToDate( const TQString& columnName, bool *ok = 0 );
|
|
|
|
/**
|
|
* Date conversion from column-number
|
|
*/
|
|
TQDate dataToDate( int columnNumber, bool *ok = 0 );
|
|
|
|
TQDateTime dataToDateTime( const TQString& columName );
|
|
TQDateTime dataToDateTime( int columnNumber );
|
|
|
|
private:
|
|
TableString m_string;
|
|
TableInt m_int;
|
|
};
|
|
|
|
/**
|
|
* the TQSQLiteResult
|
|
* either a SQL statusment failed or succeeded
|
|
*/
|
|
class TQSQLiteResult
|
|
{
|
|
|
|
public:
|
|
typedef TQValueList<TQSQLiteResultRow> Columns;
|
|
|
|
/** The Status of a Result */
|
|
enum Status{ Success = 0, Failure, Undefined };
|
|
|
|
/**
|
|
* default c'tor
|
|
* @param status The Status of the Result
|
|
* @param r ResultItems
|
|
* @param error Error Message
|
|
*/
|
|
TQSQLiteResult( enum Status status = Undefined,
|
|
const Columns &r = Columns(),
|
|
const TQString &error = 0L );
|
|
~TQSQLiteResult();
|
|
|
|
Status getStatus() const;
|
|
Columns getResults() const;
|
|
TQString getError() const;
|
|
|
|
void setStatus( enum Status status );
|
|
void setResults( const Columns &result );
|
|
void setError( const TQString &error );
|
|
|
|
void addRow( TQSQLiteResultRow row );
|
|
|
|
TQSQLiteResultRow first();
|
|
TQSQLiteResultRow next();
|
|
bool atEnd();
|
|
|
|
Columns::ConstIterator iterator() const;
|
|
int size() const;
|
|
|
|
private:
|
|
enum Status m_status;
|
|
Columns m_list;
|
|
TQString m_error;
|
|
Columns::Iterator it;
|
|
};
|
|
|
|
#endif
|