ROSE  0.9.9.109
DocumentBaseMarkup.h
1 // WARNING: Changes to this file must be contributed back to Sawyer or else they will
2 // be clobbered by the next update from Sawyer. The Sawyer repository is at
3 // https://github.com/matzke1/sawyer.
4 
5 
6 
7 
8 #ifndef Sawyer_Document_BaseMarkup_H
9 #define Sawyer_Document_BaseMarkup_H
10 
11 #include <Sawyer/DocumentMarkup.h>
12 
13 namespace Sawyer {
14 namespace Document {
15 
17 class SAWYER_EXPORT BaseMarkup: public Markup::Grammar {
18  std::string pageName_; // name of document page, usually one word
19  std::string chapterNumber_; // usually a number like "1", but not necessarily
20  std::string chapterTitle_; // like "Command-line tools"
21  std::string versionStr_; // version string
22  std::string versionDate_; // date string
23 
24 protected:
25  BaseMarkup() {
26  init();
27  }
28 
29 public:
35  const std::string& pageName() const { return pageName_; }
36  BaseMarkup& pageName(const std::string &s) { pageName_ = s; return *this; }
45  const std::string& chapterNumber() const { return chapterNumber_; }
46  BaseMarkup& chapterNumber(const std::string &s) { chapterNumber_ = s; return *this; }
47  const std::string& chapterNumberOrDefault() const;
57  const std::string& chapterTitle() const { return chapterTitle_; }
58  BaseMarkup& chapterTitle(const std::string &s) { chapterTitle_ = s; return *this; }
59  const std::string& chapterTitleOrDefault() const;
68  const std::string& versionString() const { return versionStr_; }
69  BaseMarkup& versionString(const std::string &s) { versionStr_ = s; return *this; }
70  const std::string& versionStringOrDefault() const;
79  const std::string& versionDate() const { return versionDate_; }
80  BaseMarkup& versionDate(const std::string &s) { versionDate_ = s; return *this; }
81  const std::string& versionDateOrDefault() const;
87  BaseMarkup& title(const std::string &pageName, const std::string &chapterNumber, const std::string &chapterTitle);
88 
92  BaseMarkup& version(const std::string &versionString, const std::string &versionDate);
93 
95  virtual std::string operator()(const std::string&) /*override*/;
96 
98  virtual void emit(const std::string &doc) = 0;
99 
101  static bool hasNonSpace(const std::string&);
102 
104  static std::string makeOneLine(const std::string&);
105 
107  static std::string leftJustify(const std::string&, size_t width);
108 
110  static std::string escapeSingleQuoted(const std::string&);
111 
112 protected:
113  // Last thing called before the rendered document is returend
114  virtual std::string finalizeDocument(const std::string &s) { return s; }
115 
116 private:
117  void init();
118 };
119 
120 } // namespace
121 } // namespace
122 
123 #endif
const std::string & chapterTitle() const
Property: Chapter title.
BaseMarkup & chapterTitle(const std::string &s)
Property: Chapter title.
const std::string & versionDate() const
Property: Version date.
BaseMarkup & versionString(const std::string &s)
Property: Version string.
BaseMarkup & pageName(const std::string &s)
Property: Page name.
Name space for the entire library.
Definition: Access.h:11
const std::string & chapterNumber() const
Property: Chapter number.
const std::string & versionString() const
Property: Version string.
const std::string & pageName() const
Property: Page name.
BaseMarkup & chapterNumber(const std::string &s)
Property: Chapter number.
BaseMarkup & versionDate(const std::string &s)
Property: Version date.
Base class for various documentation markup systems.