Static Public Member Functions | Static Public Attributes | List of all members
Htags Struct Reference

#include <htags.h>

Static Public Member Functions

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

Static Public Attributes

static bool useHtags = FALSE
 

Detailed Description

This class is a namespace for HTAGS related functions

Definition at line 21 of file htags.h.

Member Function Documentation

bool Htags::execute ( const QCString htmldir)
static

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

Return values
TRUEsuccess
FALSEan error has occurred.

Definition at line 37 of file htags.cpp.

38 {
39  static QStrList &inputSource = Config_getList("INPUT");
40  static bool quiet = Config_getBool("QUIET");
41  static bool warnings = Config_getBool("WARNINGS");
42  static QCString htagsOptions = ""; //Config_getString("HTAGS_OPTIONS");
43  static QCString projectName = Config_getString("PROJECT_NAME");
44  static QCString projectNumber = Config_getString("PROJECT_NUMBER");
45 
47  if (inputSource.isEmpty())
48  {
49  g_inputDir.setPath(cwd);
50  }
51  else if (inputSource.count()==1)
52  {
53  g_inputDir.setPath(inputSource.first());
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.first()
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  QCString oldDir = QDir::currentDirPath().utf8();
91  //printf("CommandLine=[%s]\n",commandLine.data());
93  bool result=portable_system("htags",commandLine,FALSE)==0;
95  QDir::setCurrent(oldDir);
96  return result;
97 }
void portable_sysTimerStop()
Definition: portable.cpp:415
static QCString result
bool isEmpty() const
Definition: qcstring.h:189
virtual void setPath(const QString &path)
Definition: qdir.cpp:248
type * first()
Definition: qinternallist.h:87
const bool FALSE
Definition: qglobal.h:370
#define Config_getList(val)
Definition: config.cpp:662
virtual QString absPath() const
Definition: qdir.cpp:276
static QDir g_inputDir
Definition: htags.cpp:30
void portable_sysTimerStart()
Definition: portable.cpp:410
static QString currentDirPath()
Definition: qdir_unix.cpp:141
#define Config_getString(val)
Definition: config.cpp:660
#define Config_getBool(val)
Definition: config.cpp:664
void err(const char *fmt,...)
Definition: message.cpp:226
bool isEmpty() const
Definition: qinternallist.h:57
uint count() const
Definition: qinternallist.h:56
QCString utf8() const
Definition: qstring.cpp:14507
virtual bool exists() const
Definition: qdir.cpp:820
static bool setCurrent(const QString &path)
Definition: qdir_unix.cpp:134
int portable_system(const char *command, const char *args, bool commandHasConsole)
Definition: portable.cpp:33
bool Htags::loadFilemap ( const QCString htmlDir)
static

load filemap and make index.

Parameters
htmlDirof HTML directory generated by htags(1).
Return values
TRUEsuccess
FALSEerror

Definition at line 105 of file htags.cpp.

106 {
107  QCString fileMapName = htmlDir+"/HTML/FILEMAP";
108  QFileInfo fi(fileMapName);
109  /*
110  * Construct FILEMAP dictionary using QDict.
111  *
112  * In FILEMAP, URL includes 'html' suffix but we cut it off according
113  * to the method of FileDef class.
114  *
115  * FILEMAP format:
116  * <NAME>\t<HREF>.html\n
117  * QDICT:
118  * dict[<NAME>] = <HREF>
119  */
120  if (fi.exists() && fi.isReadable())
121  {
122  QFile f(fileMapName);
123  const int maxlen = 8192;
124  QCString line(maxlen+1);
125  line.at(maxlen)='\0';
126  if (f.open(IO_ReadOnly))
127  {
128  int len;
129  while ((len=f.readLine(line.rawData(),maxlen))>0)
130  {
131  line.resize(len+1);
132  //printf("Read line: %s",line.data());
133  int sep = line.find('\t');
134  if (sep!=-1)
135  {
136  QCString key = line.left(sep).stripWhiteSpace();
137  QCString value = line.mid(sep+1).stripWhiteSpace();
138  int ext=value.findRev('.');
139  if (ext!=-1) value=value.left(ext); // strip extension
140  g_symbolDict.setAutoDelete(TRUE);
141  g_symbolDict.insert(key,new QCString(value));
142  //printf("Key/Value=(%s,%s)\n",key.data(),value.data());
143  }
144  }
145  return TRUE;
146  }
147  else
148  {
149  err("file %s cannot be opened\n",fileMapName.data());
150  }
151  }
152  return FALSE;
153 }
static const int maxlen
Definition: qregexp.cpp:904
const bool FALSE
Definition: qglobal.h:370
QCString left(uint len) const
Definition: qcstring.cpp:213
int findRev(char c, int index=-1, bool cs=TRUE) const
Definition: qcstring.cpp:95
#define IO_ReadOnly
Definition: qiodevice.h:61
static QDict< QCString > g_symbolDict(10007)
def key(type, name=None)
Definition: graph.py:13
const char * data() const
Definition: qcstring.h:207
void err(const char *fmt,...)
Definition: message.cpp:226
The QFile class is an I/O device that operates on files.
Definition: qfile.h:50
void line(double t, double *p, double &x, double &y, double &z)
The QFileInfo class provides system-independent file information.
Definition: qfileinfo.h:51
const bool TRUE
Definition: qglobal.h:371
QCString Htags::path2URL ( const QCString path)
static

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

Parameters
pathpath name
Returns
URL NULL: not found.

Definition at line 159 of file htags.cpp.

160 {
161  QCString url,symName=path;
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  QCString *result = g_symbolDict[symName];
171  //printf("path2URL=%s symName=%s result=%p\n",path.data(),symName.data(),result);
172  if (result)
173  {
174  url = "HTML/" + *result;
175  }
176  }
177  return url;
178 }
static QCString result
bool isEmpty() const
Definition: qcstring.h:189
uint length() const
Definition: qcstring.h:195
string dir
virtual QString absPath() const
Definition: qdir.cpp:276
static QDir g_inputDir
Definition: htags.cpp:30
static QDict< QCString > g_symbolDict(10007)
QCString mid(uint index, uint len=0xffffffff) const
Definition: qcstring.cpp:246
QCString utf8() const
Definition: qstring.cpp:14507

Member Data Documentation

bool Htags::useHtags = FALSE
static

Definition at line 23 of file htags.h.


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