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 BIBTEX_ERROR = 16384,
142 ERRORS = TEX_ERROR + LATEX_ERROR + BIBTEX_ERROR,
144 WARNINGS = TEX_WARNING + LATEX_WARNING + PACKAGE_WARNING
147 /// This signal emits an informative message
148 boost::signal<void(docstring)> message;
152 cmd = the latex command, file = name of the (temporary) latex file,
153 path = name of the files original path.
155 LaTeX(std::string const & cmd, OutputParams const &,
156 support::FileName const & file,
157 std::string const & path = empty_string());
159 /// runs LaTeX several times
160 int run(TeXErrors &);
163 int getNumErrors() { return num_errors;}
166 int scanLogFile(TeXErrors &);
169 /// use this for running LaTeX once
172 /// The dependency file.
173 support::FileName depfile;
176 void deplog(DepTable & head);
179 bool runMakeIndex(std::string const &, OutputParams const &,
180 std::string const & = std::string());
183 bool runMakeIndexNomencl(support::FileName const &,
184 std::string const &, std::string const &);
187 std::vector<AuxInfo> const scanAuxFiles(support::FileName const &);
190 AuxInfo const scanAuxFile(support::FileName const &);
193 void scanAuxFile(support::FileName const &, AuxInfo &);
196 void updateBibtexDependencies(DepTable &,
197 std::vector<AuxInfo> const &);
200 int scanBlgFile(DepTable & head, TeXErrors & terr);
203 bool runBibTeX(std::vector<AuxInfo> const &,
204 OutputParams const &);
207 void deleteFilesOnError() const;
213 support::FileName file;
218 /// used by scanLogFile
221 /// The name of the final output file.
222 support::FileName output_file;
225 OutputParams runparams;