]> git.lyx.org Git - lyx.git/blob - src/lyxlex_pimpl.h
Updates from Bennett and myself.
[lyx.git] / src / lyxlex_pimpl.h
1 // -*- C++ -*-
2 /**
3  * \file lyxlex_pimpl.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Lars Gullik Bjønnes
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef LYXLEX_PIMPL_H
13 #define LYXLEX_PIMPL_H
14
15 #include "lyxlex.h"
16
17 #include "support/types.h"
18
19 # include <boost/iostreams/filtering_streambuf.hpp>
20 # include <boost/iostreams/filter/gzip.hpp>
21 # include <boost/iostreams/device/file.hpp>
22 namespace io = boost::iostreams;
23
24 #include <boost/utility.hpp>
25
26 #include <fstream>
27 #include <istream>
28 #include <stack>
29 #include <vector>
30
31
32 namespace lyx {
33
34 namespace support { class FileName; }
35
36 ///
37 class LyXLex::Pimpl : boost::noncopyable {
38 public:
39         ///
40         Pimpl(keyword_item * tab, int num);
41         ///
42         std::string const getString() const;
43         ///
44         docstring const getDocString() const;
45         ///
46         void printError(std::string const & message) const;
47         ///
48         void printTable(std::ostream & os);
49         ///
50         void pushTable(keyword_item * tab, int num);
51         ///
52         void popTable();
53         ///
54         bool setFile(support::FileName const & filename);
55         ///
56         void setStream(std::istream & i);
57         ///
58         void setCommentChar(char c);
59         ///
60         bool next(bool esc = false);
61         ///
62         int search_kw(char const * const tag) const;
63         ///
64         int lex();
65         ///
66         bool eatLine();
67         ///
68         bool nextToken();
69         ///
70         void pushToken(std::string const &);
71         /// fb_ is only used to open files, the stream is accessed through is.
72         std::filebuf fb_;
73
74         /// gz_ is only used to open files, the stream is accessed through is.
75         io::filtering_istreambuf gz_;
76
77         /// the stream that we use.
78         std::istream is;
79         ///
80         std::string name;
81         ///
82         keyword_item * table;
83         ///
84         int no_items;
85         ///
86         std::string buff;
87         ///
88         int status;
89         ///
90         int lineno;
91         ///
92         std::string pushTok;
93         ///
94         char commentChar;
95 private:
96         ///
97         void verifyTable();
98         ///
99         class pushed_table {
100         public:
101                 ///
102                 pushed_table()
103                         : table_elem(0), table_siz(0) {}
104                 ///
105                 pushed_table(keyword_item * ki, int siz)
106                         : table_elem(ki), table_siz(siz) {}
107                 ///
108                 keyword_item * table_elem;
109                 ///
110                 int table_siz;
111         };
112         ///
113         std::stack<pushed_table> pushed;
114 };
115
116 } // namespace lyx
117
118 #endif