PathSpec.h
Go to the documentation of this file.
1 #ifndef art_Persistency_Provenance_PathSpec_h
2 #define art_Persistency_Provenance_PathSpec_h
3 
4 #include <iosfwd>
5 #include <limits>
6 #include <string>
7 #include <vector>
8 #include <tuple>
9 #include <utility>
10 
11 namespace art {
12  // Process name <-> Path name
13  std::pair<std::string, std::string> split_process_and_path_names(
15 
16  class PathID {
17  public:
18  constexpr explicit PathID(size_t const i) noexcept : id_{i} {}
19 
20  constexpr auto static invalid() noexcept { return PathID{}; }
21 
22  constexpr bool
23  operator==(PathID const other) const noexcept
24  {
25  return id_ == other.id_;
26  }
27 
28  constexpr bool
29  operator!=(PathID const other) const noexcept
30  {
31  return not operator==(other);
32  }
33 
34  constexpr bool
35  operator<(PathID const other) const noexcept
36  {
37  return id_ < other.id_;
38  }
39 
41 
42  private:
43  constexpr PathID() = default;
45  };
46 
47  struct PathSpec {
50  };
51 
52  inline auto
53  to_tuple(PathSpec const& spec) noexcept
54  {
55  return std::tie(spec.name, spec.path_id);
56  }
57 
58  inline bool
59  operator==(PathSpec const& a, PathSpec const& b)
60  {
61  return to_tuple(a) == to_tuple(b);
62  }
63 
64  inline bool
65  operator<(PathSpec const& a, PathSpec const& b)
66  {
67  return to_tuple(a) < to_tuple(b);
68  }
69 
70  // Conversion facilities for PathSpec <-> stringized form
72  std::string to_string(PathSpec const& spec);
73  PathSpec path_spec(std::string const& path_spec_str);
74  std::vector<PathSpec> path_specs(
75  std::vector<std::string> const& path_spec_strs);
76  std::ostream& operator<<(std::ostream& os, PathSpec const& spec);
77 }
78 
79 #endif /* art_Persistency_Provenance_PathSpec_h */
80 
81 // Local Variables:
82 // mode: c++
83 // End:
std::string string
Definition: nybbler.cc:12
PathID path_id
Definition: PathSpec.h:49
friend std::string to_string(PathID)
Definition: PathSpec.cc:49
auto to_tuple(PathSpec const &spec) noexcept
Definition: PathSpec.h:53
std::ostream & operator<<(std::ostream &os, const GroupSelector &gs)
constexpr PathID(size_t const i) noexcept
Definition: PathSpec.h:18
std::vector< PathSpec > path_specs(std::vector< std::string > const &path_spec_strs)
Definition: PathSpec.cc:34
const double a
size_t id_
Definition: PathSpec.h:44
constexpr bool operator<(PathID const other) const noexcept
Definition: PathSpec.h:35
static int max(int a, int b)
std::string name
Definition: PathSpec.h:48
constexpr bool operator==(PathID const other) const noexcept
Definition: PathSpec.h:23
constexpr bool operator!=(PathID const other) const noexcept
Definition: PathSpec.h:29
constexpr static auto invalid() noexcept
Definition: PathSpec.h:20
constexpr PathID()=default
static bool * b
Definition: config.cpp:1043
PathSpec path_spec(std::string const &path_spec)
Definition: PathSpec.cc:22
std::pair< std::string, std::string > split_process_and_path_names(std::string path_spec)
Definition: PathSpec.cc:11