ROSE  0.11.96.11
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 #include <Sawyer/Sawyer.h>
13 
14 namespace Sawyer {
15 namespace Document {
16 
18 class SAWYER_EXPORT BaseMarkup: public Markup::Grammar {
19  std::string pageName_; // name of document page, usually one word
20  std::string chapterNumber_; // usually a number like "1", but not necessarily
21  std::string chapterTitle_; // like "Command-line tools"
22  std::string versionStr_; // version string
23  std::string versionDate_; // date string
24 
25 protected:
26  BaseMarkup() {
27  init();
28  }
29 
30 public:
36  const std::string& pageName() const { return pageName_; }
37  BaseMarkup& pageName(const std::string &s) { pageName_ = s; return *this; }
46  const std::string& chapterNumber() const { return chapterNumber_; }
47  BaseMarkup& chapterNumber(const std::string &s) { chapterNumber_ = s; return *this; }
48  const std::string& chapterNumberOrDefault() const;
58  const std::string& chapterTitle() const { return chapterTitle_; }
59  BaseMarkup& chapterTitle(const std::string &s) { chapterTitle_ = s; return *this; }
60  const std::string& chapterTitleOrDefault() const;
69  const std::string& versionString() const { return versionStr_; }
70  BaseMarkup& versionString(const std::string &s) { versionStr_ = s; return *this; }
71  const std::string& versionStringOrDefault() const;
80  const std::string& versionDate() const { return versionDate_; }
81  BaseMarkup& versionDate(const std::string &s) { versionDate_ = s; return *this; }
82  const std::string& versionDateOrDefault() const;
88  BaseMarkup& title(const std::string &pageName, const std::string &chapterNumber, const std::string &chapterTitle);
89 
93  BaseMarkup& version(const std::string &versionString, const std::string &versionDate);
94 
96  virtual std::string operator()(const std::string&) /*override*/;
97 
99  virtual bool emit(const std::string &doc) = 0;
100 
102  static bool hasNonSpace(const std::string&);
103 
105  static std::string makeOneLine(const std::string&);
106 
108  static std::string leftJustify(const std::string&, size_t width);
109 
111  static std::string escapeSingleQuoted(const std::string&);
112 
113 protected:
114  // Last thing called before the rendered document is returend
115  virtual std::string finalizeDocument(const std::string &s) { return s; }
116 
117 private:
118  void init();
119 };
120 
121 } // namespace
122 } // namespace
123 
124 #endif
Sawyer::Document::BaseMarkup::versionDate
BaseMarkup & versionDate(const std::string &s)
Property: Version date.
Definition: DocumentBaseMarkup.h:81
Sawyer::Document::BaseMarkup::pageName
BaseMarkup & pageName(const std::string &s)
Property: Page name.
Definition: DocumentBaseMarkup.h:37
Sawyer::Document::BaseMarkup::versionString
const std::string & versionString() const
Property: Version string.
Definition: DocumentBaseMarkup.h:69
Sawyer::Document::BaseMarkup::chapterTitle
const std::string & chapterTitle() const
Property: Chapter title.
Definition: DocumentBaseMarkup.h:58
Sawyer::Document::BaseMarkup::chapterNumber
const std::string & chapterNumber() const
Property: Chapter number.
Definition: DocumentBaseMarkup.h:46
Sawyer::Document::BaseMarkup::pageName
const std::string & pageName() const
Property: Page name.
Definition: DocumentBaseMarkup.h:36
Sawyer::Document::BaseMarkup
Base class for various documentation markup systems.
Definition: DocumentBaseMarkup.h:18
Sawyer::Document::BaseMarkup::versionDate
const std::string & versionDate() const
Property: Version date.
Definition: DocumentBaseMarkup.h:80
Sawyer::Document::BaseMarkup::chapterTitle
BaseMarkup & chapterTitle(const std::string &s)
Property: Chapter title.
Definition: DocumentBaseMarkup.h:59
Sawyer
Name space for the entire library.
Definition: Access.h:13
Sawyer::Document::BaseMarkup::chapterNumber
BaseMarkup & chapterNumber(const std::string &s)
Property: Chapter number.
Definition: DocumentBaseMarkup.h:47
Sawyer::Document::BaseMarkup::versionString
BaseMarkup & versionString(const std::string &s)
Property: Version string.
Definition: DocumentBaseMarkup.h:70
Sawyer::Document::Markup::Grammar
Grammar declaration.
Definition: DocumentMarkup.h:403