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 erase(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 erase(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;