cmDocumentationSection.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #ifndef _cmDocumentationSection_h
  11. #define _cmDocumentationSection_h
  12. #include "cmStandardIncludes.h"
  13. #include "cmDocumentationFormatter.h"
  14. // Low-level interface for custom documents:
  15. /** Internal class representing a section of the documentation.
  16. * Cares e.g. for the different section titles in the different
  17. * output formats.
  18. */
  19. class cmDocumentationSection
  20. {
  21. public:
  22. /** Create a cmSection, with a special name for man-output mode. */
  23. cmDocumentationSection(const char* name, const char* manName)
  24. :Name(name), ManName(manName) {}
  25. /** Has any content been added to this section or is it empty ? */
  26. bool IsEmpty() const { return this->Entries.empty(); }
  27. /** Clear contents. */
  28. void Clear() { this->Entries.clear(); }
  29. /** Return the name of this section for the given output form. */
  30. const char* GetName(cmDocumentationEnums::Form form) const
  31. { return (form==cmDocumentationEnums::ManForm ?
  32. this->ManName.c_str() : this->Name.c_str()); }
  33. /** Return a pointer to the first entry of this section. */
  34. const std::vector<cmDocumentationEntry> &GetEntries() const
  35. { return this->Entries; }
  36. /** Append an entry to this section. */
  37. void Append(const cmDocumentationEntry& entry)
  38. { this->Entries.push_back(entry); }
  39. void Append(const std::vector<cmDocumentationEntry> &entries)
  40. { this->Entries.insert(this->Entries.end(),entries.begin(),entries.end()); }
  41. /** Append an entry to this section using NULL terminated chars */
  42. void Append(const char *[][3]);
  43. void Append(const char *n, const char *b, const char *f);
  44. /** prepend some documentation to this section */
  45. void Prepend(const char *[][3]);
  46. void Prepend(const std::vector<cmDocumentationEntry> &entries)
  47. { this->Entries.insert(this->Entries.begin(),
  48. entries.begin(),entries.end()); }
  49. private:
  50. std::string Name;
  51. std::string ManName;
  52. std::vector<cmDocumentationEntry> Entries;
  53. };
  54. #endif