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 // Copyright 2011, Lowell Boggs Jr.
00005 //
00006 // This file or directory, containing source code for a computer program,
00007 // is Copyrighted by Lowell Boggs, Jr.  987 Regency Drive, Lewisville
00008 // TX (USA), 75067.  You may use, copy, modify, and distribute this
00009 // source file without charge or obligation so long as you agree to
00010 // the following:
00011 //
00012 //  1.  You must indemnify Lowell Boggs against any and all financial
00013 //      obligations caused by its use, misuse, function, or malfunction.
00014 //      Further, you acknowledge that there is no warranty of any kind,
00015 //      whatsoever.
00016 //
00017 //  2.  You agree not to attempt to patent any portion of this original
00018 //      work -- though you may attempt to patent your own extensions to
00019 //      it if you so choose.
00020 //
00021 //  3.  You keep this copyright notice with the file and all copies
00022 //      of the file and do not change it anyway except language translation.
00023 //
00024 // You are responsible for enforcing your own compliance with these
00025 // conditions and may not use this source file if you cannot agree to the
00026 // above terms and conditions.
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,       // or struct or union
00053            Enum,        // name of an enumeration type
00054            Enumeration, // enumeration value
00055            Typedef,
00056            Namespace,
00057            FileScope,    // a file containing scopes
00058            Used,         // using symbol;
00059            Define,       // #define name
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; // keyed on member name
00091 
00092        Children children_;  
00093 
00094 
00095        typedef Children::iterator iterator;             // just for convenience
00096        typedef Children::const_iterator const_iterator; // just for convenience
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 } // namespace CppTagDB
00217 } // namespace cxxtls
00218 
00219 
00220 
00221 #endif
Generated on Wed Feb 29 22:50:03 2012 for CXXUtilities by  doxygen 1.6.3