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