cmDocumentationSection.h 1.9 KB
Newer Older
1 2
/* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
   file Copyright.txt or https://cmake.org/licensing for details.  */
3 4 5
#ifndef _cmDocumentationSection_h
#define _cmDocumentationSection_h

6
#include "cmConfigure.h" // IWYU pragma: keep
7

8
#include "cmAlgorithms.h"
9 10 11 12
#include "cmDocumentationEntry.h"

#include <string>
#include <vector>
13 14 15 16 17 18 19 20 21 22

// 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. */
23
  explicit cmDocumentationSection(const char* name)
24 25 26
    : Name(name)
  {
  }
27

28 29
  /** Has any content been added to this section or is it empty ? */
  bool IsEmpty() const { return this->Entries.empty(); }
30

31 32
  /** Clear contents. */
  void Clear() { this->Entries.clear(); }
33

34
  /** Return the name of this section. */
35
  std::string GetName() const { return this->Name; }
36

37
  /** Return a pointer to the first entry of this section. */
38 39 40 41
  const std::vector<cmDocumentationEntry>& GetEntries() const
  {
    return this->Entries;
  }
42

43 44
  /** Append an entry to this section. */
  void Append(const cmDocumentationEntry& entry)
45 46 47 48 49
  {
    this->Entries.push_back(entry);
  }
  void Append(const std::vector<cmDocumentationEntry>& entries)
  {
50
    cmAppend(this->Entries, entries);
51
  }
52

53
  /** Append an entry to this section using NULL terminated chars */
54 55
  void Append(const char* [][2]);
  void Append(const char* n, const char* b);
56 57

  /** prepend some documentation to this section */
58 59 60 61 62 63
  void Prepend(const char* [][2]);
  void Prepend(const std::vector<cmDocumentationEntry>& entries)
  {
    this->Entries.insert(this->Entries.begin(), entries.begin(),
                         entries.end());
  }
64

65 66 67 68 69 70
private:
  std::string Name;
  std::vector<cmDocumentationEntry> Entries;
};

#endif