]> git.lyx.org Git - lyx.git/blob - src/LaTeX.h
white-space changes, removed definitions.h several enum changes because of this,...
[lyx.git] / src / LaTeX.h
1 // -*- C++ -*-
2 /* This file is part of
3  * ====================================================== 
4  * 
5  *           LyX, The Document Processor         
6  *           Copyright 1995 Matthias Ettrich
7  *           Copyright 1995-1996 The Lyx Team
8  *
9  *           This file is Copyright (C) 1996-1999
10  *           Lars Gullik Bjønnes
11  *
12  * ====================================================== 
13  */
14
15 #ifndef LATEX_H
16 #define LATEX_H
17
18 #ifdef __GNUG__
19 #pragma interface
20 #endif
21
22 #include "LString.h"
23 #include "DepTable.h"
24 #include <vector>
25 using std::vector;
26
27 #include <fstream>
28 using std::ifstream;
29 using std::ofstream;
30
31 class MiniBuffer;
32
33 ///
34 class TeXErrors {
35 private:
36         ///
37         struct Error {
38                 ///
39                 Error () : error_in_line(0) {}
40                 ///
41                 Error(int line, string const & desc, string const & text)
42                         : error_in_line(line),
43                           error_desc(desc),
44                           error_text(text) {}
45                 /// what line in the TeX file the error occured in
46                 int error_in_line;
47                 /// The kind of error
48                 string error_desc;
49                 /// The line/cmd that caused the error.
50                 string error_text;
51         };
52 public:
53         ///
54         typedef vector<Error> Errors;
55         ///
56         Errors::const_iterator begin() const { return errors.begin(); }
57         ///
58         Errors::const_iterator end() const { return errors.end(); }
59         ///
60         void insertError(int line, string const & error_desc,
61                          string const & error_text);
62 private:
63         ///
64         Errors errors;
65 };
66
67
68 ///
69 class LaTeX {
70 public:
71         /** All the different files produced by TeX.
72             
73             This is the files mentioned on page 208-9 in Lamports book +
74             .ltx and .tex files.
75         */
76         enum TEX_FILES {
77                 ///
78                 NO_FILES = 0,
79                 /// used for table of contents et.al.
80                 AUX = 1,
81                 /// written by BibTeX
82                 BBL = 2,
83                 /// LaTeX's output
84                 DVI = 4,
85                 /// glossary (not supported by LyX so far)
86                 GLO = 8,
87                 ///index
88                 IDX = 16,
89                 /// written by makeindex
90                 IND = 32,
91                 /// list of figures
92                 LOF = 64,
93                 /// the LaTeX log file
94                 LOG = 128,
95                 /// list of tables
96                 LOT = 256,
97                 /// table of contents
98                 TOC = 512,
99                 /// latex files
100                 LTX = 1024,
101                 /// tex files
102                 TEX = 2048,
103                 /// list of algorithms
104                 LOA = 4096
105         };
106         
107         /** Return values from scanLogFile() and run() (to come)
108
109           This enum should be enlarged a bit so that one could
110           get more feedback from the LaTeX run.
111           */
112         enum log_status {
113                 ///
114                 NO_ERRORS = 0,
115                 ///
116                 NO_LOGFILE = 1,
117                 ///
118                 NO_OUTPUT = 2,
119                 ///
120                 UNDEF_REF = 4, // Reference '...' on page ... undefined.
121                 ///
122                 UNDEF_CIT = 8, // Citation '...' on page ... undefined.
123                 ///
124                 RERUN = 16, // Label(s) may have changed. Rerun to get...
125                 ///
126                 TEX_ERROR = 32,
127                 ///
128                 TEX_WARNING = 64,
129                 ///
130                 LATEX_ERROR = 128,
131                 ///
132                 LATEX_WARNING = 256,
133                 ///
134                 PACKAGE_WARNING = 512,
135                 ///
136                 NO_FILE = 1024,
137                 ///
138                 NO_CHANGE = 2048,
139                 ///
140                 TOO_MANY_ERRORS = 4096,
141                 ///
142                 ERRORS = TEX_ERROR + LATEX_ERROR,
143                 ///
144                 WARNINGS = TEX_WARNING + LATEX_WARNING + PACKAGE_WARNING
145         };
146         
147
148         /**
149            cmd = the latex command, file = name of the (temporary) latex file,
150            path = name of the files original path.
151         */
152         LaTeX(string const & cmd, string const & file, string const & path);
153         
154         /// runs LaTeX several times
155         int run(TeXErrors &, MiniBuffer *);
156
157         ///
158         int getNumErrors() { return num_errors;}
159
160         /// use this for running LaTeX once
161         int operator() ();
162 protected:
163         /// The dependency file.
164         string depfile;
165
166         /// unavail
167         LaTeX(LaTeX const &);
168         /// unavail
169         LaTeX & operator= (LaTeX const &);
170         
171         ///
172         void deplog(DepTable & head);
173
174         ///
175         void deptex(DepTable & head);
176         
177         ///
178         int scanLogFile(TeXErrors &);
179
180         ///
181         bool runMakeIndex(string const &);
182
183         ///
184         bool runBibTeX(string const &, DepTable &);
185         
186         ///
187         string cmd;
188
189         ///
190         string file;
191         
192         ///
193         string path;
194         ///
195         TEX_FILES tex_files;
196         
197         ///
198         int file_count;
199
200         // used by scanLogFile
201         int num_errors;
202 };
203
204 #endif