DescriptionParent

DocFormatHelper

Macros

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
#ifndef FWCore_ParameterSet_DocFormatHelper_h
#define FWCore_ParameterSet_DocFormatHelper_h

// Used internally by ParameterSetDescription in its
// print function. This function is used to produce
// human readable documentation.

#include <string>
#include <iosfwd>
#include <utility>
#include <vector>

namespace edm {

  class ParameterDescriptionNode;

  class DocFormatHelper {
  public:
    enum DescriptionParent { TOP, OR, XOR, AND, OTHER };

    DocFormatHelper()
        : brief_(false),
          lineWidth_(80),
          indentation_(4),
          startColumn2_(24U),
          section_(),
          pass_(0),
          column1_(0),
          column2_(0),
          column3_(0),
          counter_(0),
          parent_(OTHER) {}

    void init();

    bool brief() const { return brief_; }
    size_t lineWidth() const { return lineWidth_; }
    int indentation() const { return indentation_; }
    int startColumn2() const { return startColumn2_; }

    void setBrief(bool value) { brief_ = value; }
    void setLineWidth(size_t value) { lineWidth_ = value; }
    void setIndentation(int value) { indentation_ = value; }

    std::string const& section() const { return section_; }
    void setSection(std::string const& value) { section_ = value; }

    int pass() const { return pass_; }
    void setPass(int value) { pass_ = value; }

    size_t column1() const { return column1_; }
    size_t column2() const { return column2_; }
    size_t column3() const { return column3_; }

    void setAtLeast1(size_t width) {
      if (width > column1_)
        column1_ = width;
    }
    void setAtLeast2(size_t width) {
      if (width > column2_)
        column2_ = width;
    }
    void setAtLeast3(size_t width) {
      if (width > column3_)
        column3_ = width;
    }

    int counter() const { return counter_; }
    void setCounter(int value) { counter_ = value; }
    void incrementCounter() { ++counter_; }
    void decrementCounter() { --counter_; }

    DescriptionParent parent() const { return parent_; }
    void setParent(DescriptionParent value) { parent_ = value; }

    size_t commentWidth() const;

    static void wrapAndPrintText(std::ostream& os, std::string const& text, size_t indent, size_t suggestedWidth);

    void indent(std::ostream& os) const;
    void indent2(std::ostream& os) const;

    static int offsetModuleLabel() { return 2; }
    static int offsetTopLevelPSet() { return 2; }
    static int offsetSectionContent() { return 4; }

    void addCategory(std::string const& pluginCategory, std::string const& section);
    std::string sectionOfCategoryAlreadyPrinted(std::string const& pluginCategory) const;

  private:
    std::vector<std::pair<std::string, std::string>> pluginCategoriesAlreadyPrinted_;
    bool brief_;
    size_t lineWidth_;
    int indentation_;
    size_t startColumn2_;

    std::string section_;

    int pass_;

    size_t column1_;
    size_t column2_;
    size_t column3_;

    int counter_;

    DescriptionParent parent_;
  };
}  // namespace edm
#endif