2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 1995 Matthias Ettrich
8 * Copyright 1995-2001 The LyX Team.
10 * ====================================================== */
22 #include "support/lstrings.h"
30 Format(string const & n, string const & e, string const & p,
31 string const & s, string const & v) :
32 name_(n), extension_(e), prettyname_(p), shortcut_(s),
37 bool IsChildFormat() const;
39 string const ParentFormat() const;
41 string const & name() const {
45 string const & extension() const {
49 string const & prettyname() const {
53 string const & shortcut() const {
57 string const & viewer() const {
61 void setViewer(string const & v) {
78 bool operator<(Format const & a, Format const & b)
80 return compare_no_case(a.prettyname(),b.prettyname()) < 0;
88 typedef std::vector<Format> FormatList;
90 typedef FormatList::const_iterator const_iterator;
92 Format const & Get(FormatList::size_type i) const {
96 Format const * GetFormat(string const & name) const;
98 int GetNumber(string const & name) const;
100 void Add(string const & name);
102 void Add(string const & name, string const & extension,
103 string const & prettyname, string const & shortcut);
105 void Delete(string const & name);
109 void SetViewer(string const & name, string const & command);
111 bool View(Buffer const * buffer, string const & filename,
112 string const & format_name) const;
114 string const PrettyName(string const & name) const;
116 string const Extension(string const & name) const;
118 const_iterator begin() const {
119 return formatlist.begin();
122 const_iterator end() const {
123 return formatlist.end();
126 FormatList::size_type size() const {
127 return formatlist.size();
131 FormatList formatlist;
134 ///////////////////////////////////////////////////////////////////////
140 Converter(string const & f, string const & t, string const & c,
142 : from(f), to(t), command(c), flags(l), From(0), To(0),
143 latex(false), original_dir(false), need_aux(false) {}
159 /// The converter is latex or its derivatives
161 /// Do we need to run the converter in the original directory?
163 /// This converter needs the .aux files
165 /// If the converter put the result in a directory, then result_dir
166 /// is the name of the directory
168 /// If the converter put the result in a directory, then result_file
169 /// is the name of the main file in that directory
171 /// Command to convert the program output to a LaTeX log file format
179 typedef std::vector<Converter> ConverterList;
181 typedef ConverterList::const_iterator const_iterator;
183 typedef std::vector<int> EdgePath;
185 Converter const & Get(int i) const {
186 return converterlist[i];
189 Converter const * GetConverter(string const & from, string const & to);
191 int GetNumber(string const & from, string const & to);
193 void Add(string const & from, string const & to,
194 string const & command, string const & flags);
196 void Delete(string const & from, string const & to);
200 std::vector<Format const *> const
201 GetReachableTo(string const & target, bool clear_visited);
203 std::vector<Format const *> const
204 GetReachable(string const & from, bool only_viewable,
207 bool IsReachable(string const & from, string const & to);
209 EdgePath const GetPath(string const & from, string const & to);
211 bool UsePdflatex(EdgePath const & path);
213 bool Convert(Buffer const * buffer,
214 string const & from_file, string const & to_file_base,
215 string const & from_format, string const & to_format,
218 bool Convert(Buffer const * buffer,
219 string const & from_file, string const & to_file_base,
220 string const & from_format, string const & to_format);
222 string const papersize(Buffer const * buffer);
224 string const dvips_options(Buffer const * buffer);
226 string const dvipdfm_options(Buffer const * buffer);
228 void Update(Formats const & formats);
230 void UpdateLast(Formats const & formats);
234 bool FormatIsUsed(string const & format);
236 const_iterator begin() const {
237 return converterlist.begin();
239 const_iterator end() const {
240 return converterlist.end();
244 bool scanLog(Buffer const * buffer, string const & command,
245 string const & filename);
247 bool runLaTeX(Buffer const * buffer, string const & command);
249 ConverterList converterlist;
251 string latex_command;
254 std::vector<int> in_vertices;
255 std::vector<int> out_vertices;
256 std::vector<int> out_edges;
260 std::vector<Vertex> vertices;
262 std::vector<bool> visited;
266 int BFS_init(string const & start, bool clear_visited = true);
268 bool Move(string const & from, string const & to, bool copy);
271 extern Formats formats;
272 extern Converters converters;
274 extern Formats system_formats;
275 extern Converters system_converters;