cmake/Source/cmDocumentationSection.h

67 lines
1.8 KiB
C
Raw Normal View History

2016-10-30 18:24:19 +01:00
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
2021-09-14 00:13:48 +02:00
#pragma once
2017-07-20 19:35:53 +02:00
#include "cmConfigure.h" // IWYU pragma: keep
2016-10-30 18:24:19 +01:00
2023-05-23 16:38:00 +02:00
#include <iterator>
2016-10-30 18:24:19 +01:00
#include <string>
#include <vector>
2020-02-01 23:06:01 +01:00
#include "cmDocumentationEntry.h"
// Low-level interface for custom documents:
/** Internal class representing a section of the documentation.
* Cares e.g. for the different section titles in the different
* output formats.
*/
class cmDocumentationSection
{
public:
/** Create a cmSection, with a special name for man-output mode. */
2019-11-11 23:01:05 +01:00
explicit cmDocumentationSection(const char* name)
2016-07-09 11:21:54 +02:00
: Name(name)
{
}
2013-03-16 19:13:01 +02:00
/** Has any content been added to this section or is it empty ? */
bool IsEmpty() const { return this->Entries.empty(); }
2013-03-16 19:13:01 +02:00
/** Clear contents. */
void Clear() { this->Entries.clear(); }
2013-03-16 19:13:01 +02:00
2014-08-03 19:52:23 +02:00
/** Return the name of this section. */
2016-07-09 11:21:54 +02:00
std::string GetName() const { return this->Name; }
2013-03-16 19:13:01 +02:00
/** Return a pointer to the first entry of this section. */
2016-07-09 11:21:54 +02:00
const std::vector<cmDocumentationEntry>& GetEntries() const
{
return this->Entries;
}
2013-03-16 19:13:01 +02:00
/** Append an entry to this section. */
void Append(const cmDocumentationEntry& entry)
2016-07-09 11:21:54 +02:00
{
this->Entries.push_back(entry);
}
2023-05-23 16:38:00 +02:00
template <typename Iterable>
void Append(const Iterable& entries)
2016-07-09 11:21:54 +02:00
{
2023-05-23 16:38:00 +02:00
this->Entries.insert(std::end(this->Entries), std::begin(entries),
std::end(entries));
2016-07-09 11:21:54 +02:00
}
2013-03-16 19:13:01 +02:00
/** prepend some documentation to this section */
2023-05-23 16:38:00 +02:00
template <typename Iterable>
void Prepend(const Iterable& entries)
2016-07-09 11:21:54 +02:00
{
2023-05-23 16:38:00 +02:00
this->Entries.insert(std::begin(this->Entries), std::begin(entries),
std::end(entries));
2016-07-09 11:21:54 +02:00
}
2013-03-16 19:13:01 +02:00
private:
std::string Name;
std::vector<cmDocumentationEntry> Entries;
};