Doxygen
Htags结构体 参考

This class is a namespace for HTAGS related functions 更多...

#include <htags.h>

静态 Public 成员函数

static bool loadFilemap (const QCString &htmldir)
 
static QCString path2URL (const QCString &path)
 
static bool execute (const QCString &htmldir)
 

静态 Public 属性

static bool useHtags = FALSE
 

详细描述

This class is a namespace for HTAGS related functions

在文件 htags.h21 行定义.

成员函数说明

◆ execute()

bool Htags::execute ( const QCString htmldir)
static

constructs command line of htags(1) and executes it.

返回值
TRUEsuccess
FALSEan error has occurred.

在文件 htags.cpp38 行定义.

39 {
40  const StringVector &inputSource = Config_getList(INPUT);
41  bool quiet = Config_getBool(QUIET);
42  bool warnings = Config_getBool(WARNINGS);
43  QCString htagsOptions = ""; //Config_getString(HTAGS_OPTIONS);
44  QCString projectName = Config_getString(PROJECT_NAME);
45  QCString projectNumber = Config_getString(PROJECT_NUMBER);
46 
47  if (inputSource.empty())
48  {
50  }
51  else if (inputSource.size()==1)
52  {
53  g_inputDir.setPath(inputSource.back());
54  if (!g_inputDir.exists())
55  err("Cannot find directory %s. "
56  "Check the value of the INPUT tag in the configuration file.\n",
57  inputSource.back().c_str()
58  );
59  }
60  else
61  {
62  err("If you use USE_HTAGS then INPUT should specify a single directory.\n");
63  return FALSE;
64  }
65 
66  /*
67  * Construct command line for htags(1).
68  */
69  QCString commandLine = " -g -s -a -n ";
70  if (!quiet) commandLine += "-v ";
71  if (warnings) commandLine += "-w ";
72  if (!htagsOptions.isEmpty())
73  {
74  commandLine += ' ';
75  commandLine += htagsOptions;
76  }
77  if (!projectName.isEmpty())
78  {
79  commandLine += "-t \"";
80  commandLine += projectName;
81  if (!projectNumber.isEmpty())
82  {
83  commandLine += '-';
84  commandLine += projectNumber;
85  }
86  commandLine += "\" ";
87  }
88  commandLine += " \"" + htmldir + "\"";
89  std::string oldDir = Dir::currentDirPath();
91  //printf("CommandLine=[%s]\n",qPrint(commandLine));
93  bool result=Portable::system("htags",commandLine,FALSE)==0;
94  if (!result)
95  {
96  err("Problems running %s. Check your installation\n", "htags");
97  }
99  Dir::setCurrent(oldDir);
100  return result;
101 }

引用了 Dir::absPath(), Config_getBool, Config_getList, Config_getString, Dir::currentDirPath(), err(), Dir::exists(), FALSE, g_inputDir, QCString::isEmpty(), Dir::setCurrent(), Dir::setPath(), Portable::system(), Portable::sysTimerStart() , 以及 Portable::sysTimerStop().

被这些函数引用 generateOutput().

◆ loadFilemap()

bool Htags::loadFilemap ( const QCString htmlDir)
static

load filemap and make index.

参数
htmlDirof HTML directory generated by htags(1).
返回值
TRUEsuccess
FALSEerror

在文件 htags.cpp109 行定义.

110 {
111  QCString fileMapName = htmlDir+"/HTML/FILEMAP";
112  FileInfo fi(fileMapName.str());
113  /*
114  * Construct FILEMAP dictionary.
115  *
116  * In FILEMAP, URL includes 'html' suffix but we cut it off according
117  * to the method of FileDef class.
118  *
119  * FILEMAP format:
120  * <NAME>\t<HREF>.html\n
121  * QDICT:
122  * dict[<NAME>] = <HREF>
123  */
124  if (fi.exists() && fi.isReadable())
125  {
126  std::ifstream f(fileMapName.str(),std::ifstream::in);
127  if (f.is_open())
128  {
129  std::string lineStr;
130  while (getline(f,lineStr))
131  {
132  QCString line(lineStr);
133  //printf("Read line: %s",qPrint(line));
134  int sep = line.find('\t');
135  if (sep!=-1)
136  {
137  QCString key = line.left(sep).stripWhiteSpace();
138  QCString value = line.mid(sep+1).stripWhiteSpace();
139  int ext=value.findRev('.');
140  if (ext!=-1) value=value.left(ext); // strip extension
141  g_symbolMap.insert(std::make_pair(key.str(),value.str()));
142  //printf("Key/Value=(%s,%s)\n",qPrint(key),qPrint(value));
143  }
144  }
145  return true;
146  }
147  else
148  {
149  err("file %s cannot be opened\n",qPrint(fileMapName));
150  }
151  }
152  return false;
153 }

