Skip to main content

The Qhp Class Reference

Declaration

class Qhp { ... }

Included Headers

#include <src/qhp.h>

Base class

classIndexIntf

Abstract interface for index generators. More...

Public Constructors Index

Qhp ()

Public Destructor Index

~Qhp ()

Public Member Functions Index

voidinitialize ()
voidfinalize ()
voidincContentsDepth ()
voiddecContentsDepth ()
voidaddContentsItem (bool isDir, const QCString &name, const QCString &ref, const QCString &file, const QCString &anchor, bool separateIndex, bool addToNavIndex, const Definition *def, const QCString &)
voidaddIndexItem (const Definition *context, const MemberDef *md, const QCString &sectionAnchor, const QCString &title)
voidaddIndexFile (const QCString &name)
voidaddImageFile (const QCString &name)
voidaddStyleSheetFile (const QCString &name)

Private Member Functions Index

voidaddFile (const QCString &)

Private Member Attributes Index

std::unique_ptr< Private >p

Public Static Functions Index

static QCStringgetQchFileName ()

Public Static Attributes Index

static const QCStringqhpFileName = "index.qhp"

Definition at line 26 of file qhp.h.

Public Constructors

Qhp()

Qhp::Qhp ()

Declaration at line 29 of file qhp.h, definition at line 196 of file qhp.cpp.

196Qhp::Qhp() : p(std::make_unique<Private>()) {}

Reference p.

Referenced by ~Qhp.

Public Destructor

~Qhp()

Qhp::~Qhp ()

Definition at line 30 of file qhp.h.

Reference Qhp.

Public Member Functions

addContentsItem()

void Qhp::addContentsItem (bool isDir, const QCString & name, const QCString & ref, const QCString & file, const QCString & anchor, bool separateIndex, bool addToNavIndex, const Definition * def, const QCString &)
virtual

Declaration at line 37 of file qhp.h, definition at line 314 of file qhp.cpp.

314void Qhp::addContentsItem(bool /* isDir */, const QCString & name, const QCString & /*ref*/,
315 const QCString & file, const QCString &anchor, bool /* separateIndex */,
316 bool /* addToNavIndex */, const Definition * /*def*/, const QCString & /*nameAsHtml*/)
317{
318 /*
319 <toc>
320 <section title="My Application Manual" ref="index.html">
321 <section title="Chapter 1" ref="doc.html#chapter1"/>
322 <section title="Chapter 2" ref="doc.html#chapter2"/>
323 <section title="Chapter 3" ref="doc.html#chapter3"/>
324 </section>
325 </toc>
326 */
327
328 QCString f = file;
329 if (!f.isEmpty() && f.at(0)=='^') return; // absolute URL not supported
330
331 if (f.isEmpty())
332 {
333 f = "doxygen_blank";
335 std::call_once(g_blankWritten,[this,&f]()
336 {
337 QCString fileName = Config_getString(HTML_OUTPUT) + "/" + f;
338 std::ofstream blankFile = Portable::openOutputStream(fileName); // we just need an empty file
339 if (!blankFile.is_open())
340 {
341 term("Could not open file {} for writing\n",fileName);
342 }
343 TextStream blank;
344 blank.setStream(&blankFile);
345 blank << "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1 Transitional//EN\" \"https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
346 blank << "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"" + theTranslator->trISOLang() + "\">\n";
347 blank << "<head>\n";
348 blank << "<title>Validator / crawler helper</title>\n";
349 blank << "<meta http-equiv=\"Content-Type\" content=\"text/xhtml;charset=UTF-8\"/>\n";
350 blank << "<meta http-equiv=\"X-UA-Compatible\" content=\"IE=11\"/>\n";
351
352 blank << "<meta name=\"generator\" content=\"Doxygen " + getDoxygenVersion() + "\"/>\n";
353 blank << "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"/>\n";
354 blank << "</head>\n";
355 blank << "<body>\n";
356 blank << "</body>\n";
357 blank << "</html>\n";
358 blank.flush();
359 blankFile.close();
360 addFile(f);
361 });
362 }
363 QCString finalRef = makeRef(f, anchor);
364 p->sectionTree.addSection(name,finalRef);
365}

References addFile, addHtmlExtensionIfMissing, QCString::at, Config_getString, TextStream::flush, g_blankWritten, QCString::isEmpty, makeRef, Portable::openOutputStream, p, TextStream::setStream, term and theTranslator.

addImageFile()

void Qhp::addImageFile (const QCString & name)
virtual

Declaration at line 44 of file qhp.h, definition at line 416 of file qhp.cpp.

416void Qhp::addImageFile(const QCString &fileName)
417{
418 addFile(fileName);
419}

Reference addFile.

addIndexFile()

void Qhp::addIndexFile (const QCString & name)
virtual

