/sqlite3cc

To get this branch, use:
bzr branch http://bzr.ed.am/sqlite3cc

« back to all changes in this revision

Viewing changes to include/sqlite3cc/query.h

  • Committer: edam
  • Date: 2010-01-28 12:21:03 UTC
  • Revision ID: edam@waxworlds.org-20100128122103-v3gs6hro5h7ffnhb
- further initial development
- basic support for: queries, rows (query results)
- filename, comment header and project name consistency

Show diffs side-by-side

added added

removed removed

1
1
/*
2
 
 * query.hpp
 
2
 * query.h
3
3
 *
4
4
 * Copyright (C) 2009 Tim Marston <edam@waxworlds.org>
5
5
 *
6
 
 * This file is part of sqlitepp (hereafter referred to as "this program").
7
 
 * See http://www.waxworlds.org/edam/software/sqlitepp for more information.
 
6
 * This file is part of sqlite3cc (hereafter referred to as "this program").
 
7
 * See http://www.waxworlds.org/edam/software/sqlite3cc for more information.
8
8
 *
9
9
 * This program is free software: you can redistribute it and/or modify
10
10
 * it under the terms of the GNU Lesser General Public License as published
20
20
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
21
 */
22
22
 
23
 
#ifndef QUERY_HPP_
24
 
#define QUERY_HPP_
25
 
 
26
 
 
27
 
#include <sqlitepp/statement.hpp>
 
23
#ifndef SQLITE3CC_QUERY_H_
 
24
#define SQLITE3CC_QUERY_H_
 
25
 
 
26
 
 
27
#include <sqlite3cc/basic_statement.h>
28
28
 
29
29
 
30
30
namespace sqlite
31
31
{
32
32
 
33
33
 
 
34
class row;
 
35
 
 
36
 
34
37
class query
35
38
        :
36
 
        public statement
 
39
        public basic_statement
37
40
{
 
41
//______________________________________________________________________________
 
42
//                                                                 instantiation
 
43
public:
 
44
 
 
45
        /**
 
46
         * Constructor that provides a database upon which to act and the SQL
 
47
         * query to execute.
 
48
         * @param database a reference to a database
 
49
         * @param sql an SQL statement in UTF-8
 
50
         */
 
51
        explicit query(
 
52
                database &database,
 
53
                const std::string &sql );
 
54
 
 
55
        /**
 
56
         * Constructor that provides a database upon which to act.
 
57
         * @param database a reference to a database
 
58
         * @param sql an SQL statement in UTF-8
 
59
         */
 
60
        explicit query(
 
61
                database &database );
 
62
 
 
63
//______________________________________________________________________________
 
64
//                                                              public interface
 
65
public:
 
66
 
 
67
        /**
 
68
         * Prepare an SQL statement.
 
69
         * @param sql an SQL statement in UTF-8
 
70
         * @returns an sqlite error code
 
71
         * @see sqlite3_prepare_v2()
 
72
         */
 
73
        virtual int prepare(
 
74
                const std::string &sql );
 
75
 
 
76
        /**
 
77
         * Peform a step() and return row object that can be used to retrieve the
 
78
         * results.
 
79
         * @return a row object
 
80
         */
 
81
        row step();
 
82
 
 
83
        /**
 
84
         * Get the number of columns in the result of
 
85
         */
 
86
        unsigned int column_count();
38
87
 
39
88
};
40
89
 
41
90
 
42
 
}
43
 
 
44
 
 
45
 
#endif /* QUERY_HPP_ */
 
91
} // namespace sqlite
 
92
 
 
93
 
 
94
#endif /* SQLITE3CC_QUERY_H_ */