/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-23 12:57:07 UTC
  • Revision ID: edam@waxworlds.org-20100723125707-qu9jk9vvg2uewx7t
- cleaned up test-main
- fixed comment type
- made sqlite::exec() throw instead of returning sqlite error code

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
64
71
sqlite::row &sqlite::row::operator >> < sqlite::_null_t >(
65
72
        _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
}