4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
9 * Full author contact details are available in file CREDITS.
16 #include "OutputParams.h"
25 namespace support { class FileName; }
38 Converter(std::string const & f, std::string const & t, std::string const & c,
39 std::string const & l);
55 /// The converter is latex or its derivatives
57 /// The latex derivate
58 std::string latex_flavor;
59 /// The converter is xml
61 /// This converter needs the .aux files
63 /// we need a "nice" file from the backend, c.f. OutputParams.nice.
65 /// If the converter put the result in a directory, then result_dir
66 /// is the name of the directory
67 std::string result_dir;
68 /// If the converter put the result in a directory, then result_file
69 /// is the name of the main file in that directory
70 std::string result_file;
71 /// Command to convert the program output to a LaTeX log file format
80 typedef std::vector<Converter> ConverterList;
82 typedef ConverterList::const_iterator const_iterator;
85 Converter const & get(int i) const { return converterlist_[i]; }
87 Converter const * getConverter(std::string const & from,
88 std::string const & to) const;
90 int getNumber(std::string const & from, std::string const & to) const;
92 void add(std::string const & from, std::string const & to,
93 std::string const & command, std::string const & flags);
95 void erase(std::string const & from, std::string const & to);
97 std::vector<Format const *> const
98 getReachableTo(std::string const & target, bool clear_visited);
100 std::vector<Format const *> const
101 getReachable(std::string const & from, bool only_viewable,
103 std::set<std::string> const & excludes = std::set<std::string>());
105 std::vector<Format const *> importableFormats();
106 std::vector<Format const *> exportableFormats(bool only_viewable);
108 std::vector<std::string> loaders() const;
109 std::vector<std::string> savers() const;
111 /// Does a conversion path from format \p from to format \p to exist?
112 bool isReachable(std::string const & from, std::string const & to);
114 Graph::EdgePath getPath(std::string const & from, std::string const & to);
116 OutputParams::FLAVOR getFlavor(Graph::EdgePath const & path,
117 Buffer const * buffer = 0);
118 /// Flags for converting files
119 enum ConversionFlags {
122 /// Use the default converter if no converter is defined
123 try_default = 1 << 0,
124 /// Get the converted file from cache if possible
128 bool convert(Buffer const * buffer,
129 support::FileName const & from_file, support::FileName const & to_file,
130 support::FileName const & orig_from,
131 std::string const & from_format, std::string const & to_format,
132 ErrorList & errorList, int conversionflags = none);
134 void update(Formats const & formats);
136 void updateLast(Formats const & formats);
138 bool formatIsUsed(std::string const & format);
140 const_iterator begin() const { return converterlist_.begin(); }
142 const_iterator end() const { return converterlist_.end(); }
147 std::vector<Format const *> const
148 intToFormat(std::vector<int> const & input);
150 bool scanLog(Buffer const & buffer, std::string const & command,
151 support::FileName const & filename, ErrorList & errorList);
153 bool runLaTeX(Buffer const & buffer, std::string const & command,
154 OutputParams const &, ErrorList & errorList);
156 ConverterList converterlist_;
158 std::string latex_command_;
160 std::string dvilualatex_command_;
162 std::string lualatex_command_;
164 std::string pdflatex_command_;
166 std::string xelatex_command_;
167 /// If \p from = /path/file.ext and \p to = /path2/file2.ext2 then
168 /// this method moves each /path/file*.ext file to /path2/file2*.ext2
169 bool move(std::string const & fmt,
170 support::FileName const & from, support::FileName const & to,
176 /// The global instance.
177 /// Implementation is in LyX.cpp.
178 extern Converters & theConverters();
180 /// The global copy after reading lyxrc.defaults.
181 /// Implementation is in LyX.cpp.
182 extern Converters & theSystemConverters();