aboutsummaryrefslogtreecommitdiff
path: root/libbrep/review-manifest.hxx
blob: 260fdeceda4bc510e3fe56af3a7335b7e17affe6 (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
// file      : libbrep/review-manifest.hxx -*- C++ -*-
// license   : MIT; see accompanying LICENSE file

#ifndef LIBBREP_REVIEW_MANIFEST_HXX
#define LIBBREP_REVIEW_MANIFEST_HXX

#include <libbutl/manifest-forward.hxx>

#include <libbpkg/manifest.hxx>

#include <libbrep/types.hxx>
#include <libbrep/utility.hxx>

namespace brep
{
  enum class review_result: uint8_t
  {
    pass,
    fail,
    unchanged
  };

  string
  to_string (review_result);

  review_result
  to_review_result (const string&); // May throw invalid_argument.

  inline ostream&
  operator<< (ostream& os, review_result r)
  {
    return os << to_string (r);
  }

  struct review_aspect
  {
    string name;          // code, build, test, doc, etc
    review_result result;
  };

  class review_manifest
  {
  public:
    string reviewed_by;
    vector<review_aspect> results;
    optional<bpkg::version> base_version;
    optional<url> details_url;

    review_manifest (string r,
                     vector<review_aspect> rs,
                     optional<bpkg::version> bv,
                     optional<url> u)
        : reviewed_by (move (r)),
          results (move (rs)),
          base_version (move (bv)),
          details_url (move (u)) {}

  public:
    review_manifest () = default;
    review_manifest (butl::manifest_parser&, bool ignore_unknown = false);
    review_manifest (butl::manifest_parser&,
                     butl::manifest_name_value start,
                     bool ignore_unknown = false);

    void
    serialize (butl::manifest_serializer&) const;
  };

  class review_manifests: public vector<review_manifest>
  {
  public:
    review_manifests () = default;
    review_manifests (butl::manifest_parser&, bool ignore_unknown = false);

    void
    serialize (butl::manifest_serializer&) const;
  };
}

#endif // LIBBREP_REVIEW_MANIFEST_HXX