]> git.lyx.org Git - lyx.git/blob - src/LaTeX.h
377b962d99940afae17d796cd6a12ee40ee70949
[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-2000 The Lyx Team
8  *
9  *           This file is Copyright 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
26 #include <boost/utility.hpp>
27
28 class MiniBuffer;
29
30 ///
31 class TeXErrors {
32 private:
33         ///
34         struct Error {
35                 ///
36                 Error () : error_in_line(0) {}
37                 ///
38                 Error(int line, string const & desc, string const & text)
39                         : error_in_line(line),
40                           error_desc(desc),
41                           error_text(text) {}
42                 /// what line in the TeX file the error occured in
43                 int error_in_line;
44                 /// The kind of error
45                 string error_desc;
46                 /// The line/cmd that caused the error.
47                 string error_text;
48         };
49 public:
50         ///
51         typedef std::vector<Error> Errors;
52         ///
53         Errors::const_iterator begin() const { return errors.begin(); }
54         ///
55         Errors::const_iterator end() const { return errors.end(); }
56         ///
57         void insertError(int line, string const & error_desc,
58                          string const & error_text);
59 private:
60         ///
61         Errors errors;
62 };
63
64
65 ///
66 class LaTeX : public noncopyable {
67 public:
68         /** Return values from scanLogFile() and run() (to come)
69             
70             This enum should be enlarged a bit so that one could
71             get more feedback from the LaTeX run.
72         */
73         enum log_status {
74                 ///
75                 NO_ERRORS = 0,
76                 ///
77                 NO_LOGFILE = 1,
78                 ///
79                 NO_OUTPUT = 2,
80                 ///
81                 UNDEF_REF = 4, // Reference '...' on page ... undefined.
82                 ///
83                 UNDEF_CIT = 8, // Citation '...' on page ... undefined.
84                 ///
85                 RERUN = 16, // Label(s) may have changed. Rerun to get...
86                 ///
87                 TEX_ERROR = 32,
88                 ///
89                 TEX_WARNING = 64,
90                 ///
91                 LATEX_ERROR = 128,
92                 ///
93                 LATEX_WARNING = 256,
94                 ///
95                 PACKAGE_WARNING = 512,
96                 ///
97                 NO_FILE = 1024,
98                 ///
99                 NO_CHANGE = 2048,
100                 ///
101                 TOO_MANY_ERRORS = 4096,
102                 ///
103                 ERRORS = TEX_ERROR + LATEX_ERROR,
104                 ///
105                 WARNINGS = TEX_WARNING + LATEX_WARNING + PACKAGE_WARNING
106         };
107         
108
109         /**
110            cmd = the latex command, file = name of the (temporary) latex file,
111            path = name of the files original path.
112         */
113         LaTeX(string const & cmd, string const & file, string const & path);
114
115         ///
116         virtual ~LaTeX() {}
117         
118         /// runs LaTeX several times
119         int run(TeXErrors &, MiniBuffer *);
120
121         ///
122         int getNumErrors() { return num_errors;}
123
124         /// use this for running LaTeX once
125         int operator() ();
126
127         ///
128         int scanLogFile(TeXErrors &);
129
130 protected:
131         /// The dependency file.
132         string depfile;
133
134         ///
135         void deplog(DepTable & head);
136
137         ///
138         bool runMakeIndex(string const &);
139
140         ///
141         bool scanAux(DepTable &);
142         ///
143         vector<string> const
144         scanAuxFiles(string const &, DepTable &, bool);
145         ///
146         bool scanAuxFile(string const &, DepTable &, bool);
147         
148         ///
149         bool runBibTeX(DepTable &);
150
151         ///
152         void deleteFilesOnError() const;
153         
154         ///
155         string cmd;
156
157         ///
158         string file;
159         
160         ///
161         string path;
162
163         /// used by scanLogFile
164         int num_errors;
165 };
166
167 #endif