Doxygen
Loading...
Searching...
No Matches
layout.cpp File Reference
#include <array>
#include <assert.h>
#include "types.h"
#include "layout.h"
#include "message.h"
#include "language.h"
#include "util.h"
#include "doxygen.h"
#include "version.h"
#include "config.h"
#include "xml.h"
#include "resourcemgr.h"
#include "docparser.h"
#include "docnode.h"
#include "debug.h"
+ Include dependency graph for layout.cpp:

Go to the source code of this file.

Classes

class  LayoutParser
 
struct  anonymous_namespace{layout.cpp}::ElementCallbacks
 
class  LayoutDocManager::Private
 

Namespaces

namespace  anonymous_namespace{layout.cpp}
 

Functions

QCString compileOptions (const QCString &def)
 
QCString compileOptions (const QCString &def, SrcLangExt langId1, const QCString &value1)
 
QCString compileOptions (const QCString &def, SrcLangExt langId1, const QCString &value1, SrcLangExt langId2, const QCString &value2)
 
QCString compileOptions (const QCString &def, SrcLangExt langId1, const QCString &value1, SrcLangExt langId2, const QCString &value2, SrcLangExt langId3, const QCString &value3)
 
QCString compileOptions (const QCString &def, SrcLangExt langId1, const QCString &value1, SrcLangExt langId2, const QCString &value2, SrcLangExt langId3, const QCString &value3, SrcLangExt langId4, const QCString &value4)
 
QCString compileOptions (const QCString &def, SrcLangExt langId1, const QCString &value1, SrcLangExt langId2, const QCString &value2, SrcLangExt langId3, const QCString &value3, SrcLangExt langId4, const QCString &value4, SrcLangExt langId5, const QCString &value5)
 
static bool elemIsVisible (const XMLHandlers::Attributes &attrib, bool defVal=TRUE)
 
static bool parentIsVisible (LayoutNavEntry *parent)
 
template<class... Args>
static auto anonymous_namespace{layout.cpp}::startCb (void(LayoutParser::*fn)(Args...))
 
template<class... Args>
static auto anonymous_namespace{layout.cpp}::startCb (void(LayoutParser::*fn)(Args...), LayoutDocEntry::Kind kind)
 
template<class... Args>
static auto anonymous_namespace{layout.cpp}::startCb (void(LayoutParser::*fn)(Args...), LayoutDocEntry::Kind kind, const std::function< QCString()> &title)
 
template<class... Args>
static auto anonymous_namespace{layout.cpp}::startCb (void(LayoutParser::*fn)(Args...), MemberListType type, const std::function< QCString()> &title)
 
template<class... Args>
static auto anonymous_namespace{layout.cpp}::startCb (void(LayoutParser::*fn)(Args...), MemberListType type, const std::function< QCString()> &title, const std::function< QCString()> &subtitle)
 
template<class... Args>
static auto anonymous_namespace{layout.cpp}::startCb (void(LayoutParser::*fn)(Args...), LayoutDocManager::LayoutPart part, const QCString &scope, LayoutNavEntry::Kind nav)
 
static auto anonymous_namespace{layout.cpp}::endCb (void(LayoutParser::*fn)())
 
void writeDefaultLayoutFile (const QCString &fileName)
 
QCString extractLanguageSpecificTitle (const QCString &input, SrcLangExt lang)
 

Variables

static const std::map< std::string, ElementCallbacksanonymous_namespace{layout.cpp}::g_elementHandlers
 

Function Documentation

◆ compileOptions() [1/6]

QCString compileOptions ( const QCString & def)
inline

Definition at line 37 of file layout.cpp.

38{
39 return def;
40}

Referenced by compileOptions(), compileOptions(), compileOptions(), compileOptions(), and compileOptions().

◆ compileOptions() [2/6]

QCString compileOptions ( const QCString & def,
SrcLangExt langId1,
const QCString & value1 )
inline

Definition at line 42 of file layout.cpp.

43{
44 return compileOptions(def)+"|"+QCString().setNum(static_cast<long>(langId1))+"="+value1;
45}
This is an alternative implementation of QCString.
Definition qcstring.h:101
QCString & setNum(short n)
Definition qcstring.h:444
QCString compileOptions(const QCString &def)
Definition layout.cpp:37

