cmDocumentationSection.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 "cmDocumentationEntry.h"
  7. #include <string>
  8. #include <vector>
  9. // Low-level interface for custom documents:
  10. /** Internal class representing a section of the documentation.
  11. * Cares e.g. for the different section titles in the different
  12. * output formats.
  13. */
  14. class cmDocumentationSection
  15. {
  16. public:
  17. /** Create a cmSection, with a special name for man-output mode. */
  18. cmDocumentationSection(const char* name, const char*)
  19. : Name(name)
  20. {
  21. }
  22. /** Has any content been added to this section or is it empty ? */
  23. bool IsEmpty() const { return this->Entries.empty(); }
  24. /** Clear contents. */
  25. void Clear() { this->Entries.clear(); }
  26. /** Return the name of this section. */
  27. std::string GetName() const { return this->Name; }
  28. /** Return a pointer to the first entry of this section. */
  29. const std::vector<cmDocumentationEntry>& GetEntries() const
  30. {
  31. return this->Entries;
  32. }
  33. /** Append an entry to this section. */
  34. void Append(const cmDocumentationEntry& entry)
  35. {
  36. this->Entries.push_back(entry);
  37. }
  38. void Append(const std::vector<cmDocumentationEntry>& entries)
  39. {
  40. this->Entries.insert(this->Entries.end(), entries.begin(), entries.end());
  41. }
  42. /** Append an entry to this section using NULL terminated chars */
  43. void Append(const char* [][2]);
  44. void Append(const char* n, const char* b);
  45. /** prepend some documentation to this section */
  46. void Prepend(const char* [][2]);
  47. void Prepend(const std::vector<cmDocumentationEntry>& entries)
  48. {
  49. this->Entries.insert(this->Entries.begin(), entries.begin(),
  50. entries.end());
  51. }
  52. private:
  53. std::string Name;
  54. std::vector<cmDocumentationEntry> Entries;
  55. };
  56. #endif