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