2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 1995 Matthias Ettrich
8 * Copyright 1995-2000 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) {
64 friend bool operator<(Format const & a, Format const & b) {
65 return compare_no_case(a.prettyname(),b.prettyname()) < 0;
84 typedef std::vector<Format> FormatList;
86 typedef FormatList::const_iterator const_iterator;
88 Format const & Get(int i) const {
92 Format const * GetFormat(string const & name) const;
94 int GetNumber(string const & name) const;
96 void Add(string const & name);
98 void Add(string const & name, string const & extension,
99 string const & prettyname, string const & shortcut);
101 void Delete(string const & name);
105 void SetViewer(string const & name, string const & command);
107 bool View(Buffer const * buffer, string const & filename,
108 string const & format_name) const;
110 string const PrettyName(string const & name) const;
112 string const Extension(string const & name) const;
114 const_iterator begin() const {
115 return formatlist.begin();
118 const_iterator end() const {
119 return formatlist.end();
122 FormatList::size_type size() const {
123 return formatlist.size();
127 FormatList formatlist;
130 ///////////////////////////////////////////////////////////////////////
136 Converter(string const & f, string const & t, string const & c,
138 : from(f), to(t), command(c), flags(l), From(0), To(0),
139 latex(false), original_dir(false), need_aux(false) {}
155 /// The converter is latex or its derivatives
157 /// Do we need to run the converter in the original directory?
159 /// This converter needs the .aux files
161 /// If the converter put the result in a directory, then result_dir
162 /// is the name of the directory
164 /// If the converter put the result in a directory, then result_file
165 /// is the name of the main file in that directory
167 /// Command to convert the program output to a LaTeX log file format
175 typedef std::vector<Converter> ConverterList;
177 typedef ConverterList::const_iterator const_iterator;
179 typedef std::vector<int> EdgePath;
181 Converter const & Get(int i) const {
182 return converterlist[i];
185 Converter const * GetConverter(string const & from, string const & to);
187 int GetNumber(string const & from, string const & to);
189 void Add(string const & from, string const & to,
190 string const & command, string const & flags);
192 void Delete(string const & from, string const & to);
196 std::vector<Format const *> const
197 GetReachableTo(string const & target, bool clear_visited);
199 std::vector<Format const *> const
200 GetReachable(string const & from, bool only_viewable,
203 bool IsReachable(string const & from, string const & to);
205 EdgePath const GetPath(string const & from, string const & to);
207 bool UsePdflatex(EdgePath const & path);
209 bool Convert(Buffer const * buffer,
210 string const & from_file, string const & to_file_base,
211 string const & from_format, string const & to_format,
214 bool Convert(Buffer const * buffer,
215 string const & from_file, string const & to_file_base,
216 string const & from_format, string const & to_format);
218 string const dvi_papersize(Buffer const * buffer);
220 string const dvips_options(Buffer const * buffer);
222 void Update(Formats const & formats);
224 void UpdateLast(Formats const & formats);
228 bool FormatIsUsed(string const & format);
230 const_iterator begin() const {
231 return converterlist.begin();
233 const_iterator end() const {
234 return converterlist.end();
238 bool scanLog(Buffer const * buffer, string const & command,
239 string const & filename);
241 bool runLaTeX(Buffer const * buffer, string const & command);
243 ConverterList converterlist;
245 string latex_command;
248 std::vector<int> in_vertices;
249 std::vector<int> out_vertices;
250 std::vector<int> out_edges;
254 std::vector<Vertex> vertices;
256 std::vector<bool> visited;
260 int BFS_init(string const & start, bool clear_visited = true);
262 bool Move(string const & from, string const & to, bool copy);
265 extern Formats formats;
266 extern Converters converters;
268 extern Formats system_formats;
269 extern Converters system_converters;