File: HTMLControl.h

package info (click to toggle)
html2text 2.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,144 kB
  • sloc: cpp: 5,891; sh: 5,747; yacc: 891; makefile: 84
file content (88 lines) | stat: -rw-r--r-- 2,201 bytes parent folder | download | duplicates (2)
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
/*
 * Portions Copyright (c) 1999 GMRS Software GmbH
 * Carl-von-Linde-Str. 38, D-85716 Unterschleissheim, http://www.gmrs.de
 * All rights reserved.
 *
 * Author: Arno Unkrig <arno@unkrig.de>
 *
 * 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 2 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 in the file COPYING for more details.
 */

#ifndef __HTMLControl_h_INCLUDED__ /* { */
#define __HTMLControl_h_INCLUDED__

#include "iconvstream.h"
#include <istream>

#include "HTMLParser.hh"

using std::istream;

struct htmlparsertoken {
	int next_token;
	int next_token_tag_type;
	html2text::HTMLParser::semantic_type next_token_value;
	struct htmlparsertoken *next;
};

class HTMLControl {
	public:
		HTMLControl(iconvstream& is_,
				int& mode_,
				bool debug_scanner_,
				const char *file_name_) :
			mode(mode_),
			current_line(1),
			current_column(0),
			file_name(file_name_),
			literal_mode(false),
			document_start(true),
			next_tokens(NULL),
			debug_scanner(debug_scanner_),
			is(is_),
			number_of_ungotten_chars(0)
	{
	}

		void htmlparser_yyerror(const char *p);
		int htmlparser_yylex(
				html2text::HTMLParser::semantic_type *value_return);
		bool read_cdata(const char *terminal, string *value_return);
		int mode;
		int current_line;
		int current_column;
		const char *file_name;

	private:

		/*
		 * Helpers.
		 */
		int yylex2(html2text::HTMLParser::semantic_type *value_return,
				   int *tag_type_return);
		bool literal_mode;
		bool document_start;
		/* next_token, next_token_tag_type, next_token_value */
		struct htmlparsertoken *next_tokens;
		struct htmlparsertoken *get_nth_token(int id);
		void del_nth_token(int id);

		int get_char();
		void unget_char(int);

		bool debug_scanner;

		iconvstream &is;
		int ungotten_chars[5];
		int number_of_ungotten_chars;
};

#endif /* } */