]> git.lyx.org Git - lyx.git/blob - src/format.h
fix mathed crash
[lyx.git] / src / format.h
1 // -*- C++ -*-
2 /**
3  * \file format.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 FORMAT_H
13 #define FORMAT_H
14
15 #include <vector>
16 #include <string>
17
18 class Buffer;
19
20 class Format {
21 public:
22         ///
23         Format(std::string const & n, std::string const & e, std::string const & p,
24                std::string const & s, std::string const & v);
25         ///
26         bool dummy() const;
27         ///
28         bool isChildFormat() const;
29         ///
30         std::string const parentFormat() const;
31         ///
32         std::string const & name() const {
33                 return name_;
34         }
35         ///
36         std::string const & extension() const {
37                 return extension_;
38         }
39         ///
40         std::string const & prettyname() const {
41                 return prettyname_;
42         }
43         ///
44         std::string const & shortcut() const {
45                 return shortcut_;
46         }
47         ///
48         std::string const & viewer() const {
49                 return viewer_;
50         }
51         ///
52         void setViewer(std::string const & v) {
53                 viewer_ = v;
54         }
55 private:
56         std::string name_;
57         ///
58         std::string extension_;
59         ///
60         std::string prettyname_;
61         ///
62         std::string shortcut_;
63         ///
64         std::string viewer_;
65 };
66
67
68 bool operator<(Format const & a, Format const & b);
69
70 ///
71 class Formats {
72 public:
73         ///
74         typedef std::vector<Format> FormatList;
75         ///
76         typedef FormatList::const_iterator const_iterator;
77         ///
78         Format const & get(FormatList::size_type i) const {
79                 return formatlist[i];
80         }
81         ///
82         Format const * getFormat(std::string const & name) const;
83         ///
84         int getNumber(std::string const & name) const;
85         ///
86         void add(std::string const & name);
87         ///
88         void add(std::string const & name, std::string const & extension,
89                  std::string const & prettyname, std::string const & shortcut);
90         ///
91         void erase(std::string const & name);
92         ///
93         void sort();
94         ///
95         void setViewer(std::string const & name, std::string const & command);
96         ///
97         bool view(Buffer const & buffer, std::string const & filename,
98                   std::string const & format_name) const;
99         ///
100         std::string const prettyName(std::string const & name) const;
101         ///
102         std::string const extension(std::string const & name) const;
103         ///
104         const_iterator begin() const {
105                 return formatlist.begin();
106         }
107         ///
108         const_iterator end() const {
109                 return formatlist.end();
110         }
111         ///
112         FormatList::size_type size() const {
113                 return formatlist.size();
114         }
115 private:
116         ///
117         FormatList formatlist;
118 };
119
120 extern Formats formats;
121
122 extern Formats system_formats;
123
124 #endif //FORMAT_H