Doxygen
HtmlHelpIndex类 参考

A helper class for HtmlHelp that manages a two level index in alphabetical order. 更多...

+ HtmlHelpIndex 的协作图:

Public 成员函数

 HtmlHelpIndex (HtmlHelpRecoder &recoder)
 
 ~HtmlHelpIndex ()
 
void addItem (const QCString &first, const QCString &second, const QCString &url, const QCString &anchor, bool hasLink, bool reversed)
 
void writeFields (std::ostream &t)
 
size_t size () const
 

Private 属性

LinkedMap< IndexFieldm_map
 
HtmlHelpRecoderm_recoder
 

详细描述

A helper class for HtmlHelp that manages a two level index in alphabetical order.

在文件 htmlhelp.cpp114 行定义.

构造及析构函数说明

◆ HtmlHelpIndex()

HtmlHelpIndex::HtmlHelpIndex ( HtmlHelpRecoder recoder)

Constructs a new HtmlHelp index

在文件 htmlhelp.cpp130 行定义.

130  : m_recoder(recoder)
131 {
132 }

◆ ~HtmlHelpIndex()

HtmlHelpIndex::~HtmlHelpIndex ( )

Destroys the HtmlHelp index

在文件 htmlhelp.cpp135 行定义.

136 {
137 }

成员函数说明

◆ addItem()

void HtmlHelpIndex::addItem ( const QCString level1,
const QCString level2,
const QCString url,
const QCString anchor,
bool  hasLink,
bool  reversed 
)

Stores an item in the index if it is not already present. Items are stored in alphabetical order, by sorting on the concatenation of level1 and level2 (if present).

参数
level1the string at level 1 in the index.
level2the string at level 2 in the index (or 0 if not applicable).
urlthe url of the documentation (without .html extension).
anchorthe anchor of the documentation within the page.
hasLinkif true, the url (without anchor) can be used in the level1 item, when writing the header of a list of level2 items.
reversedTRUE if level1 is the member name and level2 the compound name.

在文件 htmlhelp.cpp152 行定义.

155 {
156  static const reg::Ex re(R"(@\d+)");
157  std::string key = level1.str();
158  if (!level2.isEmpty()) key+= std::string("?") + level2.str();
159  if (reg::search(key,re)) // skip anonymous stuff
160  {
161  return;
162  }
163  std::string key_anchor;
164  if (!anchor.isEmpty())
165  {
166  key_anchor = key+anchor.str();
167  }
168  else
169  {
170  key_anchor = key;
171  }
172  m_map.add(key_anchor.c_str(),key.c_str(),url,anchor,hasLink,reversed);
173 }

引用了 LinkedMap< T, Hash, KeyEqual, Map >::add(), QCString::isEmpty(), m_map, reg::search() , 以及 QCString::str().

◆ size()

size_t HtmlHelpIndex::size ( ) const
inline

在文件 htmlhelp.cpp123 行定义.

123 { return m_map.size(); }

引用了 m_map , 以及 LinkedMap< T, Hash, KeyEqual, Map >::size().

被这些函数引用 HtmlHelp::Private::createProjectFile().

◆ writeFields()

void HtmlHelpIndex::writeFields ( std::ostream &  t)

Writes the sorted list of index items into a html like list.

An list of calls with name = level1,level2 as follows:

  a1,b1
  a1,b2
  a2,b1
  a2,b2
  a3
  a4,b1

Will result in the following list:

  a1       -> link to url if hasLink==TRUE
    b1     -> link to url::anchor
    b2     -> link to url::anchor
  a2       -> link to url if hasLink==TRUE
    b1     -> link to url::anchor
    b2     -> link to url::anchor
  a3       -> link to url if hasLink==TRUE
  a4       -> link to url if hasLink==TRUE
    b1     -> link to url::anchor

在文件 htmlhelp.cpp212 行定义.

