4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Lars Gullik Bjønnes
8 * \author Angus Leeming
11 * Full author contact details are available in file CREDITS.
17 #include "OutputParams.h"
19 #include "support/docstring.h"
20 #include "support/FileName.h"
22 #include <boost/noncopyable.hpp>
23 #include <boost/signal.hpp>
40 Error () : error_in_line(0) {}
42 Error(int line, docstring const & desc, docstring const & text,
43 std::string const & fname)
44 : error_in_line(line),
48 /// what line in the TeX file the error occured in
52 /// The line/cmd that caused the error.
54 /// The name of the child where error occurred, empty otherwise.
55 std::string child_name;
59 typedef std::vector<Error> Errors;
61 Errors::const_iterator begin() const { return errors.begin(); }
63 Errors::const_iterator end() const { return errors.end(); }
65 void insertError(int line, docstring const & error_desc,
66 docstring const & error_text,
67 std::string const & child_name = empty_string());
79 support::FileName aux_file;
81 std::set<std::string> citations;
83 std::set<std::string> databases;
85 std::set<std::string> styles;
90 bool operator==(AuxInfo const &, AuxInfo const &);
91 bool operator!=(AuxInfo const &, AuxInfo const &);
95 * Class to run the LaTeX compiler and needed auxiliary programs.
96 * The main .tex file must be in the current directory. The current directory
97 * must not change as long as an object of this class lives.
98 * This is required by the LaTeX compiler, and we also make use of it by
99 * various support::makeAbsPath() calls.
101 class LaTeX : boost::noncopyable {
103 /** Return values from scanLogFile() and run() (to come)
105 This enum should be enlarged a bit so that one could
106 get more feedback from the LaTeX run.
116 UNDEF_REF = 4, // Reference '...' on page ... undefined.
118 UNDEF_CIT = 8, // Citation '...' on page ... undefined.
120 RERUN = 16, // Label(s) may have changed. Rerun to get...
130 PACKAGE_WARNING = 512,
136 TOO_MANY_ERRORS = 4096,
140 ERRORS = TEX_ERROR + LATEX_ERROR,
142 WARNINGS = TEX_WARNING + LATEX_WARNING + PACKAGE_WARNING
145 /// This signal emits an informative message
146 boost::signal<void(docstring)> message;
150 cmd = the latex command, file = name of the (temporary) latex file,
151 path = name of the files original path.
153 LaTeX(std::string const & cmd, OutputParams const &,
154 support::FileName const & file,
155 std::string const & path = empty_string());
157 /// runs LaTeX several times
158 int run(TeXErrors &);
161 int getNumErrors() { return num_errors;}
164 int scanLogFile(TeXErrors &);
167 /// use this for running LaTeX once
170 /// The dependency file.
171 support::FileName depfile;
174 void deplog(DepTable & head);
177 bool runMakeIndex(std::string const &, OutputParams const &,
178 std::string const & = std::string());
181 bool runMakeIndexNomencl(support::FileName const &,
182 std::string const &, std::string const &);
185 std::vector<AuxInfo> const scanAuxFiles(support::FileName const &);
188 AuxInfo const scanAuxFile(support::FileName const &);
191 void scanAuxFile(support::FileName const &, AuxInfo &);
194 void updateBibtexDependencies(DepTable &,
195 std::vector<AuxInfo> const &);
198 void scanBlgFile(DepTable & head);
201 bool runBibTeX(std::vector<AuxInfo> const &,
202 OutputParams const &);
205 void deleteFilesOnError() const;
211 support::FileName file;
216 /// used by scanLogFile
219 /// The name of the final output file.
220 support::FileName output_file;
223 OutputParams runparams;