LRDE Tiger Compiler  1.34a $Id: 7fef12e1f5fa43449d667a0eec1d837c40fc1202 $
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
identifier.hh
Go to the documentation of this file.
1 
6 #ifndef TEMP_IDENTIFIER_HH
7 # define TEMP_IDENTIFIER_HH
8 
9 # include <iosfwd>
10 # include <string>
11 
12 # include <boost/variant/variant.hpp>
13 
14 # include <misc/symbol.hh>
15 # include <misc/xalloc.hh>
16 # include <temp/fwd.hh>
17 
18 namespace temp
19 {
20 
21  /*-------------.
22  | Identifier. |
23  `-------------*/
24 
67  template <template <typename Tag_> class Traits_>
68  class Identifier
69  {
70  public:
73  typedef boost::variant<unsigned, misc::symbol> value_type;
74 
75  public:
76  Identifier();
77  Identifier(const misc::symbol& sym);
78  Identifier(const std::string& str);
79  Identifier(const char* str);
80  Identifier(const self_type& id);
81 
82  public:
83  std::ostream& dump(std::ostream&) const;
85  std::string string_get() const;
86  const value_type& value_get() const;
87  const std::string& prefix_get() const;
88  int rank_get() const;
89 
90  public:
91  self_type& operator=(const self_type& rhs);
92 
93  bool operator==(const self_type& rhs) const;
94  bool operator!=(const self_type& rhs) const;
95  bool operator<(const self_type& rhs) const;
96  bool operator<=(const self_type& rhs) const;
97  bool operator>(const self_type& rhs) const;
98  bool operator>=(const self_type& rhs) const;
99 
100  public:
105 
106  private:
108  const std::string* prefix_;
109  int rank_;
110 
111  private:
113  static unsigned count_;
114  };
115 
117  template <template <typename Tag_> class Traits_>
118  std::ostream& operator<<(std::ostream& o, const Identifier<Traits_>& i);
119 
120 
121  /*------------------.
122  | Variant visitor. |
123  `------------------*/
124 
125  template <template <typename Elt_> class Cmp_>
126  class IdentifierCompareVisitor : public boost::static_visitor<bool>
127  {
128  public:
129  template <typename T, typename U>
130  bool operator()(const T&, const U&) const;
131 
132  template <typename T>
133  bool operator()(const T& lhs, const T& rhs) const;
134  };
135 
138 
139 } // namespace temp
140 
141 # include <temp/identifier.hxx>
142 
143 #endif // !TEMP_IDENTIFIER_HH