/sqlite3cc

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

« back to all changes in this revision

Viewing changes to src/row.cc

  • Committer: edam
  • Date: 2010-07-29 06:28:53 UTC
  • Revision ID: edam@waxworlds.org-20100729062853-4i2fec52m86mh724
update NEWS and THANKS
- 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

21
21
 */
22
22
 
23
23
#include <sqlite3cc/row.h>
24
 
#include <sqlite3cc/query.h>
25
24
#include <sqlite3cc/manipulator.h>
26
25
#include <cassert>
27
26
 
28
27
 
29
28
sqlite::row::row(
30
 
        query &query,
31
 
        bool valid )
 
29
        sqlite3_stmt *handle,
 
30
        unsigned long long index )
32
31
        :
33
 
        _query( query ),
 
32
        _handle( handle ),
34
33
        _column_index( 0 ),
35
 
        _valid( valid )
 
34
        _index( index )
 
35
{
 
36
}
 
37
 
 
38
 
 
39
sqlite::row::row()
 
40
        :
 
41
        _index( std::numeric_limits< unsigned long long >::max() )
36
42
{
37
43
}
38
44
 
40
46
int sqlite::row::column_type(
41
47
        unsigned int index )
42
48
{
43
 
        assert( index <= _query.column_count() );
44
 
        return sqlite3_column_type( _query._handle, index );
 
49
        assert( index <
 
50
                static_cast< unsigned int >( sqlite3_column_count( _handle ) ) );
 
51
        return sqlite3_column_type( _handle, index );
45
52
}
46
53
 
47
54
 
48
55
unsigned int sqlite::row::column_bytes(
49
56
        unsigned int index )
50
57
{
51
 
        return sqlite3_column_bytes( _query._handle, index );
 
58
        return sqlite3_column_bytes( _handle, index );
52
59
}
53
60
 
54
61
 
55
62
sqlite::row &sqlite::row::operator >>(
56
 
        _set_index_t t )
 
63
        sqlite::detail::set_index_t t )
57
64
{
58
65
        _column_index = t._index;
59
66
        return *this;
61
68
 
62
69
 
63
70
template< >
64
 
sqlite::row &sqlite::row::operator >> < sqlite::_null_t >(
65
 
        _null_t & )
 
71
sqlite::row &sqlite::row::operator >> < sqlite::detail::null_t >(
 
72
        sqlite::detail::null_t & )
66
73
{
67
 
        assert( _column_index < _query.column_count() );
 
74
        assert( _column_index <
 
75
                static_cast< unsigned int >( sqlite3_column_count( _handle ) ) );
68
76
        _column_index++;
69
77
        return *this;
70
78
}