OpenASIP  2.0
SQLiteQueryResult.hh
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2009 Tampere University.
3 
4  This file is part of TTA-Based Codesign Environment (TCE).
5 
6  Permission is hereby granted, free of charge, to any person obtaining a
7  copy of this software and associated documentation files (the "Software"),
8  to deal in the Software without restriction, including without limitation
9  the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  and/or sell copies of the Software, and to permit persons to whom the
11  Software is furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in
14  all copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  DEALINGS IN THE SOFTWARE.
23  */
24 /**
25  * @file SQLiteQueryResult.hh
26  *
27  * Class definition of SQLiteQueryResult class.
28  *
29  * @author Pekka Jääskeläinen 2004 (pekka.jaaskelainen-no.spam-tut.fi)
30  *
31  * @note rating: red
32  */
33 
34 #ifndef TTA_SQLITE_QUERY_RESULT_HH
35 #define TTA_SQLITE_QUERY_RESULT_HH
36 
37 #include <vector>
38 #include <string>
39 #include <cstddef>
40 #include "sqlite3.h"
41 
42 #include "SQLiteConnection.hh"
44 #include "DataObject.hh"
45 
46 /**
47  * Implementation of RelationalDBQueryResult interface for SQLite.
48  *
49  */
51 public:
53  sqlite3_stmt* statement,
54  SQLiteConnection* connection,
55  bool init = true);
56  virtual ~SQLiteQueryResult();
57 
58  virtual int columns() const;
59  virtual std::string columnName(std::size_t columnIndex) const;
60  virtual const DataObject& data(std::size_t columnIndex) const;
61  virtual const DataObject& data(const std::string& name) const;
62  virtual bool hasNext();
63  virtual bool next();
64  virtual void bindInt(unsigned int position, int value);
65  virtual void bindString(unsigned int position, const std::string& value);
66  virtual void reset();
67 
68 private:
69  /// the compiled SQLite statement handle
70  sqlite3_stmt* statement_;
71  /// sqlite connection handle
73  /// column names
74  std::vector<std::string> columnNames_;
75  /// data of the current row
76  std::vector<DataObject> currentData_;
77  /// data of the next row
78  std::vector<DataObject> nextData_;
79  /// has next() been called for this query
81 };
82 
83 #endif
SQLiteQueryResult::hasNext
virtual bool hasNext()
Definition: SQLiteQueryResult.cc:146
SQLiteQueryResult::bindString
virtual void bindString(unsigned int position, const std::string &value)
Definition: SQLiteQueryResult.cc:223
RelationalDBQueryResult.hh
DataObject
Definition: DataObject.hh:50
SQLiteConnection.hh
SQLiteQueryResult::currentData_
std::vector< DataObject > currentData_
data of the current row
Definition: SQLiteQueryResult.hh:76
SQLiteQueryResult::next
virtual bool next()
Definition: SQLiteQueryResult.cc:162
SQLiteQueryResult::columnNames_
std::vector< std::string > columnNames_
column names
Definition: SQLiteQueryResult.hh:74
SQLiteQueryResult::data
virtual const DataObject & data(std::size_t columnIndex) const
Definition: SQLiteQueryResult.cc:114
SQLiteQueryResult::connection_
SQLiteConnection * connection_
sqlite connection handle
Definition: SQLiteQueryResult.hh:72
RelationalDBQueryResult
Definition: RelationalDBQueryResult.hh:46
SQLiteQueryResult::statement_
sqlite3_stmt * statement_
the compiled SQLite statement handle
Definition: SQLiteQueryResult.hh:70
SQLiteQueryResult
Definition: SQLiteQueryResult.hh:50
DataObject.hh
SQLiteQueryResult::~SQLiteQueryResult
virtual ~SQLiteQueryResult()
Definition: SQLiteQueryResult.cc:69
SQLiteQueryResult::bindInt
virtual void bindInt(unsigned int position, int value)
Definition: SQLiteQueryResult.cc:215
SQLiteQueryResult::nextData_
std::vector< DataObject > nextData_
data of the next row
Definition: SQLiteQueryResult.hh:78
SQLiteQueryResult::reset
virtual void reset()
Definition: SQLiteQueryResult.cc:232
SQLiteQueryResult::columnName
virtual std::string columnName(std::size_t columnIndex) const
Definition: SQLiteQueryResult.cc:98
SQLiteQueryResult::SQLiteQueryResult
SQLiteQueryResult(sqlite3_stmt *statement, SQLiteConnection *connection, bool init=true)
Definition: SQLiteQueryResult.cc:49
SQLiteQueryResult::columns
virtual int columns() const
Definition: SQLiteQueryResult.cc:86
SQLiteConnection
Definition: SQLiteConnection.hh:47
SQLiteQueryResult::dataInitialized_
bool dataInitialized_
has next() been called for this query
Definition: SQLiteQueryResult.hh:80