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