20 #include <unordered_map> 23 #include "linkedmap.h" 28 enum class SectionType
40 inline constexpr
bool isSection(SectionType type)
42 return (type==SectionType::Section ||
43 type==SectionType::Subsection ||
44 type==SectionType::Subsubsection ||
45 type==SectionType::Paragraph);
54 m_label(label), m_title(title), m_type(type), m_ref(ref),
55 m_lineNr(lineNr), m_fileName(fileName), m_level(level)
65 QCString label()
const {
return m_label; }
66 QCString title()
const {
return m_title; }
67 SectionType type()
const {
return m_type; }
68 QCString ref()
const {
return m_ref; }
69 int lineNr()
const {
return m_lineNr; }
70 QCString fileName()
const {
return m_fileName; }
71 bool generated()
const {
return m_generated; }
72 int level()
const {
return m_level; }
73 Definition *definition()
const {
return m_definition; }
76 void setFileName(
const QCString &fn) { m_fileName = fn; }
77 void setType(SectionType t) { m_type = t; }
78 void setGenerated(
bool b) { m_generated = b; }
79 void setDefinition(
Definition *d) { m_definition = d; }
80 void setTitle(
const QCString &t) { m_title = t; }
81 void setLevel(
int l) { m_level = l; }
82 void setReference(
const QCString &r) { m_ref = r; }
83 void setLineNr(
int l) { m_lineNr = l; }
92 bool m_generated =
false;
100 using SectionInfoVec = std::vector<const SectionInfo*>;
102 using const_iterator = SectionInfoVec::const_iterator;
108 auto it = m_lookup.find(label.str());
109 return it!=m_lookup.end() ? it->second :
nullptr;
115 m_lookup.insert({toStdString(si->label()),si});
116 m_entries.push_back(si);
119 const_iterator begin()
const {
return m_entries.cbegin(); }
120 const_iterator end()
const {
return m_entries.cend(); }
121 bool empty()
const {
return m_entries.empty(); }
122 size_t size()
const {
return m_entries.size(); }
125 SectionInfoVec m_entries;
126 std::unordered_map< std::string, const SectionInfo* > m_lookup;
138 si.lineNr(),si.title(),si.type(),si.level(),si.ref());
157 si->setFileName(fileName);
158 si->setLineNr(lineNr);
162 si->setReference(ref);
const T * find(const std::string &key) const
Find an object given the key.
Definition: linkedmap.h:47
The common base class of all entity definitions found in the sources.
Definition: definition.h:76
SectionInfo * replace(const QCString &label, const QCString &fileName, int lineNr, const QCString &title, SectionType type, int level, const QCString &ref=QCString())
Replace an existing section with a new one Return a non-owning pointer to the newly added section...
Definition: section.h:151
static SectionManager & instance()
returns a reference to the singleton
Definition: section.h:172
SectionInfo * add(const SectionInfo &si)
Add a new section given the data of an existing section.
Definition: section.h:135
class that represents a list of constant references to sections.
Definition: section.h:98
const SectionInfo * find(const QCString &label) const
Returns a constant pointer to the section info given a section label or nullptr if no section with th...
Definition: section.h:106
T * add(const char *k, Args &&... args)
Adds a new object to the ordered vector if it was not added already.
Definition: linkedmap.h:90
class that provide information about a section.
Definition: section.h:49
Container class representing a vector of objects with keys.
Definition: linkedmap.h:35
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:153
SectionInfo * add(const QCString &label, const QCString &fileName, int lineNr, const QCString &title, SectionType type, int level, const QCString &ref=QCString())
Add a new section Return a non-owning pointer to the newly added section.
Definition: section.h:143
singleton class that owns the list of all sections
Definition: section.h:130
This is an alternative implementation of QCString.
Definition: qcstring.h:108
void add(const SectionInfo *si)
Adds a non-owning section reference.
Definition: section.h:113