LRDE Tiger Compiler  1.34a $Id: 7fef12e1f5fa43449d667a0eec1d837c40fc1202 $
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
metavar-map.hxx
Go to the documentation of this file.
1 
6 #ifndef PARSE_METAVAR_MAP_HXX
7 # define PARSE_METAVAR_MAP_HXX
8 
9 # include <sstream>
10 # include <boost/lexical_cast.hpp>
11 # include <parse/metavar-map.hh>
12 
13 namespace parse
14 {
15 
16  template <typename Data>
17  MetavarMap<Data>::MetavarMap(const std::string& name)
18  : name_(name), map_()
19  {
20  }
21 
22  template <typename Data>
24  {
25  assertion(map_.empty());
26  }
27 
28  template <typename Data>
29  std::string
30  MetavarMap<Data>::show(unsigned key)
31  {
32  return '_' + name_ + '(' + boost::lexical_cast<std::string>(key) + ')';
33  }
34 
35  template <typename Data>
36  std::string
37  MetavarMap<Data>::append_(unsigned& count, Data* data)
38  {
39  map_[count] = data;
40  return show(count++);
41  }
42 
43  template <typename Data>
44  Data*
46  {
47  return map_.take(key);
48  }
49 
50 }
51 
52 #endif // !PARSE_METAVAR_MAP_HXX