Doxygen
Loading...
Searching...
No Matches
LayoutDocManager Class Reference

Singleton providing access to the (user configurable) layout of the documentation. More...

#include <src/layout.h>

Classes

class  Private
 

Public Types

enum  LayoutPart { PART_SPECIFICATIONS }
 

Public Member Functions

const LayoutDocEntryListdocEntries (LayoutPart part) const
 Returns the list of LayoutDocEntry's in representation order for a given page identified by part.
 
LayoutNavEntryrootNavEntry () const
 returns the (invisible) root of the navigation tree.
 
LayoutNavEntrycreateChildNavEntry (LayoutNavEntry *root, LayoutNavEntry::Kind k, bool vs, const QCString &bf, const QCString &tl, const QCString &intro)
 append a new node as a child to root.
 
void parse (const QCString &fileName, const char *data=nullptr)
 Parses a user provided layout.
 
void init ()
 
int majorVersion () const
 
int minorVersion () const
 

Static Public Member Functions

static LayoutDocManagerinstance ()
 Returns a reference to this singleton.
 
static std::string partToString (int k)
 

Private Member Functions

void addEntry (LayoutPart p, LayoutDocEntryPtr &&e)
 
void mergeNavEntries (LayoutDocManager &manager)
 
void mergeDocEntries (const QCString &fileName, LayoutDocManager &manager)
 
void removeInvisibleDocEntries ()
 
 LayoutDocManager ()
 
 ~LayoutDocManager ()
 

Private Attributes

std::unique_ptr< Privated
 

Friends

class LayoutParser
 

Detailed Description

Singleton providing access to the (user configurable) layout of the documentation.

Definition at line 261 of file layout.h.

Member Enumeration Documentation

◆ LayoutPart

Enumerator
PART_SPECIFICATIONS 

Definition at line 265 of file layout.h.

266 {
267#define PSPEC(x,y) x y,
269#undef PSPEC
270 };

Constructor & Destructor Documentation

◆ LayoutDocManager()

LayoutDocManager::LayoutDocManager ( )
private

Definition at line 1407 of file layout.cpp.

1407 : d(std::make_unique<Private>())
1408{
1409}
std::unique_ptr< Private > d
Definition layout.h:305

References d.

Referenced by instance(), mergeDocEntries(), mergeNavEntries(), and parse().

◆ ~LayoutDocManager()

LayoutDocManager::~LayoutDocManager ( )
private

Definition at line 1411 of file layout.cpp.

1412{
1413}

Member Function Documentation

◆ addEntry()

void LayoutDocManager::addEntry ( LayoutDocManager::LayoutPart p,
LayoutDocEntryPtr && e )
private

Definition at line 1462 of file layout.cpp.

1463{
1464 auto &docEntry = d->docEntries[static_cast<int>(p)];
1465 docEntry.push_back(std::move(e)); // add
1466}

References d.

◆ createChildNavEntry()

LayoutNavEntry * LayoutDocManager::createChildNavEntry ( LayoutNavEntry * root,
LayoutNavEntry::Kind k,
bool vs,
const QCString & bf,
const QCString & tl,
const QCString & intro )

append a new node as a child to root.

Definition at line 1451 of file layout.cpp.

1454{
1455 if (parent==nullptr) parent = &d->rootNav;
1456 auto ptr = std::make_unique<LayoutNavEntry>(parent,k,vs,bf,tl,intro);
1457 auto child = ptr.get();
1458 parent->appendChild(std::move(ptr));
1459 return child;
1460}
constexpr DocNodeVariant * parent(DocNodeVariant *n)
returns the parent node of a given node n or nullptr if the node has no parent.
Definition docnode.h:1324

References d, and parent().

◆ docEntries()

const LayoutDocEntryList & LayoutDocManager::docEntries ( LayoutDocManager::LayoutPart part) const

Returns the list of LayoutDocEntry's in representation order for a given page identified by part.

Definition at line 1441 of file layout.cpp.

1442{
1443 return d->docEntries[static_cast<int>(part)];
1444}

References d.

◆ init()

