replace most &dquot;...&dquot; by <...>
[lyx.git] / src / converter.h
blobce290766fce7975155932cc9959ab65fd65d4e8c
1 // -*- C++ -*-
2 /**
3 * \file converter.h
4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Dekel Tsur
9 * Full author contact details are available in file CREDITS.
12 #ifndef CONVERTER_H
13 #define CONVERTER_H
15 #include "graph.h"
16 #include "outputparams.h"
18 #include <vector>
19 #include <string>
22 class Buffer;
23 class Format;
24 class Formats;
25 class OutputParams;
28 ///
29 class Converter {
30 public:
31 ///
32 Converter(std::string const & f, std::string const & t, std::string const & c,
33 std::string const & l);
34 ///
35 void readFlags();
36 ///
37 std::string from;
38 ///
39 std::string to;
40 ///
41 std::string command;
42 ///
43 std::string flags;
44 ///
45 Format const * From;
46 ///
47 Format const * To;
49 /// The converter is latex or its derivatives
50 bool latex;
51 /// The converter is xml
52 bool xml;
53 /// Do we need to run the converter in the original directory?
54 bool original_dir;
55 /// This converter needs the .aux files
56 bool need_aux;
57 /// If the converter put the result in a directory, then result_dir
58 /// is the name of the directory
59 std::string result_dir;
60 /// If the converter put the result in a directory, then result_file
61 /// is the name of the main file in that directory
62 std::string result_file;
63 /// Command to convert the program output to a LaTeX log file format
64 std::string parselog;
68 ///
69 class Converters {
70 public:
71 ///
72 typedef std::vector<int> EdgePath; // to be removed SOON
73 ///
74 typedef std::vector<Converter> ConverterList;
75 ///
76 typedef ConverterList::const_iterator const_iterator;
77 ///
78 Converter const & get(int i) const {
79 return converterlist_[i];
81 ///
82 Converter const * getConverter(std::string const & from,
83 std::string const & to) const;
84 ///
85 int getNumber(std::string const & from, std::string const & to) const;
86 ///
87 void add(std::string const & from, std::string const & to,
88 std::string const & command, std::string const & flags);
90 void erase(std::string const & from, std::string const & to);
91 ///
92 void sort();
93 ///
94 std::vector<Format const *> const
95 getReachableTo(std::string const & target, bool clear_visited);
96 ///
97 std::vector<Format const *> const
98 getReachable(std::string const & from, bool only_viewable,
99 bool clear_visited);
101 bool isReachable(std::string const & from, std::string const & to);
103 Graph::EdgePath const getPath(std::string const & from, std::string const & to);
105 OutputParams::FLAVOR getFlavor(Graph::EdgePath const & path);
107 bool convert(Buffer const * buffer,
108 std::string const & from_file, std::string const & to_file_base,
109 std::string const & from_format, std::string const & to_format,
110 std::string & to_file);
112 bool convert(Buffer const * buffer,
113 std::string const & from_file, std::string const & to_file_base,
114 std::string const & from_format, std::string const & to_format);
116 void update(Formats const & formats);
118 void updateLast(Formats const & formats);
120 bool formatIsUsed(std::string const & format);
122 const_iterator begin() const {
123 return converterlist_.begin();
125 const_iterator end() const {
126 return converterlist_.end();
129 void buildGraph();
130 private:
132 std::vector<Format const *> const
133 intToFormat(std::vector<int> const & input);
135 bool scanLog(Buffer const & buffer, std::string const & command,
136 std::string const & filename);
138 bool runLaTeX(Buffer const & buffer, std::string const & command,
139 OutputParams const &);
141 ConverterList converterlist_;
143 std::string latex_command_;
145 bool move(std::string const & fmt,
146 std::string const & from, std::string const & to,
147 bool copy);
149 Graph G_;
152 extern Converters converters;
154 extern Converters system_converters;
156 #endif //CONVERTER_H