Declaration at line 43 of file qhp.h, definition at line 411 of file qhp.cpp.

411void Qhp::addIndexFile(const QCString & fileName)
412{
413 addFile(fileName);
414}

Reference addFile.

addIndexItem()

void Qhp::addIndexItem (const Definition * context, const MemberDef * md, const QCString & sectionAnchor, const QCString & title)
virtual

Declaration at line 41 of file qhp.h, definition at line 367 of file qhp.cpp.

367void Qhp::addIndexItem(const Definition *context,const MemberDef *md,
368 const QCString &sectionAnchor,const QCString &word)
369{
370 (void)word;
371 //printf("addIndexItem(%s %s %s\n",
372 // context?context->name().data():"<none>",
373 // md?md->name().data():"<none>",
374 // qPrint(word));
375
376 if (context && md) // member
377 {
378 QCString cfname = md->getOutputFileBase();
379 QCString argStr = md->argsString();
380 QCString level1 = context->name();
381 QCString level2 = !word.isEmpty() ? word : md->name();
382 QCString anchor = !sectionAnchor.isEmpty() ? sectionAnchor : md->anchor();
383 QCString ref;
384
385 // <keyword name="foo" id="MyApplication::foo" ref="doc.html#foo"/>
386 ref = makeRef(cfname, anchor);
387 QCString id = level1+"::"+level2;
388 writeIndent(p->index,3);
389 p->index << "<keyword name=\"" << convertToXML(level2 + argStr) << "\""
390 " id=\"" << convertToXML(id + "_" + anchor) << "\""
391 " ref=\"" << convertToXML(ref) << "\"/>\n";
392 }
393 else if (context) // container
394 {
395 // <keyword name="Foo" id="Foo" ref="doc.html#Foo"/>
396 QCString contRef = context->getOutputFileBase();
397 QCString level1 = !word.isEmpty() ? word : context->name();
398 QCString ref = makeRef(contRef,sectionAnchor);
399 writeIndent(p->index,3);
400 p->index << "<keyword name=\"" << convertToXML(level1) << "\""
401 << " id=\"" << convertToXML(level1 +"_" + sectionAnchor) << "\""
402 << " ref=\"" << convertToXML(ref) << "\"/>\n";
403 }
404}

References Definition::anchor, MemberDef::argsString, convertToXML, Definition::getOutputFileBase, QCString::isEmpty, makeRef, Definition::name, p and writeIndent.

addStyleSheetFile()

void Qhp::addStyleSheetFile (const QCString & name)
virtual

Declaration at line 45 of file qhp.h, definition at line 421 of file qhp.cpp.

421void Qhp::addStyleSheetFile(const QCString &fileName)
422{
423 addFile(fileName);
424}

Reference addFile.

decContentsDepth()

void Qhp::decContentsDepth ()
virtual

Declaration at line 36 of file qhp.h, definition at line 309 of file qhp.cpp.

310{
311 p->sectionTree.decLevel();
312}

Reference p.

finalize()

void Qhp::finalize ()
virtual

Declaration at line 34 of file qhp.h, definition at line 272 of file qhp.cpp.

273{
274 // close root node
275 p->sectionTree.decLevel();
276
277 // Finish TOC
278 p->sectionTree.writeToc(p->doc);
279
280 // Finish index
281 writeIndent(p->index,2);
282 p->index << "</keywords>\n";
283 p->doc << p->index.str();
284
285 // Finish files
286 writeIndent(p->doc,2);
287 p->doc << "<files>\n";
288 for (auto &s : p->files)
289 {
290 writeIndent(p->doc,3);
291 p->doc << s.c_str() << "\n";
292 }
293 writeIndent(p->doc,2);
294 p->doc << "</files>\n";
295
296 writeIndent(p->doc,1);
297 p->doc << "</filterSection>\n";
298 p->doc << "</QtHelpProject>\n";
299
300 p->doc.flush();
301 p->docFile.close();
302}

References p and writeIndent.

incContentsDepth()

void Qhp::incContentsDepth ()
virtual

Declaration at line 35 of file qhp.h, definition at line 304 of file qhp.cpp.

305{
306 p->sectionTree.incLevel();
307}

Reference p.

initialize()

void Qhp::initialize ()
virtual

Declaration at line 33 of file qhp.h, definition at line 199 of file qhp.cpp.

