PathSpec.cc
Go to the documentation of this file.
4 
5 #include <ostream>
6 #include <string>
7 #include <utility>
8 
9 namespace art {
10  std::pair<std::string, std::string>
12  {
13  detail::remove_whitespace(path_spec);
14  auto const pos = path_spec.find(":");
15  if (pos == std::string::npos) {
16  return std::make_pair("", path_spec);
17  }
18  return std::make_pair(path_spec.substr(0, pos), path_spec.substr(pos + 1));
19  }
20 
21  PathSpec
23  {
24  auto const colon_position = path_spec.find(":");
25  if (colon_position == std::string::npos) {
27  }
28  auto name = path_spec.substr(colon_position + 1);
29  auto const id = std::stoull(path_spec.substr(0, colon_position));
30  return PathSpec{move(name), PathID{id}};
31  }
32 
33  std::vector<PathSpec>
34  path_specs(std::vector<std::string> const& path_spec_strs)
35  {
36  std::vector<PathSpec> result;
37  cet::for_all_with_index(path_spec_strs,
38  [&result](size_t const i, auto const& str) {
39  auto spec = path_spec(str);
40  if (spec.path_id == PathID::invalid()) {
41  spec.path_id = PathID{i};
42  }
43  result.push_back(std::move(spec));
44  });
45  return result;
46  }
47 
49  to_string(PathID const id)
50  {
51  return std::to_string(id.id_);
52  }
53 
55  to_string(PathSpec const& spec)
56  {
57  return to_string(spec.path_id) + ':' + spec.name;
58  }
59 
60  std::ostream&
61  operator<<(std::ostream& os, PathSpec const& spec)
62  {
63  return os << to_string(spec);
64  }
65 }
static QCString name
Definition: declinfo.cpp:673
static QCString result
std::string string
Definition: nybbler.cc:12
void for_all_with_index(FwdCont &, Func)
PathID path_id
Definition: PathSpec.h:49
std::ostream & operator<<(std::ostream &os, const GroupSelector &gs)
std::vector< PathSpec > path_specs(std::vector< std::string > const &path_spec_strs)
Definition: PathSpec.cc:34
def move(depos, offset)
Definition: depos.py:107
std::string name
Definition: PathSpec.h:48
std::string to_string(PathSpec const &spec)
Definition: PathSpec.cc:55
constexpr static auto invalid() noexcept
Definition: PathSpec.h:20
void remove_whitespace(std::string &str)
PathSpec path_spec(std::string const &path_spec)
Definition: PathSpec.cc:22
std::string to_string(ModuleType const mt)
Definition: ModuleType.h:34
static QCString str
std::pair< std::string, std::string > split_process_and_path_names(std::string path_spec)
Definition: PathSpec.cc:11