void LayoutDocManager::init ( )

Definition at line 1415 of file layout.cpp.

1416{
1418 XMLHandlers handlers;
1419 handlers.startElement = [&layoutParser](const std::string &name,const XMLHandlers::Attributes &attrs) { layoutParser.startElement(name,attrs); };
1420 handlers.endElement = [&layoutParser](const std::string &name) { layoutParser.endElement(name); };
1421 handlers.error = [&layoutParser](const std::string &fileName,int lineNr,const std::string &msg) { layoutParser.error(fileName,lineNr,msg); };
1422 XMLParser parser(handlers);
1423 layoutParser.setDocumentLocator(&parser);
1424 constexpr auto layoutFile = "layout_default.xml";
1425 QCString layout_default = ResourceMgr::instance().getAsString(layoutFile);
1426 parser.parse(layoutFile,layout_default.data(),Debug::isFlagSet(Debug::Lex_xml),
1427 [&]() { DebugLex::print(Debug::Lex_xml,"Entering","libxml/xml.l",layoutFile); },
1428 [&]() { DebugLex::print(Debug::Lex_xml,"Finished", "libxml/xml.l",layoutFile); }
1429 );
1431 d->majorVersion = layoutParser.majorVersion();
1432 d->minorVersion = layoutParser.minorVersion();
1433}
@ Lex_xml
Definition debug.h:70
static bool isFlagSet(const DebugMask mask)
Definition debug.cpp:132
static LayoutDocManager & instance()
Returns a reference to this singleton.
Definition layout.cpp:1435
friend class LayoutParser
Definition layout.h:306
void removeInvisibleDocEntries()
Definition layout.cpp:1509
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string.
Definition qcstring.h:159
static ResourceMgr & instance()
Returns the one and only instance of this class.
QCString getAsString(const QCString &name) const
Gets the resource data as a C string.
std::unordered_map< std::string, std::string > Attributes
Definition xml.h:29
std::function< EndElementType > endElement
handler invoked when a closing tag has been found
Definition xml.h:40
std::function< StartElementType > startElement
handler invoked when an opening tag has been found
Definition xml.h:39
std::function< ErrorType > error
handler invoked when the parser encounters an error
Definition xml.h:42
#define msg(fmt,...)
Definition message.h:94

References d, QCString::data(), LayoutParser::endElement(), XMLHandlers::endElement, LayoutParser::error(), XMLHandlers::error, ResourceMgr::getAsString(), instance(), ResourceMgr::instance(), Debug::isFlagSet(), LayoutParser, Debug::Lex_xml, LayoutParser::majorVersion(), LayoutParser::minorVersion(), msg, XMLParser::parse(), removeInvisibleDocEntries(), LayoutParser::setDocumentLocator(), LayoutParser::startElement(), and XMLHandlers::startElement.

Referenced by parseInput().

◆ instance()

LayoutDocManager & LayoutDocManager::instance ( )
static

Returns a reference to this singleton.

Definition at line 1435 of file layout.cpp.

1436{
1437 static LayoutDocManager theInstance;
1438 return theInstance;
1439}

References LayoutDocManager().

