File: docgenerator.h

package info (click to toggle)
source-highlight 3.1.7-1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 10,332 kB
  • ctags: 5,233
  • sloc: sh: 11,270; cpp: 10,206; ansic: 9,515; makefile: 1,865; lex: 1,200; yacc: 1,021; php: 213; perl: 211; awk: 98; erlang: 94; lisp: 90; java: 75; ruby: 69; python: 61; asm: 43; ml: 38; ada: 36; haskell: 27; xml: 23; cs: 11; sql: 8; tcl: 6; sed: 4
file content (125 lines) | stat: -rw-r--r-- 3,446 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/*
 ** Copyright (C) 1999-2007 Lorenzo Bettini <http://www.lorenzobettini.it>
 **
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
 ** the Free Software Foundation; either version 3 of the License, or
 ** (at your option) any later version.
 **
 ** This program is distributed in the hope that it will be useful,
 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 ** GNU General Public License for more details.
 **
 ** You should have received a copy of the GNU General Public License
 ** along with this program; if not, write to the Free Software
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
 */

// docgenerator.h : Document generator class

// for preable, header, footer, etc.

#ifndef DOCGENERATOR_H
#define DOCGENERATOR_H

#include <string>
#include <iostream>

#include "doctemplate.h"

using std::string;

namespace srchilite {

/**
 * Given a DocTemplate it generates the start of the document and the end, using
 * variables such as title, file_name, header, etc.
 */
class DocGenerator {
protected:
    string title;
    bool gen_source_highlight_version;
    string input_file_name;
    string doc_header;
    string doc_footer;
    string css_url;
    string doc_background;
    bool entire_doc;
    string input_lang;

    DocTemplate docTemplate;

public:
    DocGenerator(const string &s, const string &i, const string &h,
            const string &f, const string &c, const string &back, bool entire, 
	    const string &inputlang,
            const string &start_tmpl, const string &end_tmpl) :
        title(s), gen_source_highlight_version(true), input_file_name(i),
                doc_header(h), doc_footer(f), css_url(c), doc_background(back),
	  entire_doc(entire), input_lang(inputlang), docTemplate(DocTemplate(start_tmpl,
                        end_tmpl)) {
    }
    DocGenerator(const string &start_tmpl, const string &end_tmpl) :
        gen_source_highlight_version(true), docTemplate(DocTemplate(start_tmpl,
                end_tmpl)) {
    }
    DocGenerator() {
    }
    ~DocGenerator() {
    }

    /**
     * Generates the start of the document into the passed ostream
     *
     * @param sout the stream for generating the output
     */
    void generate_start_doc(std::ostream *sout);

    /**
     * Generates the end of the document into the passed ostream
     *
     * @param sout the stream for generating the output
     */
    void generate_end_doc(std::ostream *sout);

    /**
     * Sets the version of the generator (i.e., of source-highlight)
     */
    void set_gen_version(bool b) {
        gen_source_highlight_version = b;
    }

    void setInputFileName(const std::string &filename) {
        input_file_name = filename;
    }

    void setTitle(const std::string &_title) {
        title = _title;
    }

    void setInputLang(const std::string &_input_lang) {
      input_lang = _input_lang;
    }

    void setBackgroundColor(const std::string &bg) {
        doc_background = bg;
    }

    void setCss(const std::string &css) {
        css_url = css;
    }

    void setHeader(const std::string &_header) {
        doc_header = _header;
    }

    void setFooter(const std::string &_footer) {
        doc_footer = _footer;
    }
};

}

#endif // DOCGENERATOR_H