aboutsummaryrefslogtreecommitdiff
path: root/odb/sqlite/blob.hxx
blob: eccb3abd178add203c555781acaefd1e20c7b180 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// file      : odb/sqlite/blob.hxx
// copyright : Copyright (c) 2005-2015 Code Synthesis Tools CC
// license   : GNU GPL v2; see accompanying LICENSE file

#ifndef ODB_SQLITE_BLOB_HXX
#define ODB_SQLITE_BLOB_HXX

#include <odb/pre.hxx>

#include <string>
#include <cstddef> // std::size_t

// Carefully allow this header to be included into the ODB compilation.
//
#ifndef ODB_COMPILER
#  include <odb/sqlite/forward.hxx>
#  include <odb/sqlite/details/export.hxx>
#endif

namespace odb
{
  namespace sqlite
  {
#ifdef ODB_COMPILER
    #pragma db sqlite:type("BLOB STREAM")
    class blob
#else
    class LIBODB_SQLITE_EXPORT blob
#endif
    {
    public:
      // BLOB size to provision for. Set before calling persist() or update().
      //
      explicit
      blob (std::size_t size = 0): size_ (size) {}

      std::size_t size () const {return size_;}
      void size (std::size_t s) {size_ = s;}

      const std::string& db () const {return db_;}
      const std::string& table () const {return table_;}
      const std::string& column () const {return column_;}
      long long rowid () const {return rowid_;}

      void
      clear ()
      {
        size_ = 0;
        db_.clear ();
        table_.clear ();
        column_.clear ();
        rowid_ = 0;
      }

    private:
#ifndef ODB_COMPILER
      friend struct default_value_traits<blob, id_blob_stream>;
#endif
      std::size_t size_;
      mutable std::string db_;
      mutable std::string table_;
      mutable std::string column_;
      mutable long long rowid_;
    };
  }
}

#include <odb/post.hxx>

#endif // ODB_SQLITE_BLOB_HXX