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 // use the compare_ascii_no_case instead of compare_no_case,
81 // because in turkish, 'i' is not the lowercase version of 'I',
82 // and thus turkish locale breaks parsing of tags.
84 return compare_ascii_no_case(a.prettyname(), b.prettyname()) < 0;
92 typedef std::vector<Format> FormatList;
94 typedef FormatList::const_iterator const_iterator;
96 Format const & get(FormatList::size_type i) const {
100 Format const * getFormat(string const & name) const;
102 int getNumber(string const & name) const;
104 void add(string const & name);
106 void add(string const & name, string const & extension,
107 string const & prettyname, string const & shortcut);
109 void erase(string const & name);
113 void setViewer(string const & name, string const & command);
115 bool view(Buffer const * buffer, string const & filename,
116 string const & format_name) const;
118 string const prettyName(string const & name) const;
120 string const extension(string const & name) const;
122 const_iterator begin() const {
123 return formatlist.begin();
126 const_iterator end() const {
127 return formatlist.end();
130 FormatList::size_type size() const {
131 return formatlist.size();
135 FormatList formatlist;
138 ///////////////////////////////////////////////////////////////////////
144 Converter(string const & f, string const & t, string const & c,
146 : from(f), to(t), command(c), flags(l), From(0), To(0),
147 latex(false), original_dir(false), need_aux(false) {}
163 /// The converter is latex or its derivatives
165 /// Do we need to run the converter in the original directory?
167 /// This converter needs the .aux files
169 /// If the converter put the result in a directory, then result_dir
170 /// is the name of the directory
172 /// If the converter put the result in a directory, then result_file
173 /// is the name of the main file in that directory
175 /// Command to convert the program output to a LaTeX log file format
183 typedef std::vector<Converter> ConverterList;
185 typedef ConverterList::const_iterator const_iterator;
187 typedef std::vector<int> EdgePath;
189 Converter const & get(int i) const {
190 return converterlist_[i];
193 Converter const * getConverter(string const & from, string const & to);
195 int getNumber(string const & from, string const & to);
197 void add(string const & from, string const & to,
198 string const & command, string const & flags);
200 void erase(string const & from, string const & to);
204 std::vector<Format const *> const
205 getReachableTo(string const & target, bool clear_visited);
207 std::vector<Format const *> const
208 getReachable(string const & from, bool only_viewable,
211 bool isReachable(string const & from, string const & to);
213 EdgePath const getPath(string const & from, string const & to);
215 bool usePdflatex(EdgePath const & path);
217 bool convert(Buffer const * buffer,
218 string const & from_file, string const & to_file_base,
219 string const & from_format, string const & to_format,
222 bool convert(Buffer const * buffer,
223 string const & from_file, string const & to_file_base,
224 string const & from_format, string const & to_format);
226 string const papersize(Buffer const * buffer);
228 string const dvips_options(Buffer const * buffer);
230 string const dvipdfm_options(Buffer const * buffer);
232 void update(Formats const & formats);
234 void updateLast(Formats const & formats);
238 bool formatIsUsed(string const & format);
240 const_iterator begin() const {
241 return converterlist_.begin();
243 const_iterator end() const {
244 return converterlist_.end();
248 bool scanLog(Buffer const * buffer, string const & command,
249 string const & filename);
251 bool runLaTeX(Buffer const * buffer, string const & command);
253 ConverterList converterlist_;
255 string latex_command_;
258 std::vector<int> in_vertices;
259 std::vector<int> out_vertices;
260 std::vector<int> out_edges;
264 std::vector<Vertex> vertices_;
266 std::vector<bool> visited_;
270 int bfs_init(string const & start, bool clear_visited = true);
272 bool move(string const & from, string const & to, bool copy);
275 extern Formats formats;
276 extern Converters converters;
278 extern Formats system_formats;
279 extern Converters system_converters;