引用了 err(), FileInfo::exists(), QCString::find(), QCString::findRev(), g_symbolMap, FileInfo::isReadable(), QCString::left(), QCString::mid(), qPrint(), QCString::str() , 以及 QCString::stripWhiteSpace().

被这些函数引用 generateOutput().

◆ path2URL()

QCString Htags::path2URL ( const QCString path)
static

convert path name into the url in the hypertext generated by htags.

参数
pathpath name
返回
URL NULL: not found.

在文件 htags.cpp159 行定义.

160 {
161  QCString url,symName=path;
162  QCString dir = g_inputDir.absPath();
163  int dl=dir.length();
164  if ((int)symName.length()>dl+1)
165  {
166  symName = symName.mid(dl+1);
167  }
168  if (!symName.isEmpty())
169  {
170  auto it = g_symbolMap.find(symName.str());
171  //printf("path2URL=%s symName=%s result=%p\n",qPrint(path),qPrint(symName),result);
172  if (it!=g_symbolMap.end())
173  {
174  url = QCString("HTML/"+it->second);
175  }
176  }
177  return url;
178 }

引用了 Dir::absPath(), g_inputDir, g_symbolMap, QCString::isEmpty(), QCString::length(), QCString::mid() , 以及 QCString::str().

被这些函数引用 FileDefImpl::getSourceFileBase().

类成员变量说明

◆ useHtags

bool Htags::useHtags = FALSE
static

该结构体的文档由以下文件生成:
StringVector
std::vector< std::string > StringVector
Definition: containers.h:32
Dir::currentDirPath
static std::string currentDirPath()
Definition: dir.cpp:282
QCString::length
uint length() const
Returns the length of the string, not counting the 0-terminator.
Definition: qcstring.h:147
g_symbolMap
static std::unordered_map< std::string, std::string > g_symbolMap
Definition: htags.cpp:32
QCString::findRev
int findRev(char c, int index=-1, bool cs=TRUE) const
Definition: qcstring.cpp:86
QCString::isEmpty
bool isEmpty() const
Returns TRUE iff the string is empty
Definition: qcstring.h:144
QCString::str
std::string str() const
Definition: qcstring.h:442
err
void err(const char *fmt,...)
Definition: message.cpp:203
g_inputDir
static Dir g_inputDir
Definition: htags.cpp:31
QCString::stripWhiteSpace
QCString stripWhiteSpace() const
returns a copy of this string with leading and trailing whitespace removed
Definition: qcstring.h:243
QCString::left
QCString left(size_t len) const
Definition: qcstring.h:212
Portable::sysTimerStart
void sysTimerStart()
Definition: portable.cpp:470
Dir::absPath
std::string absPath() const
Definition: dir.cpp:305
Portable::system
int system(const QCString &command, const QCString &args, bool commandHasConsole=true)
Definition: portable.cpp:42
Dir::setCurrent
static bool setCurrent(const std::string &path)
Definition: dir.cpp:290
QCString::mid
QCString mid(size_t index, size_t len=static_cast< size_t >(-1)) const
Definition: qcstring.h:224
Config_getBool
#define Config_getBool(name)
Definition: config.h:33
FileInfo
Minimal replacement for QFileInfo.
Definition: fileinfo.h:22
qPrint
const char * qPrint(const char *s)
Definition: qcstring.h:589
Config_getString
#define Config_getString(name)
Definition: config.h:32
Dir::setPath
void setPath(const std::string &path)
Definition: dir.cpp:171
Portable::sysTimerStop
void sysTimerStop()
Definition: portable.cpp:475
Dir::exists
bool exists() const
Definition: dir.cpp:199
Config_getList
#define Config_getList(name)
Definition: config.h:37
FALSE
#define FALSE
Definition: qcstring.h:33
QCString
This is an alternative implementation of QCString.
Definition: qcstring.h:108