ROSE 0.11.145.192
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://gitlab.com/charger7534/sawyer.git.
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
14namespace Sawyer {
15namespace Document {
16
18class 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
25protected:
26 BaseMarkup() {
27 init();
28 }
29
30public:
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
113protected:
114 // Last thing called before the rendered document is returend
115 virtual std::string finalizeDocument(const std::string &s) { return s; }
116
117private:
118 void init();
119};
120
121} // namespace
122} // namespace
123
124#endif
Base class for various documentation markup systems.
const std::string & versionStringOrDefault() const
Property: Version string.
const std::string & versionDateOrDefault() const
Property: Version date.
static std::string escapeSingleQuoted(const std::string &)
Escape single quoted string content.
const std::string & versionDate() const
Property: Version date.
BaseMarkup & pageName(const std::string &s)
Property: Page name.
const std::string & chapterTitle() const
Property: Chapter title.
static std::string makeOneLine(const std::string &)
Remove linefeeds.
BaseMarkup & chapterNumber(const std::string &s)
Property: Chapter number.
const std::string & chapterNumber() const
Property: Chapter number.
BaseMarkup & chapterTitle(const std::string &s)
Property: Chapter title.
BaseMarkup & version(const std::string &versionString, const std::string &versionDate)
Set version properties.
BaseMarkup & versionDate(const std::string &s)
Property: Version date.
virtual std::string operator()(const std::string &)
Parse input to generate POD.
const std::string & pageName() const
Property: Page name.
static bool hasNonSpace(const std::string &)
True if this string contains any non-blank characters.
const std::string & chapterNumberOrDefault() const
Property: Chapter number.
BaseMarkup & title(const std::string &pageName, const std::string &chapterNumber, const std::string &chapterTitle)
Set title properties.
virtual bool emit(const std::string &doc)=0
Emit documentation to output.
const std::string & versionString() const
Property: Version string.
const std::string & chapterTitleOrDefault() const
Property: Chapter title.
BaseMarkup & versionString(const std::string &s)
Property: Version string.
static std::string leftJustify(const std::string &, size_t width)
Left justify a string in a field of width N (or more).
Sawyer support library.