A class that encapsulates the searching of the database created by the "etags" program. EtagsDB lets you read the database file and search it for a symbol. See "man etags" or a google search. More...
#include <etagsdb.h>
Public Member Functions | |
EtagsDB () | |
default constructor | |
EtagsDB (std::string etags_database_filename) | |
construct and open the specified file | |
bool | find_first (std::string const &symbol, std::string *file_name, int *line_number, std::string *line_text, bool case_sensitive_search=false) |
Find the first definition of a specified symbol name. This function must be called before find_next() -- which lets you find subsequent references to the symbol. The function return value indicates that the symbol was in fact found. The third parameter, case_sensitive_search, is used only if you want to find an exact match for the symbol including case. | |
bool | find_next (std::string *file_name, int *line_number, std::string *line_text) |
Find next is the same as find_first except that it does not allways start at the beginning of the tags database when doing searches -- rather it starts at the location just passed the most recent find first operation. | |
int | matching_files (std::string relative_path, std::list< std::string > *output) const |
Find all files in the etags database that 'match' the specified relative path. | |
bool | ok () const |
bool | set_tags_file (std::string tagsfile) |
Change the name of the tags database file -- closing the current one and opening a new one. The function returns true if error. | |
~EtagsDB () | |
destructor | |
Private Member Functions | |
EtagsDB (EtagsDB const &) | |
Copy constructor is private. | |
EtagsDB & | operator= (EtagsDB const &) |
Assignment operator is private. | |
int | searchFor (std::string const &symbol, std::string *foundFile, int *foundLine, std::string *sourceText) |
This helper function actually scans the TAGS file. | |
Private Attributes | |
bool | case_sensitive_ |
FILE * | file_ |
when file_ is 0, then the filename was bad | |
std::string | filename_ |
name of etags file | |
char | most_recent_file_ [2048] |
used in parsing | |
std::string | symbol_ |
name of symbol to find |
A class that encapsulates the searching of the database created by the "etags" program. EtagsDB lets you read the database file and search it for a symbol. See "man etags" or a google search.
Definition at line 44 of file etagsdb.h.
EtagsDB | ( | std::string | etags_database_filename | ) |
construct and open the specified file
Definition at line 33 of file etagsdb.cxx.
EtagsDB | ( | ) |
default constructor
Definition at line 304 of file etagsdb.cxx.
~EtagsDB | ( | ) |
destructor
Definition at line 42 of file etagsdb.cxx.
bool find_first | ( | std::string const & | symbol, | |
std::string * | file_name, | |||
int * | line_number, | |||
std::string * | line_text, | |||
bool | case_sensitive_search = false | |||
) |
Find the first definition of a specified symbol name. This function must be called before find_next() -- which lets you find subsequent references to the symbol. The function return value indicates that the symbol was in fact found. The third parameter, case_sensitive_search, is used only if you want to find an exact match for the symbol including case.
This search function assumes you are looking for C++ symbols and will return class members matching the symbol name, namespace members matching the symbol name, and global symbols -- including #defines.
This function starts searching at the beginning of the database.
Definition at line 51 of file etagsdb.cxx.
bool find_next | ( | std::string * | file_name, | |
int * | line_number, | |||
std::string * | line_text | |||
) |
Find next is the same as find_first except that it does not allways start at the beginning of the tags database when doing searches -- rather it starts at the location just passed the most recent find first operation.
Definition at line 282 of file etagsdb.cxx.
int matching_files | ( | std::string | relative_path, | |
std::list< std::string > * | output | |||
) | const |
Find all files in the etags database that 'match' the specified relative path.
If the relatative path is actually an absolute path, the returned list will contain exactly 1 element -- the input path -- regardless of whether or not it is in the etags database.
If the relative_path is a single file basename, or a subdirectory path, such as "dir/dir/file", then all pathnames in the etags database ending in "/" followed by the relative path will be returned. Acount of matchines will be returned.
Note: if the relative_path is empty string, then all files in the etags database will be returned
Definition at line 327 of file etagsdb.cxx.
bool ok | ( | ) | const |
int searchFor | ( | std::string const & | symbol, | |
std::string * | foundFile, | |||
int * | foundLine, | |||
std::string * | sourceText | |||
) | [private] |
This helper function actually scans the TAGS file.
symbol | defines the string to be searched for starting at the current position in the TAGS database file. | |
foundFile | points to a variable which will be populated with the name of the file that defines the specified symbol. | |
foundLine | points to a variable that will be updated with the line number within the foundFile where the symbol is defined. | |
sourceText | points to a string variable that will be updated the text of the line that defines the symbol. |
Definition at line 97 of file etagsdb.cxx.
bool set_tags_file | ( | std::string | tagsfile | ) |
Change the name of the tags database file -- closing the current one and opening a new one. The function returns true if error.
Definition at line 311 of file etagsdb.cxx.
bool case_sensitive_ [private] |
FILE* file_ [private] |
char most_recent_file_[2048] [private] |