00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef CPPIDENTIFIER_H
00020 #define CPPIDENTIFIER_H
00021
00022 #include <dtoolbase.h>
00023
00024 #include "cppDeclaration.h"
00025 #include "cppNameComponent.h"
00026 #include "cppFile.h"
00027
00028 #include <string>
00029 #include <vector>
00030
00031 class CPPScope;
00032 class CPPType;
00033 class CPPPreprocessor;
00034 class CPPTemplateParameterList;
00035
00036
00037
00038
00039
00040 class CPPIdentifier {
00041 public:
00042 CPPIdentifier(const string &name, const CPPFile &file = CPPFile());
00043 CPPIdentifier(const CPPNameComponent &name);
00044 void add_name(const string &name);
00045 void add_name(const CPPNameComponent &name);
00046
00047 bool operator == (const CPPIdentifier &other) const;
00048 bool operator != (const CPPIdentifier &other) const;
00049 bool operator < (const CPPIdentifier &other) const;
00050
00051 bool is_scoped() const;
00052
00053 string get_simple_name() const;
00054 string get_local_name(CPPScope *scope = NULL) const;
00055 string get_fully_scoped_name() const;
00056
00057 bool is_fully_specified() const;
00058 bool is_tbd() const;
00059
00060
00061 CPPScope *get_scope(CPPScope *current_scope, CPPScope *global_scope,
00062 CPPPreprocessor *error_sink = NULL) const;
00063 CPPScope *get_scope(CPPScope *current_scope, CPPScope *global_scope,
00064 CPPDeclaration::SubstDecl &subst,
00065 CPPPreprocessor *error_sink = NULL) const;
00066
00067 CPPType *find_type(CPPScope *current_scope, CPPScope *global_scope,
00068 bool force_instantiate = false,
00069 CPPPreprocessor *error_sink = NULL) const;
00070 CPPType *find_type(CPPScope *current_scope, CPPScope *global_scope,
00071 CPPDeclaration::SubstDecl &subst,
00072 CPPPreprocessor *error_sink = NULL) const;
00073 CPPDeclaration *find_symbol(CPPScope *current_scope,
00074 CPPScope *global_scope,
00075 CPPPreprocessor *error_sink = NULL) const;
00076 CPPDeclaration *find_template(CPPScope *current_scope,
00077 CPPScope *global_scope,
00078 CPPPreprocessor *error_sink = NULL) const;
00079 CPPScope *find_scope(CPPScope *current_scope,
00080 CPPScope *global_scope,
00081 CPPPreprocessor *error_sink = NULL) const;
00082
00083 CPPIdentifier *substitute_decl(CPPDeclaration::SubstDecl &subst,
00084 CPPScope *current_scope,
00085 CPPScope *global_scope);
00086
00087 void output(ostream &out, CPPScope *scope) const;
00088 void output_local_name(ostream &out, CPPScope *scope) const;
00089 void output_fully_scoped_name(ostream &out) const;
00090
00091 typedef vector<CPPNameComponent> Names;
00092 Names _names;
00093 CPPScope *_native_scope;
00094 CPPFile _file;
00095 };
00096
00097 inline ostream &operator << (ostream &out, const CPPIdentifier &identifier) {
00098 identifier.output(out, (CPPScope *)NULL);
00099 return out;
00100 }
00101
00102
00103 #endif