]> git.lyx.org Git - lyx.git/blob - src/converter.h
02588fee2b4cf3b004f38366561ae8f3e29cff9d
[lyx.git] / src / converter.h
1 // -*- C++ -*-
2 /* This file is part of
3  * ====================================================== 
4  * 
5  *           LyX, The Document Processor
6  *        
7  *           Copyright 1995 Matthias Ettrich
8  *           Copyright 1995-2000 The LyX Team.
9  *
10  * ====================================================== */
11
12 #ifndef CONVERTER_H
13 #define CONVERTER_H
14
15 #ifdef __GNUG__
16 #pragma interface
17 #endif
18
19 #include <map>
20 #include <vector>
21 #include "LString.h"
22
23 class Buffer;
24
25 struct Command {
26         Command(string const & f, string const & t, string const & c,
27                 bool o)
28                 : from(f), to(t), command(c), original_dir(o) {}
29         ///
30         string from;
31         ///
32         string to;
33         ///
34         string command;
35         ///
36         bool original_dir;
37         ///
38         bool visited;
39         ///
40         std::vector<Command>::iterator previous;
41 };
42
43 class Format {
44 public:
45         Format() : in_degree(0) {}
46         ///
47         Format(string const & n);
48         ///
49         string name;
50         ///
51         string prettyname;
52         ///
53         string viewer;
54         ///
55         int in_degree;
56 };
57
58 class Formats {
59 public:
60         ///
61         static
62         void Add(string const & name);
63         ///
64         static
65         void SetViewer(string const & name, string const & command);
66         ///
67         static
68         bool View(string const & filename);
69         ///
70         static
71         Format * GetFormat(string const & name);
72         ///
73         static
74         string PrettyName(string const & name);
75 private:
76         ///
77         static
78         std::map<string, Format> formats;
79 };
80
81 class Converter {
82 public:
83         ///
84         static
85         void Add(string const & from, string const & to,
86                  string const & command, string const & flags);
87         ///
88         static
89         std::vector<std::pair<string, string> > GetReachable(string const & from,
90                                                              bool only_viewable = false);
91         ///
92         static
93         bool convert(Buffer * buffer, string const & from_file,
94                      string const & to_format);
95         ///
96         static
97         string SplitFormat(string const & str, string & format); 
98 private:
99         ///
100         static
101         bool runLaTeX(Buffer * buffer, string const & command);
102         ///
103         static
104         std::vector<Command> commands;
105 };
106
107 #endif