/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-29 06:28:53 UTC
  • Revision ID: edam@waxworlds.org-20100729062853-4i2fec52m86mh724
- made basic_statement::step() protected, for use by query and command only
- moved basic_statement::operator<<() to command and query instead; one needs to accept sqlite::exec, the other doesn't
- added tests for query::operator<<()
- added code to invlaidate in-progress queries during any transaction rollbacks (currently segfaults in basic_statement::finalize())
- added new sqlite_error constructor that obtains a full error message
- implemented database::database_mutex_guard class
- swapped command's step mutex in favour of the database mutex

Show diffs side-by-side

added added

removed removed

26
26
 
27
27
#include <sqlite3.h>
28
28
#include <boost/utility.hpp>
 
29
#include <string>
29
30
 
30
31
 
31
32
namespace sqlite
33
34
 
34
35
 
35
36
class basic_statement;
36
 
class transaction;
 
37
class basic_transaction;
37
38
 
38
39
 
39
40
class database
53
54
                const std::string &filename );
54
55
 
55
56
        explicit database();
56
 
        virtual ~database() throw( );
 
57
        virtual ~database();
57
58
 
58
59
//______________________________________________________________________________
59
60
//                                                              public interface
78
79
        void close();
79
80
 
80
81
        /**
81
 
         * Execute an SQL statement.
 
82
         * Execute an SQL statement. An exception is thrown on error.
82
83
         * @param sql an SQL statement in UTF-8
83
 
         * @return an sqlite error code
84
84
         * @see sqlite3_exc()
85
85
         */
86
 
        int exec(
 
86
        void exec(
87
87
                const std::string &sql );
88
88
 
89
89
        /**
98
98
 
99
99
//______________________________________________________________________________
100
100
//                                                                implementation
101
 
private:
 
101
protected:
102
102
 
103
103
        friend class basic_statement;
 
104
        friend class basic_transaction;
104
105
        friend class command;
 
106
        friend class query;
 
107
        friend class sqlite_error;
 
108
 
 
109
        /** class to provide a scope lock for the database mutex */
 
110
        class database_mutex_guard
 
111
        {
 
112
        public:
 
113
 
 
114
                /** constructor that provides a database */
 
115
                database_mutex_guard(
 
116
                        database &database );
 
117
 
 
118
                ~database_mutex_guard();
 
119
 
 
120
                /** release the mutex early */
 
121
                void leave();
 
122
 
 
123
        private:
 
124
                sqlite3_mutex *_mutex;
 
125
        };
 
126
 
 
127
private:
105
128
 
106
129
        /** the database handle */
107
130
        sqlite3 *_handle;