Skip to main content

The Htags Struct Reference

This class is a namespace for HTAGS related functions. More...

Declaration

struct Htags { ... }

Included Headers

#include <src/htags.h>

Public Static Functions Index

static boolloadFilemap (const QCString &htmldir)
static QCStringpath2URL (const QCString &path)
static boolexecute (const QCString &htmldir)

Public Static Attributes Index

static booluseHtags = FALSE

Description

This class is a namespace for HTAGS related functions.

Definition at line 21 of file htags.h.

Public Static Functions

execute()

bool Htags::execute (const QCString & htmldir)
static

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

Return Values
TRUE

success

FALSE

an error has occurred.

Declaration at line 26 of file htags.h, definition at line 38 of file htags.cpp.

38bool Htags::execute(const QCString &htmldir)
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 {}. "
56 "Check the value of the INPUT tag in the configuration file.\n",
57 inputSource.back()
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));
92 bool result=Portable::system("htags",commandLine,FALSE)==0;
93 if (!result)
94 {
95 err("Problems running htags. Check your installation\n");
96 }
97 Dir::setCurrent(oldDir);
98 return result;
99}

References Config_getBool, Config_getList, Config_getString, Dir::currentDirPath, err, FALSE, g_inputDir, QCString::isEmpty, Dir::setCurrent and Portable::system.

Referenced by generateOutput.

loadFilemap()

bool Htags::loadFilemap (const QCString & htmlDir)
static

load filemap and make index.

Parameters
htmlDir

of HTML directory generated by htags(1).

Return Values
TRUE

success

FALSE

error

Declaration at line 24 of file htags.h, definition at line 107 of file htags.cpp.

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

References err, FileInfo::exists, QCString::find, QCString::findRev, g_symbolMap, FileInfo::isReadable, QCString::left, QCString::mid, Portable::openInputStream, QCString::str and QCString::stripWhiteSpace.

Referenced by generateOutput.

path2URL()

QCString Htags::path2URL (const QCString & path)
static

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

Parameters
path

path name

Returns

URL nullptr: not found.

Declaration at line 25 of file htags.h, definition at line 157 of file htags.cpp.

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

References g_inputDir, g_symbolMap, QCString::isEmpty, QCString::length, QCString::mid and QCString::str.

Referenced by FileDefImpl::getSourceFileBase.

Public Static Attributes

useHtags

bool Htags::useHtags = FALSE
static

The documentation for this struct was generated from the following files:


Generated via doxygen2docusaurus by Doxygen 1.14.0.