Skip to main content

The HtmlHelpIndex Class Reference

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

Declaration

class HtmlHelpIndex { ... }

Public Constructors Index

HtmlHelpIndex (HtmlHelpRecoder &recoder)

Public Destructor Index

~HtmlHelpIndex ()

Public Member Functions Index

voidaddItem (const QCString &first, const QCString &second, const QCString &url, const QCString &anchor, bool hasLink, bool reversed)
voidwriteFields (std::ostream &t)
size_tsize () const

Private Member Attributes Index

LinkedMap< IndexField >m_map
HtmlHelpRecoder &m_recoder

Description

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

Definition at line 113 of file htmlhelp.cpp.

Public Constructors

HtmlHelpIndex()

HtmlHelpIndex::HtmlHelpIndex (HtmlHelpRecoder & recoder)

Constructs a new HtmlHelp index

Definition at line 116 of file htmlhelp.cpp.

Reference m_recoder.

Referenced by ~HtmlHelpIndex.

Public Destructor

~HtmlHelpIndex()

HtmlHelpIndex::~HtmlHelpIndex ()

Destroys the HtmlHelp index

Definition at line 117 of file htmlhelp.cpp.

Reference HtmlHelpIndex.

Public Member Functions

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).

Parameters
level1

the string at level 1 in the index.

level2

the string at level 2 in the index (or 0 if not applicable).

url

the url of the documentation (without .html extension).

anchor

the anchor of the documentation within the page.

hasLink

if true, the url (without anchor) can be used in the level1 item, when writing the header of a list of level2 items.

reversed

TRUE if level1 is the member name and level2 the compound name.

Definition at line 119 of file htmlhelp.cpp.

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

References QCString::isEmpty, m_map, reg::search, QCString::str and substitute.

size()

size_t HtmlHelpIndex::size ()
inline

Definition at line 123 of file htmlhelp.cpp.

123 size_t size() const { return m_map.size(); }

Reference m_map.

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

Definition at line 122 of file htmlhelp.cpp.

238void HtmlHelpIndex::writeFields(std::ostream &t)
239{
240 std::stable_sort(std::begin(m_map),
241 std::end(m_map),
242 [](const auto &e1,const auto &e2) { return qstricmp_sort(e1->name,e2->name)<0; }
243 );
244 QCString prevLevel1;
245 bool level2Started=FALSE;
246 for (auto it = std::begin(m_map); it!=std::end(m_map); ++it)
247 {
248 auto &f = *it;
249 QCString level1,level2;
250 int i = f->name.find('?');
251 if (i!=-1)
252 {
253 level1 = f->name.left(i);
254 level2 = f->name.right(f->name.length()-i-1);
255 }
256 else
257 {
258 level1 = f->name;
259 }
260
261 { // finish old list at level 2
262 if (level2Started) t << " </UL>\n";
263 level2Started=FALSE;
264
265 // <Antony>
266 // Added this code so that an item with only one subitem is written
267 // without any subitem.
268 // For example:
269 // a1, b1 -> will create only a1, not separate subitem for b1
270 // a2, b2
271 // a2, b3
272 QCString nextLevel1;
273 auto it_next = std::next(it);
274 if (it_next!=std::end(m_map))
275 {
276 auto &fnext = *it_next;
277 int j = fnext->name.find('?');
278 if (j<0) j=0;
279 nextLevel1 = fnext->name.left(j);
280 }
281 if (!(level1 == prevLevel1 || level1 == nextLevel1))
282 {
283 level2 = "";
284 }
285 prevLevel1 = level1;
286 // </Antony>
287
288 if (level2.isEmpty())
289 {
290 t << " <LI><OBJECT type=\"text/sitemap\">";
291 t << "<param name=\"Local\" value=\"" << field2URL(f.get(),FALSE);
292 t << "\">";
293 t << "<param name=\"Name\" value=\"" << convertToHtmlAndTruncate(m_recoder.recode(level1)) << "\">"
294 "</OBJECT>\n";
295 }
296 else
297 {
298 if (f->link)
299 {
300 t << " <LI><OBJECT type=\"text/sitemap\">";
301 t << "<param name=\"Local\" value=\"" << field2URL(f.get(),TRUE);
302 t << "\">";
303 t << "<param name=\"Name\" value=\"" << convertToHtmlAndTruncate(m_recoder.recode(level1)) << "\">"
304 "</OBJECT>\n";
305 }
306 else
307 {
308 t << " <LI><OBJECT type=\"text/sitemap\">";
309 t << "<param name=\"See Also\" value=\"" << convertToHtml(m_recoder.recode(level1)) << "\">";
310 t << "<param name=\"Name\" value=\"" << convertToHtmlAndTruncate(m_recoder.recode(level1)) << "\">"
311 "</OBJECT>\n";
312 }
313 }
314 }
315 if (!level2Started && !level2.isEmpty())
316 { // start new list at level 2
317 t << " <UL>\n";
318 level2Started=TRUE;
319 }
320 else if (level2Started && level2.isEmpty())
321 { // end list at level 2
322 t << " </UL>\n";
323 level2Started=FALSE;
324 }
325 if (level2Started)
326 {
327 t << " <LI><OBJECT type=\"text/sitemap\">";
328 t << "<param name=\"Local\" value=\"" << field2URL(f.get(),FALSE);
329 t << "\">";
330 t << "<param name=\"Name\" value=\"" << convertToHtmlAndTruncate(m_recoder.recode(level2)) << "\">"
331 "</OBJECT>\n";
332 }
333 }
334 if (level2Started) t << " </UL>\n";
335}

References convertToHtml, convertToHtmlAndTruncate, FALSE, field2URL, QCString::find, QCString::isEmpty, QCString::left, m_map, m_recoder, qstricmp_sort, QCString::right and TRUE.

Private Member Attributes

m_map

LinkedMap<IndexField> HtmlHelpIndex::m_map

Definition at line 125 of file htmlhelp.cpp.

Referenced by addItem, size and writeFields.

m_recoder

HtmlHelpRecoder& HtmlHelpIndex::m_recoder

Definition at line 126 of file htmlhelp.cpp.

Referenced by HtmlHelpIndex and writeFields.


The documentation for this class was generated from the following file:


Generated via doxygen2docusaurus by Doxygen 1.14.0.