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

  • Committer: Tim Marston
  • Date: 2015-02-26 08:56:26 UTC
  • Revision ID: tim@ed.am-20150226085626-vba9c55uz3ta094h
improved support for blobs: added bind_blob(), added blob_t for binding stream
operators and blob() creation function; detect blob column type in row::column()

Show diffs side-by-side

added added

removed removed

Lines of Context:
127
127
        {
128
128
                assert( index <
129
129
                        static_cast< unsigned int >( sqlite3_column_count( _handle ) ) );
130
 
                const char *text = reinterpret_cast< const char * >(
131
 
                        sqlite3_column_text( _handle, index ) );
132
 
                if( text )
 
130
 
 
131
                switch( column_type( index ) ) {
 
132
                case SQLITE_NULL:
 
133
                        value = boost::get( boost::value_initialized< T >() );
 
134
                        break;
 
135
                case SQLITE_BLOB: {
 
136
                        int length = sqlite3_column_bytes( _handle, index );
 
137
                        std::string string_value( static_cast< const char * >(
 
138
                                        sqlite3_column_blob( _handle, index ) ), length );
 
139
                        value = boost::lexical_cast< T >( string_value );
 
140
                        break;
 
141
                }
 
142
                default:
 
143
                        const char *text = reinterpret_cast< const char * >(
 
144
                                sqlite3_column_text( _handle, index ) );
133
145
                        value = boost::lexical_cast< T >( text );
134
 
                else
135
 
                        value = boost::get( boost::value_initialized< T >() );
 
146
                }
136
147
        }
137
148
 
138
149
        /**