aboutsummaryrefslogtreecommitdiff
path: root/bbot/utility
blob: ebab97171c44d8f469f17e5503dd1330e2f1ae40 (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
// file      : bbot/utility -*- C++ -*-
// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd
// license   : MIT; see accompanying LICENSE file

#ifndef BBOT_UTILITY
#define BBOT_UTILITY

#include <memory>   // make_shared()
#include <string>   // to_string(), stoull()
#include <utility>  // move(), forward(), declval(), make_pair()
#include <cassert>  // assert()
#include <iterator> // make_move_iterator()

#include <butl/ft/lang>

#include <butl/process>
#include <butl/utility> // casecmp(), reverse_iterate(), etc
#include <butl/filesystem>

#include <bbot/types>
#include <bbot/version-impl>

namespace bbot
{
  using std::move;
  using std::forward;
  using std::declval;

  using std::make_pair;
  using std::make_shared;
  using std::make_move_iterator;
  using std::to_string;
  using std::stoull;

  // <butl/utility>
  //
  using butl::casecmp;
  using butl::reverse_iterate;

  using butl::exception_guard;
  using butl::make_exception_guard;

  // Process execution.
  //
  class tracer;

  template <typename I, typename O, typename E, typename P, typename... A>
  void
  run (tracer&, I&& in, O&& out, E&& err, P&&, A&&...);

  template <typename I, typename O, typename E, typename P, typename... A>
  butl::process_exit::code_type
  run_exit (tracer&, I&& in, O&& out, E&& err, P&&, A&&...);

  template <typename P, typename... A>
  inline void
  run (tracer& t, P&& p, A&&... a)
  {
    run (t, butl::fdnull (), 2, 2, forward<P> (p), forward<A> (a)...);
  }

  template <typename P, typename... A>
  inline butl::process_exit::code_type
  run_exit (tracer& t, P&& p, A&&... a)
  {
    return run (t, butl::fdnull (), 2, 2, forward<P> (p), forward<A> (a)...);
  }

  // Manifest parsing and serialization.
  //
  template <typename T>
  T
  parse_manifest (const path&, const char* what, bool ignore_unknown = true);

  template <typename T>
  void
  serialize_manifest (const T&, const path&, const char* what);

  template <typename T>
  void
  serialize_manifest (const T&,
                      ostream&,
                      const string& name,
                      const char* what);
}

#include <bbot/utility.txx>

#endif // BBOT_UTILITY