cmDocumentationSection.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #ifndef _cmDocumentationSection_h
  4. #define _cmDocumentationSection_h
  5. #include "cmConfigure.h" // IWYU pragma: keep
  6. #include "cmAlgorithms.h"
  7. #include "cmDocumentationEntry.h"
  8. #include <string>
  9. #include <vector>
  10. // Low-level interface for custom documents:
  11. /** Internal class representing a section of the documentation.
  12. * Cares e.g. for the different section titles in the different
  13. * output formats.
  14. */
  15. class cmDocumentationSection
  16. {
  17. public:
  18. /** Create a cmSection, with a special name for man-output mode. */
  19. explicit cmDocumentationSection(const char* name)
  20. : Name(name)
  21. {
  22. }
  23. /** Has any content been added to this section or is it empty ? */
  24. bool IsEmpty() const { return this->Entries.empty(); }
  25. /** Clear contents. */
  26. void Clear() { this->Entries.clear(); }
  27. /** Return the name of this section. */
  28. std::string GetName() const { return this->Name; }
  29. /** Return a pointer to the first entry of this section. */
  30. const std::vector<cmDocumentationEntry>& GetEntries() const
  31. {
  32. return this->Entries;
  33. }
  34. /** Append an entry to this section. */
  35. void Append(const cmDocumentationEntry& entry)
  36. {
  37. this->Entries.push_back(entry);
  38. }
  39. void Append(const std::vector<cmDocumentationEntry>& entries)
  40. {
  41. cmAppend(this->Entries, entries);
  42. }
  43. /** Append an entry to this section using NULL terminated chars */
  44. void Append(const char* [][2]);
  45. void Append(const char* n, const char* b);
  46. /** prepend some documentation to this section */
  47. void Prepend(const char* [][2]);
  48. void Prepend(const std::vector<cmDocumentationEntry>& entries)
  49. {
  50. this->Entries.insert(this->Entries.begin(), entries.begin(),
  51. entries.end());
  52. }
  53. private:
  54. std::string Name;
  55. std::vector<cmDocumentationEntry> Entries;
  56. };
  57. #endif