/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-27 15:12:55 UTC
  • Revision ID: edam@waxworlds.org-20100727151255-goaqgdz4kj13q7gz
- update TODO
- added some missing includes for <string>
- changed usage of database::exec() to not require return code!
- prevented transaction_guard destructor from throwing an exception

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>
33
33
{
34
34
 
35
35
 
36
 
namespace detail {
37
 
        class basic_statement;
38
 
        class basic_transaction;
39
 
}
40
 
 
41
 
 
42
 
class connection
 
36
class basic_statement;
 
37
class transaction;
 
38
 
 
39
 
 
40
class database
43
41
        :
44
42
        private boost::noncopyable
45
43
{
46
44
//______________________________________________________________________________
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
45
//                                                                 instantiation
80
46
public:
81
47
 
84
50
         * @param filename the filename of the database file to open
85
51
         * @throws database_error on error
86
52
         */
87
 
        explicit connection(
 
53
        explicit database(
88
54
                const std::string &filename );
89
55
 
90
 
        explicit connection();
91
 
        virtual ~connection();
 
56
        explicit database();
 
57
        virtual ~database();
92
58
 
93
59
//______________________________________________________________________________
94
60
//                                                              public interface
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_ */