Source-highlight Library
docgenerator.h
1 /*
2  ** Copyright (C) 1999-2007 Lorenzo Bettini <http://www.lorenzobettini.it>
3  **
4  ** This program is free software; you can redistribute it and/or modify
5  ** it under the terms of the GNU General Public License as published by
6  ** the Free Software Foundation; either version 3 of the License, or
7  ** (at your option) any later version.
8  **
9  ** This program is distributed in the hope that it will be useful,
10  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
11  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  ** GNU General Public License for more details.
13  **
14  ** You should have received a copy of the GNU General Public License
15  ** along with this program; if not, write to the Free Software
16  ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17  **
18  */
19 
20 // docgenerator.h : Document generator class
21 
22 // for preable, header, footer, etc.
23 
24 #ifndef DOCGENERATOR_H
25 #define DOCGENERATOR_H
26 
27 #include <string>
28 #include <iostream>
29 
30 #include "doctemplate.h"
31 
32 using std::string;
33 
34 namespace srchilite {
35 
40 class DocGenerator {
41 protected:
42  string title;
43  bool gen_source_highlight_version;
44  string input_file_name;
45  string doc_header;
46  string doc_footer;
47  string css_url;
48  string doc_background;
49  bool entire_doc;
50  string input_lang;
51 
52  DocTemplate docTemplate;
53 
54 public:
55  DocGenerator(const string &s, const string &i, const string &h,
56  const string &f, const string &c, const string &back, bool entire,
57  const string &inputlang,
58  const string &start_tmpl, const string &end_tmpl) :
59  title(s), gen_source_highlight_version(true), input_file_name(i),
60  doc_header(h), doc_footer(f), css_url(c), doc_background(back),
61  entire_doc(entire), input_lang(inputlang), docTemplate(DocTemplate(start_tmpl,
62  end_tmpl)) {
63  }
64  DocGenerator(const string &start_tmpl, const string &end_tmpl) :
65  gen_source_highlight_version(true), docTemplate(DocTemplate(start_tmpl,
66  end_tmpl)) {
67  }
68  DocGenerator() {
69  }
70  ~DocGenerator() {
71  }
72 
78  void generate_start_doc(std::ostream *sout);
79 
85  void generate_end_doc(std::ostream *sout);
86 
90  void set_gen_version(bool b) {
91  gen_source_highlight_version = b;
92  }
93 
94  void setInputFileName(const std::string &filename) {
95  input_file_name = filename;
96  }
97 
98  void setTitle(const std::string &_title) {
99  title = _title;
100  }
101 
102  void setInputLang(const std::string &_input_lang) {
103  input_lang = _input_lang;
104  }
105 
106  void setBackgroundColor(const std::string &bg) {
107  doc_background = bg;
108  }
109 
110  void setCss(const std::string &css) {
111  css_url = css;
112  }
113 
114  void setHeader(const std::string &_header) {
115  doc_header = _header;
116  }
117 
118  void setFooter(const std::string &_footer) {
119  doc_footer = _footer;
120  }
121 };
122 
123 }
124 
125 #endif // DOCGENERATOR_H
Given a DocTemplate it generates the start of the document and the end, using variables such as title...
Definition: docgenerator.h:40
void generate_end_doc(std::ostream *sout)
Generates the end of the document into the passed ostream.
Definition: docgenerator.cc:52
C++ class: doctemplate.h.
Definition: bufferedoutput.cpp:13
void set_gen_version(bool b)
Sets the version of the generator (i.e., of source-highlight)
Definition: docgenerator.h:90
Definition: doctemplate.h:18
void generate_start_doc(std::ostream *sout)
Generates the start of the document into the passed ostream.
Definition: docgenerator.cc:31