EtagsDB Class Reference

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>

Collaboration diagram for EtagsDB:
Collaboration graph
[legend]

List of all members.

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.
EtagsDBoperator= (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

Detailed Description

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.


Constructor & Destructor Documentation

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.

EtagsDB ( EtagsDB const &   )  [private]

Copy constructor is private.


Member Function Documentation

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.

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Here is the caller graph for this function:

bool ok (  )  const

Definition at line 60 of file etagsdb.h.

Here is the caller graph for this function:

EtagsDB& operator= ( EtagsDB const &   )  [private]

Assignment operator is private.

int searchFor ( std::string const &  symbol,
std::string *  foundFile,
int *  foundLine,
std::string *  sourceText 
) [private]

This helper function actually scans the TAGS file.

Returns:
an integer containing one of the following:
  • 0 didn't find the symbol but not end of file
  • 1 did find the symbol
  • 2 didn't find the symbol and end of file occurred And 3 pointers to variables to hold additional return data
Parameters:
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.

Here is the caller graph for this function:

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.

Here is the caller graph for this function:


Member Data Documentation

bool case_sensitive_ [private]

Definition at line 121 of file etagsdb.h.

FILE* file_ [private]

when file_ is 0, then the filename was bad

Definition at line 49 of file etagsdb.h.

std::string filename_ [private]

name of etags file

Definition at line 50 of file etagsdb.h.

char most_recent_file_[2048] [private]

used in parsing

Definition at line 127 of file etagsdb.h.

std::string symbol_ [private]

name of symbol to find

Definition at line 51 of file etagsdb.h.


The documentation for this class was generated from the following files:
Generated on Wed Feb 29 22:54:39 2012 for CXXUtilities by  doxygen 1.6.3