/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/database.h

  • Committer: edam
  • Date: 2010-07-23 09:17:03 UTC
  • Revision ID: edam@waxworlds.org-20100723091703-3siqjj6eeux9hupz
- added NEWS
- added library checks to configure.ac
- added query::iterators
- remove dependency that rows have on querys (since querys have to be dependent on rows for boost::iterator_facade to work)
- rows now have the handle to the sqlite3 statement and know a count of their row number
- added convenience function tht can be used to detect presence of sqlite3cc in other packages
- updated test-main
- renamed all subdir.mk files to emake.mk

Show diffs side-by-side

added added

removed removed

1
1
/*
2
 
 * connection.h
 
2
 * database.h
3
3
 *
4
4
 * Copyright (C) 2009 Tim Marston <edam@waxworlds.org>
5
5
 *
20
20
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
21
 */
22
22
 
23
 
#ifndef SQLITE3CC_CONNECTION_H_
24
 
#define SQLITE3CC_CONNECTION_H_
 
23
#ifndef SQLITE3CC_DATABASE_H_
 
24
#define SQLITE3CC_DATABASE_H_
25
25
 
26
26
 
27
27
#include <sqlite3.h>
28
28
#include <boost/utility.hpp>
29
 
#include <string>
30
29
 
31
30
 
32
31
namespace sqlite
33
32
{
34
33
 
35
34
 
36
 
namespace detail {
37
 
        class basic_statement;
38
 
        class basic_transaction;
39
 
}
40
 
 
41
 
 
42
 
class connection
 
35
class basic_statement;
 
36
class transaction;
 
37
 
 
38
 
 
39
class database
43
40
        :
44
41
        private boost::noncopyable
45
42
{
46
43
//______________________________________________________________________________
47
 
//                                                                         types
48
 
public:
49
 
 
50
 
        /**
51
 
         * Class to provide a scope lock for the connection mutex
52
 
         */
53
 
        class mutex_guard
54
 
        {
55
 
        public:
56
 
 
57
 
                /**
58
 
                 * Constructor that provides a connection upon which to act
59
 
                 * @param connection reference to a connection
60
 
                 * @see sqlite3_db_mutex()
61
 
                 * @see sqlite3_mutex_enter()
62
 
                 */
63
 
                mutex_guard(
64
 
                        connection &connection );
65
 
 
66
 
                ~mutex_guard();
67
 
 
68
 
                /**
69
 
                 * Release the mutex early
70
 
                 * @see sqlite3_mutex_leave()
71
 
                 */
72
 
                void leave();
73
 
 
74
 
        private:
75
 
                sqlite3_mutex *_mutex;
76
 
        };
77
 
 
78
 
//______________________________________________________________________________
79
44
//                                                                 instantiation
80
45
public:
81
46
 
84
49
         * @param filename the filename of the database file to open
85
50
         * @throws database_error on error
86
51
         */
87
 
        explicit connection(
 
52
        explicit database(
88
53
                const std::string &filename );
89
54
 
90
 
        explicit connection();
91
 
        virtual ~connection();
 
55
        explicit database();
 
56
        virtual ~database();
92
57
 
93
58
//______________________________________________________________________________
94
59
//                                                              public interface
113
78
        void close();
114
79
 
115
80
        /**
116
 
         * Execute an SQL statement. An exception is thrown on error.
 
81
         * Execute an SQL statement.
117
82
         * @param sql an SQL statement in UTF-8
 
83
         * @return an sqlite error code
118
84
         * @see sqlite3_exc()
119
85
         */
120
 
        void exec(
 
86
        int exec(
121
87
                const std::string &sql );
122
88
 
123
89
        /**
124
90
         * Sets a default busy handler which will
125
91
         * wait for the specified number of milliseconds.
126
 
         * @param duration number of milliseconds to wait
 
92
         * @param milliseconds number of milliseconds to wait
127
93
         * @returns an sqlite error code
128
94
         * @see sqlite3_busy_timeout()
129
95
         */
134
100
//                                                                implementation
135
101
private:
136
102
 
137
 
        friend class detail::basic_statement;
138
 
        friend class detail::basic_transaction;
 
103
        friend class basic_statement;
139
104
        friend class command;
140
 
        friend class sqlite_error;
141
105
 
142
 
        /** the connection handle */
 
106
        /** the database handle */
143
107
        sqlite3 *_handle;
144
108
 
145
109
};
148
112
} // namespace sqlite
149
113
 
150
114
 
151
 
#endif /* SQLITE3CC_CONNECTION_H_ */
 
115
#endif /* SQLITE3CC_DATABASE_H_ */