aboutsummaryrefslogtreecommitdiff
path: root/brep/package.cxx
blob: be140341ad3fadc2ba64d0552eb34980fb2c794a (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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
// file      : brep/package.cxx -*- C++ -*-
// copyright : Copyright (c) 2014-2015 Code Synthesis Ltd
// license   : MIT; see accompanying LICENSE file

#include <brep/package>

#include <utility> // move()
#include <cassert>

#include <odb/database.hxx>

#include <brep/package-odb>

using namespace std;
using namespace odb::core;

namespace brep
{
  // package
  //
  package::
  package (string nm,
           version_type vr,
           priority_type pr,
           string sm,
           license_alternatives_type la,
           strings tg,
           optional<string> ds,
           string ch,
           url_type ur,
           optional<url_type> pu,
           email_type em,
           optional<email_type> pe,
           dependencies_type dp,
           requirements_type rq,
           optional<path> lc,
           shared_ptr<repository_type> rp)
      : name (move (nm)),
        version (move (vr)),
        priority (move (pr)),
        summary (move (sm)),
        license_alternatives (move (la)),
        tags (move (tg)),
        description (move (ds)),
        changes (move (ch)),
        url (move (ur)),
        package_url (move (pu)),
        email (move (em)),
        package_email (move (pe)),
        dependencies (move (dp)),
        requirements (move (rq)),
        internal_repository (move (rp)),
        location (move (lc))
  {
    assert (internal_repository->internal);
  }

  package::
  package (string nm,
           version_type vr,
           shared_ptr<repository_type> rp)
      : name (move (nm)),
        version (move (vr))
  {
    assert (!rp->internal);
    external_repositories.emplace_back (move (rp));
  }

  package::_id_type package::
  _id () const
  {
    return _id_type {
      {
        name,
        version.epoch,
        version.canonical_upstream,
        version.revision
      },
      version.upstream};
  }

  void package::
  _id (_id_type&& v, database&)
  {
    const auto& dv (v.data.version);
    name = move (v.data.name);
    version = version_type (dv.epoch, move (v.upstream), dv.revision);
    assert (version.canonical_upstream == dv.canonical_upstream);
  }

  // repository
  //
  repository::
  repository (repository_location l, string d, dir_path p)
      : location (move (l)),
        display_name (move (d)),
        local_path (move (p)),
        internal (true)
  {
  }

  repository::_id_type repository::
  _id () const
  {
    return _id_type {location.canonical_name (), location.string ()};
  }

  void repository::
  _id (_id_type&& l)
  {
    location = repository_location (move (l.location));
    assert (location.canonical_name () == l.canonical_name);
  }
}