cpptagdb.h
Go to the documentation of this file.00001 #ifndef CPPTAGDB_HEADER_FILE_INCLUDED_P
00002 #define CPPTAGDB_HEADER_FILE_INCLUDED_P
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00029
00030 #include <vector>
00031 #include <map>
00032 #include <set>
00033 #include <iostream>
00034
00035 #include <string>
00036
00037 namespace cxxtls
00038 {
00039 namespace CppTagDB
00040 {
00041
00042 struct SymbolInfo
00047 {
00048 enum Type
00049 {
00050 Function,
00051 Variable,
00052 Class,
00053 Enum,
00054 Enumeration,
00055 Typedef,
00056 Namespace,
00057 FileScope,
00058 Used,
00059 Define,
00060 unknownType,
00061 };
00062
00063 std::string fullname_;
00064 std::string member_;
00065 std::string type_;
00066 std::string file_;
00067 int line_;
00068 Type typeId_;
00069
00070 SymbolInfo()
00071 : line_(0)
00072 {
00073 }
00074
00075 SymbolInfo(std::string const &symbol,
00076 std::string const &member,
00077 std::string const &type,
00078 std::string const &file,
00079 int line
00080 )
00081 : fullname_(symbol)
00082 , member_(member)
00083 , type_(type)
00084 , file_(file)
00085 , line_(line)
00086 , typeId_(computeTypeId(type))
00087 {
00088 }
00089
00090 typedef std::multimap<std::string, SymbolInfo> Children;
00091
00092 Children children_;
00093
00094
00095 typedef Children::iterator iterator;
00096 typedef Children::const_iterator const_iterator;
00097
00098 void output(std::ostream &s, std::string indent) const;
00102
00103 friend std::ostream &operator<< (std::ostream &s, SymbolInfo const &me)
00111 {
00112 me.output(s, "");
00113 return s;
00114 }
00115
00116
00117 Type computeTypeId(std::string const &typeName);
00120
00121 char typeChar() const;
00122
00123 std::string annotatedName(bool member=false) const;
00124
00125
00126 };
00127
00128 class Info
00129 {
00130 public:
00131 typedef std::multimap<std::string, std::string> FilesMap;
00132
00133
00134
00135
00136 typedef std::multimap<std::string, SymbolInfo const *> MembersMap;
00137
00138
00139
00140
00141 typedef std::set<std::string> Directories;
00142
00143
00144
00145 SymbolInfo symbols_;
00146
00147
00148
00149 FilesMap files_;
00150
00151
00152 Directories directories_;
00153
00154 MembersMap members_;
00155
00156 void findMatchingFiles(std::string const &fileNodeName, std::vector<std::string> &output) const;
00164
00165 void findMatchingMembers(std::string const &memberName, std::vector<SymbolInfo const *> &output, bool caseSensitive=true) const;
00173
00174 void findRelativeFiles(std::string const &relativeSubPath, std::vector<std::string> &output) const;
00181
00182
00183
00184 Info()
00185 {
00186 }
00187
00188 int populate(std::string const &filename, int &failedLine);
00193
00194
00195 int populate(FILE *f, int &failedLine);
00196
00197
00198
00199
00200
00201
00202 friend std::ostream &operator<< (std::ostream &s, Info const &me);
00203
00204
00205
00206 private:
00207
00208 int populateSymbol(std::string const &filename, std::string const &info);
00209
00210
00211
00212
00213
00214 };
00215
00216 }
00217 }
00218
00219
00220
00221 #endif