213 {
214  std::sort(std::begin(m_map),
215  std::end(m_map),
216  [](const auto &e1,const auto &e2) { return e1->name < e2->name; }
217  );
218  QCString prevLevel1;
219  bool level2Started=FALSE;
220  for (auto it = std::begin(m_map); it!=std::end(m_map); ++it)
221  {
222  auto &f = *it;
223  QCString level1,level2;
224  int i;
225  if ((i=f->name.find('?'))!=-1)
226  {
227  level1 = f->name.left(i);
228  level2 = f->name.right(f->name.length()-i-1);
229  }
230  else
231  {
232  level1 = f->name;
233  }
234 
235  { // finish old list at level 2
236  if (level2Started) t << " </UL>\n";
237  level2Started=FALSE;
238 
239  // <Antony>
240  // Added this code so that an item with only one subitem is written
241  // without any subitem.
242  // For example:
243  // a1, b1 -> will create only a1, not separate subitem for b1
244  // a2, b2
245  // a2, b3
246  QCString nextLevel1;
247  auto it_next = std::next(it);
248  if (it_next!=std::end(m_map))
249  {
250  auto &fnext = *it_next;
251  int j = fnext->name.find('?');
252  if (j<0) j=0;
253  nextLevel1 = fnext->name.left(j);
254  }
255  if (!(level1 == prevLevel1 || level1 == nextLevel1))
256  {
257  level2 = "";
258  }
259  prevLevel1 = level1;
260  // </Antony>
261 
262  if (level2.isEmpty())
263  {
264  t << " <LI><OBJECT type=\"text/sitemap\">";
265  t << "<param name=\"Local\" value=\"" << field2URL(f.get(),FALSE);
266  t << "\">";
267  t << "<param name=\"Name\" value=\"" << convertToHtml(m_recoder.recode(level1),TRUE) << "\">"
268  "</OBJECT>\n";
269  }
270  else
271  {
272  if (f->link)
273  {
274  t << " <LI><OBJECT type=\"text/sitemap\">";
275  t << "<param name=\"Local\" value=\"" << field2URL(f.get(),TRUE);
276  t << "\">";
277  t << "<param name=\"Name\" value=\"" << convertToHtml(m_recoder.recode(level1),TRUE) << "\">"
278  "</OBJECT>\n";
279  }
280  else
281  {
282  t << " <LI><OBJECT type=\"text/sitemap\">";
283  t << "<param name=\"See Also\" value=\"" << convertToHtml(m_recoder.recode(level1),TRUE) << "\">";
284  t << "<param name=\"Name\" value=\"" << convertToHtml(m_recoder.recode(level1),TRUE) << "\">"
285  "</OBJECT>\n";
286  }
287  }
288  }
289  if (!level2Started && !level2.isEmpty())
290  { // start new list at level 2
291  t << " <UL>\n";
292  level2Started=TRUE;
293  }
294  else if (level2Started && level2.isEmpty())
295  { // end list at level 2
296  t << " </UL>\n";
297  level2Started=FALSE;
298  }
299  if (level2Started)
300  {
301  t << " <LI><OBJECT type=\"text/sitemap\">";
302  t << "<param name=\"Local\" value=\"" << field2URL(f.get(),FALSE);
303  t << "\">";
304  t << "<param name=\"Name\" value=\"" << convertToHtml(m_recoder.recode(level2),TRUE) << "\">"
305  "</OBJECT>\n";
306  }
307  }
308  if (level2Started) t << " </UL>\n";
309 }

引用了 begin(), convertToHtml(), end(), FALSE, field2URL(), QCString::isEmpty(), QCString::left(), m_map, m_recoder, HtmlHelpRecoder::recode(), QCString::right() , 以及 TRUE.

类成员变量说明

◆ m_map

LinkedMap<IndexField> HtmlHelpIndex::m_map
private

在文件 htmlhelp.cpp125 行定义.

被这些函数引用 addItem(), size() , 以及 writeFields().

◆ m_recoder

HtmlHelpRecoder& HtmlHelpIndex::m_recoder
private

在文件 htmlhelp.cpp126 行定义.

被这些函数引用 writeFields().


该类的文档由以下文件生成:
HtmlHelpRecoder::recode
QCString recode(const QCString &s)
Definition: htmlhelp.cpp:84
QCString::isEmpty
bool isEmpty() const
Returns TRUE iff the string is empty
Definition: qcstring.h:144
LinkedMap::add
T * add(const char *k, Args &&... args)
Adds a new object to the ordered vector if it was not added already.
Definition: linkedmap.h:103
QCString::str
std::string str() const
Definition: qcstring.h:442
field2URL
static QCString field2URL(const IndexField *f, bool checkReversed)
Definition: htmlhelp.cpp:175
begin
DirIterator begin(DirIterator it) noexcept
Definition: dir.cpp:123
end
DirIterator end(const DirIterator &) noexcept
Definition: dir.cpp:128
QCString::left
QCString left(size_t len) const
Definition: qcstring.h:212
TRUE
#define TRUE
Definition: qcstring.h:36
HtmlHelpIndex::m_map
LinkedMap< IndexField > m_map
Definition: htmlhelp.cpp:125
reg::Ex
Class representing a regular expression.
Definition: regex.h:48
HtmlHelpIndex::m_recoder
HtmlHelpRecoder & m_recoder
Definition: htmlhelp.cpp:126
reg::search
bool search(const std::string &str, Match &match, const Ex &re, size_t pos)
Search in a given string str starting at position pos for a match against regular expression re.
Definition: regex.cpp:718
QCString::right
QCString right(size_t len) const
Definition: qcstring.h:217
convertToHtml
QCString convertToHtml(const QCString &s, bool keepEntities)
Definition: util.cpp:4063
FALSE
#define FALSE
Definition: qcstring.h:33
LinkedMap::size
size_t size() const
Definition: linkedmap.h:223
QCString
This is an alternative implementation of QCString.
Definition: qcstring.h:108