]> git.lyx.org Git - lyx.git/blob - src/converter.h
Point fix, earlier forgotten
[lyx.git] / src / converter.h
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.
6  *
7  * \author Dekel Tsur
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef CONVERTER_H
13 #define CONVERTER_H
14
15 #include "latexrunparams.h"
16 #include "graph.h"
17
18 #include <vector>
19
20 class Format;
21 class Formats;
22
23 class Buffer;
24
25 ///
26 class Converter {
27 public:
28         ///
29         Converter(string const & f, string const & t, string const & c,
30                   string const & l);
31         ///
32         void readFlags();
33         ///
34         string from;
35         ///
36         string to;
37         ///
38         string command;
39         ///
40         string flags;
41         ///
42         Format const * From;
43         ///
44         Format const * To;
45
46         /// The converter is latex or its derivatives
47         bool latex;
48         /// Do we need to run the converter in the original directory?
49         bool original_dir;
50         /// This converter needs the .aux files
51         bool need_aux;
52         /// If the converter put the result in a directory, then result_dir
53         /// is the name of the directory
54         string result_dir;
55         /// If the converter put the result in a directory, then result_file
56         /// is the name of the main file in that directory
57         string result_file;
58         /// Command to convert the program output to a LaTeX log file format
59         string parselog;
60 };
61
62
63 ///
64 class Converters {
65 public:
66         ///
67         typedef std::vector<int> EdgePath; // to be removed SOON
68         ///
69         typedef std::vector<Converter> ConverterList;
70         ///
71         typedef ConverterList::const_iterator const_iterator;
72         ///
73         Converter const & get(int i) const {
74                 return converterlist_[i];
75         }
76         ///
77         Converter const * getConverter(string const & from, string const & to);
78         ///
79         int getNumber(string const & from, string const & to);
80         ///
81         void add(string const & from, string const & to,
82                  string const & command, string const & flags);
83         //
84         void erase(string const & from, string const & to);
85         ///
86         void sort();
87         ///
88         std::vector<Format const *> const
89         getReachableTo(string const & target, bool clear_visited);
90         ///
91         std::vector<Format const *> const
92         getReachable(string const & from, bool only_viewable,
93                      bool clear_visited);
94         ///
95         bool isReachable(string const & from, string const & to);
96         ///
97         Graph::EdgePath const getPath(string const & from, string const & to);
98         ///
99         bool usePdflatex(Graph::EdgePath const & path);
100         ///
101         bool convert(Buffer const * buffer,
102                      string const & from_file, string const & to_file_base,
103                      string const & from_format, string const & to_format,
104                      string & to_file);
105         ///
106         bool convert(Buffer const * buffer,
107                      string const & from_file, string const & to_file_base,
108                      string const & from_format, string const & to_format);
109         ///
110         void update(Formats const & formats);
111         ///
112         void updateLast(Formats const & formats);
113         ///
114         bool formatIsUsed(string const & format);
115         ///
116         const_iterator begin() const {
117                 return converterlist_.begin();
118         }
119         const_iterator end() const {
120                 return converterlist_.end();
121         }
122         ///
123         void buildGraph();
124 private:
125         ///
126         std::vector<Format const *> const
127         Converters::intToFormat(std::vector<int> const & input);
128         ///
129         bool scanLog(Buffer const & buffer, string const & command,
130                      string const & filename);
131         ///
132         bool runLaTeX(Buffer const & buffer, string const & command,
133                       LatexRunParams const &);
134         ///
135         ConverterList converterlist_;
136         ///
137         string latex_command_;
138         ///
139         bool move(string const & from, string const & to, bool copy);
140         ///
141         Graph G_;
142 };
143
144 extern Converters converters;
145
146 extern Converters system_converters;
147
148 #endif //CONVERTER_H