Referenced by addMembersToIndex(), ClassDefImpl::countAdditionalInheritedMembers(), ModuleDefImpl::countVisibleMembers(), NamespaceDefImpl::countVisibleMembers(), generateJSNavTree(), ClassDefImpl::getTitleForMemberListType(), init(), parseInput(), printLayout(), renderQuickLinksAsTabs(), ClassDefImpl::setAnonymousEnumType(), ClassDefImpl::writeAdditionalInheritedMembers(), writeAlphabeticalExceptionIndex(), writeAlphabeticalIndex(), writeAlphabeticalInterfaceIndex(), writeAlphabeticalStructIndex(), writeAnnotatedIndexGeneric(), writeClassMemberIndex(), writeClassMemberIndexFiltered(), writeConceptIndex(), ClassDefImpl::writeDeclaration(), writeDefaultQuickLinks(), ConceptDefImpl::writeDocumentation(), DirDefImpl::writeDocumentation(), FileDefImpl::writeDocumentation(), GroupDefImpl::writeDocumentation(), ModuleDefImpl::writeDocumentation(), NamespaceDefImpl::writeDocumentation(), ClassDefImpl::writeDocumentationContents(), writeExampleIndex(), writeFileIndex(), writeFileMemberIndex(), writeFileMemberIndexFiltered(), writeGraphicalClassHierarchy(), writeGraphicalExceptionHierarchy(), writeGraphicalInterfaceHierarchy(), writeGroupTreeNode(), writeHierarchicalExceptionIndex(), writeHierarchicalIndex(), writeHierarchicalInterfaceIndex(), writeIndex(), writeIndexHierarchy(), writeIndexHierarchyEntries(), ClassDefImpl::writeInlineDocumentation(), writeMenuData(), writeModuleIndex(), writeModuleMemberIndex(), writeModuleMemberIndexFiltered(), writeModuleMembers(), writeNamespaceIndex(), writeNamespaceMemberIndex(), writeNamespaceMemberIndexFiltered(), writeNamespaceMembers(), writePageIndex(), writePages(), ClassDefImpl::writeSummaryLinks(), FileDefImpl::writeSummaryLinks(), GroupDefImpl::writeSummaryLinks(), ModuleDefImpl::writeSummaryLinks(), NamespaceDefImpl::writeSummaryLinks(), ClassDefImpl::writeTagFile(), DirDefImpl::writeTagFile(), FileDefImpl::writeTagFile(), GroupDefImpl::writeTagFile(), ModuleDefImpl::writeTagFile(), NamespaceDefImpl::writeTagFile(), and writeTopicIndex().

◆ majorVersion()

int LayoutDocManager::majorVersion ( ) const

Definition at line 1529 of file layout.cpp.

1530{
1531 return d->majorVersion;
1532}

References d.

◆ mergeDocEntries()

void LayoutDocManager::mergeDocEntries ( const QCString & fileName,
LayoutDocManager & manager )
private

Definition at line 1721 of file layout.cpp.

1722{
1723 for (size_t i=0; i<d->docEntries.size(); i++)
1724 {
1725 //printf("========= part %zu\n",i);
1726 mergeDocEntryLists(fileName,other.d->docEntries[i],d->docEntries[i]);
1727 }
1728}
static void mergeDocEntryLists(const QCString &fileName, LayoutDocEntryList &targetList, LayoutDocEntryList &sourceList)
Definition layout.cpp:1638

References d, LayoutDocManager(), and mergeDocEntryLists().

Referenced by parse().

◆ mergeNavEntries()

void LayoutDocManager::mergeNavEntries ( LayoutDocManager & manager)
private

Definition at line 1633 of file layout.cpp.

1634{
1635 mergeNavTreeNodesRec(other.rootNavEntry(),rootNavEntry());
1636}
LayoutNavEntry * rootNavEntry() const
returns the (invisible) root of the navigation tree.
Definition layout.cpp:1446
static void mergeNavTreeNodesRec(LayoutNavEntry *targetTree, LayoutNavEntry *sourceTree)
Definition layout.cpp:1555

References LayoutDocManager(), mergeNavTreeNodesRec(), and rootNavEntry().

◆ minorVersion()

int LayoutDocManager::minorVersion ( ) const

Definition at line 1534 of file layout.cpp.

1535{
1536 return d->minorVersion;
1537}

References d.

◆ parse()

void LayoutDocManager::parse ( const QCString & fileName,
const char * data = nullptr )

Parses a user provided layout.

Definition at line 1468 of file layout.cpp.