References compileOptions(), and QCString::setNum().

◆ compileOptions() [3/6]

QCString compileOptions ( const QCString & def,
SrcLangExt langId1,
const QCString & value1,
SrcLangExt langId2,
const QCString & value2 )
inline

Definition at line 47 of file layout.cpp.

49{
50 return compileOptions(def,langId1,value1)+
51 "|"+QCString().setNum(static_cast<long>(langId2))+"="+value2;
52}

References compileOptions(), and QCString::setNum().

◆ compileOptions() [4/6]

QCString compileOptions ( const QCString & def,
SrcLangExt langId1,
const QCString & value1,
SrcLangExt langId2,
const QCString & value2,
SrcLangExt langId3,
const QCString & value3 )
inline

Definition at line 54 of file layout.cpp.

57{
58 return compileOptions(def,langId1,value1,langId2,value2)+
59 "|"+QCString().setNum(static_cast<long>(langId3))+"="+value3;
60}

References compileOptions(), and QCString::setNum().

◆ compileOptions() [5/6]

QCString compileOptions ( const QCString & def,
SrcLangExt langId1,
const QCString & value1,
SrcLangExt langId2,
const QCString & value2,
SrcLangExt langId3,
const QCString & value3,
SrcLangExt langId4,
const QCString & value4 )
inline

Definition at line 62 of file layout.cpp.

66{
67 return compileOptions(def,langId1,value1,langId2,value2,langId3,value3)+
68 "|"+QCString().setNum(static_cast<long>(langId4))+"="+value4;
69}

References compileOptions(), and QCString::setNum().

◆ compileOptions() [6/6]

QCString compileOptions ( const QCString & def,
SrcLangExt langId1,
const QCString & value1,
SrcLangExt langId2,
const QCString & value2,
SrcLangExt langId3,
const QCString & value3,
SrcLangExt langId4,
const QCString & value4,
SrcLangExt langId5,
const QCString & value5 )
inline

Definition at line 71 of file layout.cpp.

76{
77 return compileOptions(def,langId1,value1,langId2,value2,langId3,value3,langId4,value4)+
78 "|"+QCString().setNum(static_cast<long>(langId5))+"="+value5;
79}

References compileOptions(), and QCString::setNum().

◆ elemIsVisible()

static bool elemIsVisible ( const XMLHandlers::Attributes & attrib,
bool defVal = TRUE )
static

Definition at line 81 of file layout.cpp.

82{
83 QCString visible = XMLHandlers::value(attrib,"visible");
84 if (visible.isEmpty()) return defVal;
85 if (visible.at(0)=='$' && visible.length()>1)
86 {
87 QCString id = visible.mid(1);
88 const ConfigValues::Info *opt = ConfigValues::instance().get(id);
89 if (opt && opt->type==ConfigValues::Info::Bool)
90 {
91 return ConfigValues::instance().*(opt->value.b);
92 }
93 else if (opt && opt->type==ConfigValues::Info::String)
94 {
95 return opt->getBooleanRepresentation();
96 }
97 else if (!opt)
98 {
99 err("found unsupported value '%s' for visible attribute in layout file, reverting to '%s'\n",
100 qPrint(visible),(defVal?"yes":"no"));
101 return defVal;
102 }
103 }
104 QCString visibleLow = visible.lower();
105 if (visibleLow=="no" || visibleLow=="false" || visibleLow=="0") return FALSE;
106 else if (visibleLow=="yes" || visibleLow=="true" || visibleLow=="1") return TRUE;
107 else
108 {
109 err("found unsupported value '%s' for visible attribute in layout file, reverting to '%s'\n",
110 qPrint(visible),(defVal?"yes":"no"));
111 return defVal;
112 }
113}
size_t length() const
Returns the length of the string, not counting the 0-terminator.
Definition qcstring.h:153
QCString mid(size_t index, size_t len=static_cast< size_t >(-1)) const
Definition qcstring.h:226
QCString lower() const
Definition qcstring.h:234
char & at(size_t i)
Returns a reference to the character at index i.
Definition qcstring.h:578
bool isEmpty() const
Returns TRUE iff the string is empty.
Definition qcstring.h:150
static std::string value(const Attributes &attrib, const std::string &key)
Definition xml.h:44
#define err(fmt,...)
Definition message.h:84
const char * qPrint(const char *s)
Definition qcstring.h:672
#define TRUE
Definition qcstring.h:37
#define FALSE
Definition qcstring.h:34

