File indexing completed on 2024-04-06 12:12:51
0001 #ifndef FWCore_ParameterSet_DocFormatHelper_h
0002 #define FWCore_ParameterSet_DocFormatHelper_h
0003
0004
0005
0006
0007
0008 #include <string>
0009 #include <iosfwd>
0010 #include <utility>
0011 #include <vector>
0012
0013 namespace edm {
0014
0015 class ParameterDescriptionNode;
0016
0017 class DocFormatHelper {
0018 public:
0019 enum DescriptionParent { TOP, OR, XOR, AND, OTHER };
0020
0021 DocFormatHelper()
0022 : brief_(false),
0023 lineWidth_(80),
0024 indentation_(4),
0025 startColumn2_(24U),
0026 section_(),
0027 pass_(0),
0028 column1_(0),
0029 column2_(0),
0030 column3_(0),
0031 counter_(0),
0032 parent_(OTHER) {}
0033
0034 void init();
0035
0036 bool brief() const { return brief_; }
0037 size_t lineWidth() const { return lineWidth_; }
0038 int indentation() const { return indentation_; }
0039 int startColumn2() const { return startColumn2_; }
0040
0041 void setBrief(bool value) { brief_ = value; }
0042 void setLineWidth(size_t value) { lineWidth_ = value; }
0043 void setIndentation(int value) { indentation_ = value; }
0044
0045 std::string const& section() const { return section_; }
0046 void setSection(std::string const& value) { section_ = value; }
0047
0048 int pass() const { return pass_; }
0049 void setPass(int value) { pass_ = value; }
0050
0051 size_t column1() const { return column1_; }
0052 size_t column2() const { return column2_; }
0053 size_t column3() const { return column3_; }
0054
0055 void setAtLeast1(size_t width) {
0056 if (width > column1_)
0057 column1_ = width;
0058 }
0059 void setAtLeast2(size_t width) {
0060 if (width > column2_)
0061 column2_ = width;
0062 }
0063 void setAtLeast3(size_t width) {
0064 if (width > column3_)
0065 column3_ = width;
0066 }
0067
0068 int counter() const { return counter_; }
0069 void setCounter(int value) { counter_ = value; }
0070 void incrementCounter() { ++counter_; }
0071 void decrementCounter() { --counter_; }
0072
0073 DescriptionParent parent() const { return parent_; }
0074 void setParent(DescriptionParent value) { parent_ = value; }
0075
0076 size_t commentWidth() const;
0077
0078 static void wrapAndPrintText(std::ostream& os, std::string const& text, size_t indent, size_t suggestedWidth);
0079
0080 void indent(std::ostream& os) const;
0081 void indent2(std::ostream& os) const;
0082
0083 static int offsetModuleLabel() { return 2; }
0084 static int offsetTopLevelPSet() { return 2; }
0085 static int offsetSectionContent() { return 4; }
0086
0087 void addCategory(std::string const& pluginCategory, std::string const& section);
0088 std::string sectionOfCategoryAlreadyPrinted(std::string const& pluginCategory) const;
0089
0090 private:
0091 std::vector<std::pair<std::string, std::string>> pluginCategoriesAlreadyPrinted_;
0092 bool brief_;
0093 size_t lineWidth_;
0094 int indentation_;
0095 size_t startColumn2_;
0096
0097 std::string section_;
0098
0099 int pass_;
0100
0101 size_t column1_;
0102 size_t column2_;
0103 size_t column3_;
0104
0105 int counter_;
0106
0107 DescriptionParent parent_;
0108 };
0109 }
0110 #endif