200{
201 /*
202 <QtHelpProject version="1.0">
203 <namespace>mycompany.com.myapplication.1_0</namespace>
204 <virtualFolder>doc</virtualFolder>
205 <customFilter name="My Application 1.0">
206 <filterAttribute>myapp</filterAttribute>
207 <filterAttribute>1.0</filterAttribute>
208 </customFilter>
209 <filterSection>
210 <filterAttribute>myapp</filterAttribute>
211 <filterAttribute>1.0</filterAttribute>
212 ..
213 */
214 QCString fileName = Config_getString(HTML_OUTPUT) + "/" + qhpFileName;
215 p->docFile = Portable::openOutputStream(fileName);
216 if (!p->docFile.is_open())
217 {
218 term("Could not open file {} for writing\n",fileName);
219 }
220 p->doc.setStream(&p->docFile);
221
222 p->doc << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
223 p->doc << "<QtHelpProject version=\"1.0\">\n";
224 writeIndent(p->doc,1);
225 p->doc << "<namespace>" << convertToXML(Config_getString(QHP_NAMESPACE)) << "</namespace>\n";
226 writeIndent(p->doc,1);
227 p->doc << "<virtualFolder>" << convertToXML(Config_getString(QHP_VIRTUAL_FOLDER)) << "</virtualFolder>\n";
228
229 // Add custom filter
230 QCString filterName = Config_getString(QHP_CUST_FILTER_NAME);
231 if (!filterName.isEmpty())
232 {
233 writeIndent(p->doc,1);
234 p->doc << "<customFilter name=\"" << convertToXML(filterName) << "\">\n";
235
236 StringVector customFilterAttributes =
237 split(Config_getString(QHP_CUST_FILTER_ATTRS).str(), " ");
238 for (const auto &attr : customFilterAttributes)
239 {
240 writeIndent(p->doc,2);
241 p->doc << "<filterAttribute>" << convertToXML(QCString(attr)) << "</filterAttribute>\n";
242 }
243 writeIndent(p->doc,1);
244 p->doc << "</customFilter>\n";
245 }
246
247 writeIndent(p->doc,1);
248 p->doc << "<filterSection>\n";
249
250 // Add section attributes
251 StringVector sectionFilterAttributes = split(Config_getString(QHP_SECT_FILTER_ATTRS).str(), " ");
252 // always add doxygen as filter attribute
253 if (std::find(sectionFilterAttributes.begin(), sectionFilterAttributes.end(), "doxygen") ==
254 sectionFilterAttributes.end())
255 {
256 sectionFilterAttributes.emplace_back("doxygen");
257 }
258 for (const auto &attr : sectionFilterAttributes)
259 {
260 writeIndent(p->doc,2);
261 p->doc << "<filterAttribute>" << convertToXML(QCString(attr)) << "</filterAttribute>\n";
262 }
263
264 // Add extra root node to the TOC
265 p->sectionTree.addSection(getFullProjectName(),"index"+Doxygen::htmlFileExtension);
266 p->sectionTree.incLevel();
267
268 writeIndent(p->index,2);
269 p->index << "<keywords>\n";
270}

References Config_getString, convertToXML, getFullProjectName, Doxygen::htmlFileExtension, QCString::isEmpty, Portable::openOutputStream, p, qhpFileName, split, term and writeIndent.

Private Member Functions

addFile()

void Qhp::addFile (const QCString & fileName)

Declaration at line 51 of file qhp.h, definition at line 406 of file qhp.cpp.

406void Qhp::addFile(const QCString & fileName)
407{
408 p->files.insert(("<file>" + convertToXML(fileName) + "</file>").str());
409}

References convertToXML and p.

Referenced by addContentsItem, addImageFile, addIndexFile and addStyleSheetFile.

Private Member Attributes

p

std::unique_ptr<Private> Qhp::p

Definition at line 53 of file qhp.h.

53 std::unique_ptr<Private> p;

Referenced by addContentsItem, addFile, addIndexItem, decContentsDepth, finalize, incContentsDepth, initialize and Qhp.

Public Static Functions

getQchFileName()

QCString Qhp::getQchFileName ()
static

Declaration at line 48 of file qhp.h, definition at line 426 of file qhp.cpp.

427{
428 QCString const & qchFile = Config_getString(QCH_FILE);
429 if (!qchFile.isEmpty())
430 {
431 return qchFile;
432 }
433
434 QCString const & projectName = Config_getString(PROJECT_NAME);
435 QCString const & versionText = Config_getString(PROJECT_NUMBER);
436
437 return QCString("../qch/")
438 + (projectName.isEmpty() ? QCString("index") : projectName)
439 + (versionText.isEmpty() ? QCString("") : QCString("-") + versionText)
440 + QCString(".qch");
441}

References Config_getString and QCString::isEmpty.

Referenced by runQHelpGenerator.

Public Static Attributes

qhpFileName

const QCString Qhp::qhpFileName = "index.qhp"
static

Definition at line 47 of file qhp.h.

47 static inline const QCString qhpFileName = "index.qhp";

Referenced by initialize and runQHelpGenerator.


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


Generated via doxygen2docusaurus by Doxygen 1.14.0.