References QCString::at(), err, FALSE, QCString::isEmpty(), QCString::length(), QCString::lower(), QCString::mid(), qPrint(), TRUE, and XMLHandlers::value().

Referenced by LayoutParser::startMemberDecl(), LayoutParser::startMemberDeclEntry(), LayoutParser::startMemberDef(), LayoutParser::startMemberDefEntry(), LayoutParser::startNavEntry(), LayoutParser::startSectionEntry(), LayoutParser::startSimpleEntry(), and LayoutParser::startTop().

◆ extractLanguageSpecificTitle()

QCString extractLanguageSpecificTitle ( const QCString & input,
SrcLangExt lang )

Definition at line 1503 of file layout.cpp.

1504{
1505 int s=0,e=input.find('|');
1506 if (e==-1) return input; // simple title case
1507 int e1=e;
1508 while (e!=-1) // look for 'number=title' pattern separated by '|'
1509 {
1510 s=e+1;
1511 e=input.find('|',s);
1512 int i=input.find('=',s);
1513 assert(i>s);
1514 SrcLangExt key= static_cast<SrcLangExt>(input.mid(s,i-s).toUInt());
1515 if (key==lang) // found matching key
1516 {
1517 if (e==-1) e=static_cast<int>(input.length());
1518 return input.mid(i+1,e-i-1);
1519 }
1520 }
1521 return input.left(e1); // fallback, no explicit language key found
1522}
int find(char c, int index=0, bool cs=TRUE) const
Definition qcstring.cpp:43
QCString left(size_t len) const
Definition qcstring.h:214
SrcLangExt
Language as given by extension.
Definition types.h:42

References QCString::find(), QCString::left(), QCString::length(), and QCString::mid().

Referenced by LayoutDocEntryMemberDecl::subtitle(), LayoutDocEntryMemberDecl::title(), LayoutDocEntryMemberDef::title(), and LayoutDocEntrySection::title().

◆ parentIsVisible()

static bool parentIsVisible ( LayoutNavEntry * parent)
static

Definition at line 115 of file layout.cpp.

116{
117 return parent==nullptr || parent->visible();
118}
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 parent().

Referenced by LayoutParser::startMemberDecl(), LayoutParser::startMemberDeclEntry(), LayoutParser::startMemberDef(), LayoutParser::startMemberDefEntry(), LayoutParser::startNavEntry(), LayoutParser::startSectionEntry(), and LayoutParser::startSimpleEntry().

◆ writeDefaultLayoutFile()

void writeDefaultLayoutFile ( const QCString & fileName)

Definition at line 1479 of file layout.cpp.

1480{
1481 std::ofstream f;
1482 if (openOutputFile(fileName,f))
1483 {
1484 TextStream t(&f);
1485 QCString layout_default = ResourceMgr::instance().getAsString("layout_default.xml");
1486 t << substitute(layout_default,"$doxygenversion",getDoxygenVersion());
1487 }
1488 else
1489 {
1490 err("Failed to open file %s for writing!\n",qPrint(fileName));
1491 return;
1492 }
1493 f.close();
1494}
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.
Text streaming class that buffers data.
Definition textstream.h:36
QCString substitute(const QCString &s, const QCString &src, const QCString &dst)
substitute all occurrences of src in s by dst
Definition qcstring.cpp:477
bool openOutputFile(const QCString &outFile, std::ofstream &f)
Definition util.cpp:6624

References err, ResourceMgr::getAsString(), ResourceMgr::instance(), openOutputFile(), qPrint(), and substitute().

Referenced by LayoutDocManager::LayoutParser, and readConfiguration().