]> git.lyx.org Git - features.git/blob - src/insets/ExternalTemplate.h
Remove some redundant #includes.
[features.git] / src / insets / ExternalTemplate.h
1 // -*- C++ -*-
2 /**
3  * \file ExternalTemplate.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Asger Alstrup Nielsen
8  * \author Angus Leeming
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #ifndef EXTERNALTEMPLATE_H
14 #define EXTERNALTEMPLATE_H
15
16 #include "ExternalTransforms.h"
17
18 #include <boost/utility.hpp>
19
20 class LyXLex;
21
22 namespace lyx {
23 namespace external {
24
25 struct Template {
26         /// We have to have default commands for safety reasons!
27         Template();
28         ///
29         void readTemplate(LyXLex &);
30         ///
31         void dumpFormats(std::ostream &) const;
32
33         struct Option {
34                 Option(std::string const & name_, std::string const & opt_)
35                         : name(name_), option(opt_) {}
36                 std::string name;
37                 std::string option;
38         };
39
40         /// What is the name of this template in the LyX format?
41         std::string lyxName;
42         /// What will the button in the GUI say?
43         std::string guiName;
44         /// A short help text
45         std::string helpText;
46         /** The format of the input file. Can be "*", in which case we try and
47          *   ascertain the format from the contents of the file.
48          */
49         std::string inputFormat;
50         /// A file extension regular expression for the file browser
51         std::string fileRegExp;
52         /// Should we do automatic production of the output?
53         bool automaticProduction;
54         /// A collection of transforms that we can use to transform the data.
55         std::vector<TransformID> transformIds;
56
57         /// This is the information needed to support a specific output format
58         struct Format {
59                 Format();
60                 ///
61                 void readFormat(LyXLex &);
62
63                 /// The text that should be inserted into the exported file
64                 std::string product;
65                 /// The filename of the resulting file
66                 std::string updateResult;
67                 /// The format of this file.
68                 std::string updateFormat;
69                 /// What features does this external inset require?
70                 std::string requirement;
71                 /// A collection of preamble snippets identified by name.
72                 std::vector<std::string> preambleNames;
73                 /// A list of options to the basic command.
74                 std::vector<Option> options;
75
76                 /// The factory functions for each supported transformation.
77                 std::map<TransformID, TransformStore> command_transformers;
78                 std::map<TransformID, TransformStore> option_transformers;
79         };
80         ///
81         typedef std::map<std::string, Format> Formats;
82         ///
83         Formats formats;
84 };
85
86 /**
87  *  A singleton class that manages the external inset templates
88  */
89 class TemplateManager : boost::noncopyable {
90 public:
91         /// Map from the LyX name of the template to the template structure
92         typedef std::map<std::string, Template> Templates;
93         /** Map from the LyX name of the preamble definition to the preamble
94          *  definition itself.
95          */
96         typedef std::map<std::string, std::string> PreambleDefs;
97
98         static TemplateManager & get();
99
100         Templates const & getTemplates() const;
101         /** return the template by LyX name.
102          *  If it isn't found, return 0.
103          */
104         Template const * getTemplateByName(std::string const & name) const;
105         /** return the preamble definition by LyX name.
106          *  If it isn't found, return an empty std::string.
107          */
108         std::string const getPreambleDefByName(std::string const & name) const;
109 private:
110         TemplateManager();
111         void readTemplates(std::string const & path);
112         void dumpTemplates(std::ostream &) const;
113         void dumpPreambleDefs(std::ostream &) const;
114
115         Templates templates;
116         PreambleDefs preambledefs;
117 };
118
119 } // namespace external
120 } // namespace lyx
121
122 #endif // EXTERNALTEMPLATE_H