[odb-users] c++17,20,23 and sqlite

MM finjulhich at gmail.com
Sat Jan 29 14:10:01 EST 2022


On Mon, 24 Jan 2022 at 13:11, Boris Kolpackov <boris at codesynthesis.com>
wrote:

> MM <finjulhich at gmail.com> writes:
>
> > Hello,
> > I need to hold the content of a custom layout file in a cell, about 30
> > kbytes.
> > I have a 1-row table where I store static data. 1 of the columns would
> hold
> > the content of the file.
> >
> > First, I'm not sure what C++ type to use for that file. I need to store
> the
> > content, not the file path.
> > The first thing that springs to mind is that I like the std::byte type.
> > Would a std::basic_string<std::byte> work? Or a std::vector<std::byte>?
> > What type would have a natural mapping in sqlite?
>
> You can read more about the supported C++ to SQLite type mapping
> in Section 18.1, "SQLite Type Mapping" of the ODB manual:
>
> https://codesynthesis.com/products/odb/doc/manual.xhtml#18.1
>
> Specifically, Section 18.1.2, "Binary Type Mapping" talks about
> storing BLOB (binary large object). std::byte is most likely a
> cute alias for char or unsigned char so std::vectro<std::byte>
> will probably work out of the box.


Without a self-contained case, perhaps a specialisation is not found.

.cxx:1408:40: error: no matching function for call to
‘odb::sqlite::value_traits<std::vector<std::byte>,
odb::sqlite::id_blob>::set_image(odb::details::buffer&, std::size_t&,
bool&, const std::vector<std::byte>&)’
 1406 |       sqlite::value_traits<
      |       ~~~~~~~~~~~~~~~~~~~~~
 1407 |           ::std::vector< ::std::byte >,
      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1408 |           sqlite::id_blob >::set_image (
      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
 1409 |         i.data_value,
      |         ~~~~~~~~~~~~~
 1410 |         i.data_size,
      |         ~~~~~~~~~~~~
 1411 |         is_null,
      |         ~~~~~~~~
 1412 |         v);

with std::vector<char> it worked on the other hand.

odb 2.5.0-b.21
(GCC) 11.2.1 20211203

Regards.


More information about the odb-users mailing list