Synopsis - Cross-Reference

File: /Synopsis/Parsers/Cxx/TypeIdFormatter.hh
 1//
 2// Copyright (C) 2008 Stefan Seefeld
 3// All rights reserved.
 4// Licensed to the public under the terms of the GNU LGPL (>= 2),
 5// see the file COPYING for details.
 6//
 7
 8#ifndef TypeIdFormatter_hh_
 9#define TypeIdFormatter_hh_
10
11#include "ASG.hh"
12#include "Types.hh"
13#include <string>
14#include <vector>
15
16class TypeIdFormatter : public Types::Visitor
17{
18public:
19  TypeIdFormatter();
20
21  //. Sets the current scope, pushing the previous onto a stack
22  void push_scope(const ScopedName& scope);
23  //. Pops the previous scope from the stack
24  void pop_scope();
25
26  //
27  // Type Visitor
28  //
29  //. Returns a formatter string for given type.
30  //. The option string pointer refers to the parameter name (where
31  //. applicable) so that it can be put in the right place for function pointer
32  //. types. The pointed to pointer will be set to 0 if the identifier is
33  //. used
34  std::string format(const Types::Type*, const std::string** id = 0);
35  virtual void visit_type(Types::Type*);
36  virtual void visit_unknown(Types::Unknown*);
37  virtual void visit_modifier(Types::Modifier*);
38  virtual void visit_named(Types::Named*);
39  virtual void visit_base(Types::Base*);
40  virtual void visit_declared(Types::Declared*);
41  virtual void visit_template_type(Types::Template*);
42  virtual void visit_parameterized(Types::Parameterized*);
43  virtual void visit_func_ptr(Types::FuncPtr*);
44
45private:
46  //. The Type String
47  std::string type_;
48  //. The current scope name
49  ScopedName scope_;
50  //. Returns the given Name relative to the current scope
51  std::string colonate(const ScopedName& name);
52  //. A stack of previous scopes
53  std::vector<ScopedName> scope_stack_;
54  //. A pointer to the identifier for function pointers
55  const std::string** fptr_id_;
56};
57
58#endif