aboutsummaryrefslogtreecommitdiff
path: root/bpkg/database
blob: 05ffb0488ddb08136282b2250bc120299ed938bb (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
// file      : bpkg/database -*- C++ -*-
// copyright : Copyright (c) 2014-2015 Code Synthesis Ltd
// license   : MIT; see accompanying LICENSE file

#ifndef BPKG_DATABASE
#define BPKG_DATABASE

#include <odb/sqlite/database.hxx>

#include <bpkg/types>
#include <bpkg/diagnostics>

namespace bpkg
{
  using odb::sqlite::database;
  using odb::sqlite::transaction;

  database
  open (const dir_path& configuration, tracer&, bool create = false);

  struct tracer_guard
  {
    tracer_guard (database& db, tracer& t)
        : db_ (db), t_ (db.tracer ()) {db.tracer (t);}
    ~tracer_guard () {db_.tracer (*t_);}

  private:
    database& db_;
    odb::tracer* t_;
  };
}

#endif // BPKG_DATABASE