ICG 2
Electric Boogaloo
Scope.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <deque>
4 #include <string>
5 #include <sstream>
6 
7 namespace JClang {
8 
13  class Scope {
14 
15  public:
16 
22  void push_qualifier(std::string name) {
23  qualified_name_parts.push_back(name);
24  }
25 
31  std::string pop_qualifier() {
32  std::string result = qualified_name_parts.back();
33  qualified_name_parts.pop_back();
34  return result;
35  }
36 
43  std::string make_scoped_name(std::string name) {
44  std::stringstream ss;
45  for (auto part : qualified_name_parts) {
46  ss << part << "::";
47  }
48  ss << name;
49  return ss.str();
50  }
51 
52  private:
53  std::deque<std::string> qualified_name_parts;
54  };
55 }
Keep track of the namespace scope that we're in.
Definition: Scope.hpp:13
std::string pop_qualifier()
Pop the top level qualifier when we leave a namespace/class.
Definition: Scope.hpp:31
std::string make_scoped_name(std::string name)
Take a top level name and attach the current qualifiers.
Definition: Scope.hpp:43
void push_qualifier(std::string name)
Push on a qualifier when we enter a namespace/class.
Definition: Scope.hpp:22
Definition: JClang.hpp:8