1469{
1470 //printf("============ LayoutDocManager::parse(%s)\n",qPrint(fileName));
1471 LayoutDocManager layoutDocManager;
1472 LayoutParser layoutParser(layoutDocManager);
1473 XMLHandlers handlers;
1474 handlers.startElement = [&layoutParser](const std::string &name,const XMLHandlers::Attributes &attrs) { layoutParser.startElement(name,attrs); };
1475 handlers.endElement = [&layoutParser](const std::string &name) { layoutParser.endElement(name); };
1476 handlers.error = [&layoutParser](const std::string &fn,int lineNr,const std::string &msg) { layoutParser.error(fn,lineNr,msg); };
1477 XMLParser parser(handlers);
1478 layoutParser.setDocumentLocator(&parser);
1479 parser.parse(fileName.data(),
1480 data ? data : fileToString(fileName).data(),
1482 [&]() { DebugLex::print(Debug::Lex_xml,"Entering","libxml/xml.l",qPrint(fileName)); },
1483 [&]() { DebugLex::print(Debug::Lex_xml,"Finished", "libxml/xml.l",qPrint(fileName)); },
1485 );
1486
1487 // version in the user defined layout overrides default one
1488 d->majorVersion = layoutParser.majorVersion();
1489 d->minorVersion = layoutParser.minorVersion();
1490
1491 // merge missing parts of the default layout into the user defined layout
1492 // For now merging in defaults has been disabled for navigation entries
1493 // to avoid "extra entries" for projects that work with partial layout files.
1494 //mergeNavEntries(layoutDocManager);
1495
1496 // for compatibility reasons we only merge defaults when the user defined layout has at least version 2.0 or higher
1497 if (d->majorVersion>=2)
1498 {
1499 mergeDocEntries(fileName,layoutDocManager);
1500 }
1501
1502 layoutDocManager.removeInvisibleDocEntries();
1503
1504 // replace default layout with merged layout
1505 d->docEntries.swap(layoutDocManager.d->docEntries);
1506 d->rootNav.swap(layoutDocManager.d->rootNav);
1507}
static void print(Debug::DebugMask mask, const char *state, const char *lexName, const char *fileName)
Definition debug.cpp:156
void mergeDocEntries(const QCString &fileName, LayoutDocManager &manager)
Definition layout.cpp:1721
const char * qPrint(const char *s)
Definition qcstring.h:672
bool transcodeCharacterStringToUTF8(std::string &input, const char *inputEncoding)
Definition util.cpp:1376
QCString fileToString(const QCString &name, bool filter, bool isSourceCode)
Definition util.cpp:1414

References d, QCString::data(), LayoutParser::endElement(), XMLHandlers::endElement, LayoutParser::error(), XMLHandlers::error, fileToString(), Debug::isFlagSet(), LayoutDocManager(), LayoutParser, Debug::Lex_xml, LayoutParser::majorVersion(), mergeDocEntries(), LayoutParser::minorVersion(), msg, XMLParser::parse(), DebugLex::print(), qPrint(), removeInvisibleDocEntries(), LayoutParser::setDocumentLocator(), LayoutParser::startElement(), XMLHandlers::startElement, and transcodeCharacterStringToUTF8().

Referenced by parseInput().

◆ partToString()

static std::string LayoutDocManager::partToString ( int k)
inlinestatic

Definition at line 273 of file layout.h.

274 {
275 switch (k)
276 {
277#define PSPEC(x,y) case x: return #x; break;
279#undef PSPEC
280 default: return "unknown"; // to satisfy compiler
281 }
282 }

References PART_SPECIFICATIONS.

Referenced by printLayout().

◆ removeInvisibleDocEntries()

void LayoutDocManager::removeInvisibleDocEntries ( )
private

Definition at line 1509 of file layout.cpp.

1510{
1511 // remove invisible entries
1512 for (auto &list : d->docEntries)
1513 {
1514 auto it = list.begin();
1515 while (it!=list.end())
1516 {
1517 if (*it==nullptr || !(*it)->visible())
1518 {
1519 it = list.erase(it);
1520 }
1521 else
1522 {
1523 ++it;
1524 }
1525 }
1526 }
1527}

References d.

Referenced by init(), and parse().

◆ rootNavEntry()

Friends And Related Symbol Documentation

◆ LayoutParser

friend class LayoutParser
friend

Definition at line 306 of file layout.h.

References LayoutParser, printLayout(), and writeDefaultLayoutFile().

Referenced by init(), LayoutParser, and parse().

Member Data Documentation

◆ d


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