Consider the case where there is not any layout name.
[lyx.git] / src / LaTeX.h
blobc7d51e92a6e86529d5a2d3ce428772dcb254ddd1
1 // -*- C++ -*-
2 /**
3 * \file LaTeX.h
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
9 * \author Dekel Tsur
11 * Full author contact details are available in file CREDITS.
14 #ifndef LATEX_H
15 #define LATEX_H
17 #include "outputparams.h"
19 #include <boost/utility.hpp>
20 #include <boost/signal.hpp>
22 #include <vector>
23 #include <set>
25 class DepTable;
27 ///
28 class TeXErrors {
29 private:
30 ///
31 class Error {
32 public:
33 ///
34 Error () : error_in_line(0) {}
35 ///
36 Error(int line, std::string const & desc, std::string const & text)
37 : error_in_line(line),
38 error_desc(desc),
39 error_text(text) {}
40 /// what line in the TeX file the error occured in
41 int error_in_line;
42 /// The kind of error
43 std::string error_desc;
44 /// The line/cmd that caused the error.
45 std::string error_text;
47 public:
48 ///
49 typedef std::vector<Error> Errors;
50 ///
51 Errors::const_iterator begin() const { return errors.begin(); }
52 ///
53 Errors::const_iterator end() const { return errors.end(); }
54 ///
55 void insertError(int line, std::string const & error_desc,
56 std::string const & error_text);
57 private:
58 ///
59 Errors errors;
63 class Aux_Info {
64 public:
65 ///
66 Aux_Info() {}
67 ///
68 std::string aux_file;
69 ///
70 std::set<std::string> citations;
71 ///
72 std::set<std::string> databases;
73 ///
74 std::set<std::string> styles;
78 ///
79 bool operator==(Aux_Info const &, Aux_Info const &);
80 bool operator!=(Aux_Info const &, Aux_Info const &);
83 ///
84 class LaTeX : boost::noncopyable {
85 public:
86 /** Return values from scanLogFile() and run() (to come)
88 This enum should be enlarged a bit so that one could
89 get more feedback from the LaTeX run.
91 enum log_status {
92 ///
93 NO_ERRORS = 0,
94 ///
95 NO_LOGFILE = 1,
96 ///
97 NO_OUTPUT = 2,
98 ///
99 UNDEF_REF = 4, // Reference '...' on page ... undefined.
101 UNDEF_CIT = 8, // Citation '...' on page ... undefined.
103 RERUN = 16, // Label(s) may have changed. Rerun to get...
105 TEX_ERROR = 32,
107 TEX_WARNING = 64,
109 LATEX_ERROR = 128,
111 LATEX_WARNING = 256,
113 PACKAGE_WARNING = 512,
115 NO_FILE = 1024,
117 NO_CHANGE = 2048,
119 TOO_MANY_ERRORS = 4096,
121 ERROR_RERUN = 8192,
123 ERRORS = TEX_ERROR + LATEX_ERROR,
125 WARNINGS = TEX_WARNING + LATEX_WARNING + PACKAGE_WARNING
128 /// This signal emits an informative message
129 boost::signal<void(std::string)> message;
133 cmd = the latex command, file = name of the (temporary) latex file,
134 path = name of the files original path.
136 LaTeX(std::string const & cmd, OutputParams const &,
137 std::string const & file, std::string const & path);
139 /// runs LaTeX several times
140 int run(TeXErrors &);
143 int getNumErrors() { return num_errors;}
146 int scanLogFile(TeXErrors &);
148 private:
149 /// use this for running LaTeX once
150 int startscript();
152 /// The dependency file.
153 std::string depfile;
156 void deplog(DepTable & head);
159 bool runMakeIndex(std::string const &, OutputParams const &);
162 std::vector<Aux_Info> const scanAuxFiles(std::string const &);
165 Aux_Info const scanAuxFile(std::string const &);
168 void scanAuxFile(std::string const &, Aux_Info &);
171 void updateBibtexDependencies(DepTable &,
172 std::vector<Aux_Info> const &);
175 bool runBibTeX(std::vector<Aux_Info> const &);
178 void deleteFilesOnError() const;
181 std::string cmd;
184 std::string file;
187 std::string path;
189 /// used by scanLogFile
190 int num_errors;
192 /// The name of the final output file.
193 std::string output_file;
196 OutputParams runparams;
199 #endif