wibble  1.1
doc.h
Go to the documentation of this file.
1 #ifndef WIBBLE_COMMANDLINE_DOC_H
2 #define WIBBLE_COMMANDLINE_DOC_H
3 
5 #include <string>
6 #include <vector>
7 #include <ostream>
8 
9 namespace wibble {
10 namespace commandline {
11 
12 class HelpWriter;
13 
14 class DocMaker
15 {
16 protected:
17  std::string m_app;
18  std::string m_ver;
19 
20 public:
21  DocMaker(const std::string& app, const std::string& ver)
22  : m_app(app), m_ver(ver) {}
23 };
24 
25 class Help : public DocMaker
26 {
27 protected:
28  void outputOptions(std::ostream& out, HelpWriter& writer, const Engine& cp);
29 
30 public:
31  Help(const std::string& app, const std::string& ver)
32  : DocMaker(app, ver) {}
33 
34  void outputVersion(std::ostream& out);
35  void outputHelp(std::ostream& out, const Engine& cp);
36 };
37 
38 class Manpage : public DocMaker
39 {
40 public:
41  enum where { BEFORE, BEGINNING, END };
42 
43 private:
44  struct Hook
45  {
46  std::string section;
47  where placement;
48  std::string text;
49 
50  Hook(const std::string& section, where placement, const std::string& text)
51  : section(section), placement(placement), text(text) {}
52  };
53 
54  int m_section;
55  std::string m_author;
56 
57  std::vector<Hook> hooks;
58  std::string lastSection;
59 
60  void outputParagraph(std::ostream& out, const std::string& str);
61  void outputOption(std::ostream& out, const Option* o);
62  void outputOptions(std::ostream& out, const Engine& p);
63  void runHooks(std::ostream& out, const std::string& section, where where);
64  void startSection(std::ostream& out, const std::string& name);
65  void endSection(std::ostream& out);
66 
67 
68 public:
69  Manpage(const std::string& app, const std::string& ver, int section, const std::string& author)
70  : DocMaker(app, ver), m_section(section), m_author(author) {}
71 
72  void addHook(const std::string& section, where placement, const std::string& text)
73  {
74  hooks.push_back(Hook(section, placement, text));
75  }
76  void readHooks(const std::string& file);
77 
78  void output(std::ostream& out, const Engine& cp);
79 };
80 
81 }
82 }
83 
84 // vim:set ts=4 sw=4:
85 #endif
Manpage(const std::string &app, const std::string &ver, int section, const std::string &author)
Definition: doc.h:69
Definition: doc.h:14
Definition: doc.h:25
DocMaker(const std::string &app, const std::string &ver)
Definition: doc.h:21
Definition: doc.h:38
Parse commandline options.
Definition: engine.h:38
void addHook(const std::string &section, where placement, const std::string &text)
Definition: doc.h:72
Interface for a parser for one commandline option.
Definition: options.h:55
std::string m_ver
Definition: doc.h:18
Definition: amorph.h:17
void output(List l, Out it)
Definition: list.h:415
Help(const std::string &app, const std::string &ver)
Definition: doc.h:31
std::string m_app
Definition: doc.h:17
where
Definition: doc.h:41