a8fb51a17807c7ecd1c60c5b12fedb64af4ca259
[platform/upstream/groff.git] / src / devices / grohtml / html.h
1 // -*- C++ -*-
2 /* Copyright (C) 2000-2014  Free Software Foundation, Inc.
3      Written by James Clark (jjc@jclark.com)
4
5 This file is part of groff.
6
7 groff is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11
12 groff is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15 for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
20 #if !defined(HTML_H)
21 #  define HTML_H
22
23 /*
24  *  class and structure needed to buffer words
25  */
26
27 struct word {
28   char *s;
29   word  *next;
30
31   word  (const char *w, int n);
32   ~word ();
33 };
34
35 class word_list {
36 public:
37             word_list     ();
38   int       flush         (FILE *f);
39   void      add_word      (const char *s, int n);
40   int       get_length    (void);
41   
42 private:
43   int       length;
44   word     *head;
45   word     *tail;
46 };
47
48 class simple_output {
49 public:
50   simple_output(FILE *, int max_line_length);
51   simple_output &put_string(const char *, int);
52   simple_output &put_string(const char *s);
53   simple_output &put_string(const string &s);
54   simple_output &put_troffps_char (const char *s);
55   simple_output &put_translated_string(const char *s);
56   simple_output &put_number(int);
57   simple_output &put_float(double);
58   simple_output &put_symbol(const char *);
59   simple_output &put_literal_symbol(const char *);
60   simple_output &set_fixed_point(int);
61   simple_output &simple_comment(const char *);
62   simple_output &begin_comment(const char *);
63   simple_output &comment_arg(const char *);
64   simple_output &end_comment();
65   simple_output &set_file(FILE *);
66   simple_output &include_file(FILE *);
67   simple_output &copy_file(FILE *);
68   simple_output &end_line();
69   simple_output &put_raw_char(char);
70   simple_output &special(const char *);
71   simple_output &enable_newlines(int);
72   simple_output &check_newline(int n);
73   simple_output &nl(void);
74   simple_output &force_nl(void);
75   simple_output &space_or_newline (void);
76   simple_output &begin_tag (void);
77   FILE *get_file();
78 private:
79   FILE         *fp;
80   int           max_line_length;          // not including newline
81   int           col;
82   int           fixed_point;
83   int           newlines;                 // can we issue newlines automatically?
84   word_list     last_word;
85
86   void          flush_last_word (void);
87   int           check_space (const char *s, int n);
88 };
89
90 inline FILE *simple_output::get_file()
91 {
92   return fp;
93 }
94
95 #endif