3 * \file ExternalTemplate.h
4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Asger Alstrup Nielsen
9 * Full author contact details are available in file CREDITS.
12 #ifndef EXTERNALTEMPLATE_H
13 #define EXTERNALTEMPLATE_H
15 #include <boost/function.hpp>
16 #include <boost/utility.hpp>
29 /// We have to have default commands for safety reasons!
32 void readTemplate(LyXLex &);
34 void dumpFormats(std::ostream &) const;
36 /// What is the name of this template in the LyX format?
38 /// What will the button in the GUI say?
42 /** The format of the input file. Can be "*", in which case we try and
43 * ascertain the format from the contents of the file.
45 std::string inputFormat;
46 /// A file extension regular expression for the file browser
47 std::string fileRegExp;
48 /// What command should be executed to edit the file?
49 std::string editCommand;
50 /// Should we do automatic production of the output?
51 bool automaticProduction;
53 /// This is the information needed to support a specific output format
55 /// This constructor has to default a command for safety reasons!
58 void readFormat(LyXLex &);
60 /// The text that should be inserted into the exported file
62 /// The filename of the resulting file
63 std::string updateResult;
64 /// The format of this file.
65 std::string updateFormat;
66 /// What features does this external inset require?
67 std::string requirement;
68 /// A collection of preamble snippets identified by name.
69 std::vector<std::string> preambleNames;
72 typedef std::map<std::string, Format> Formats;
79 A singleton class that manages the external inset templates
81 class TemplateManager : boost::noncopyable {
83 /// Map from the LyX name of the template to the template structure
84 typedef std::map<std::string, Template> Templates;
85 /** Map from the LyX name of the preamble definition to the preamble
88 typedef std::map<std::string, std::string> PreambleDefs;
90 static TemplateManager & get();
91 Templates & getTemplates();
92 Templates const & getTemplates() const;
93 /** return the template by LyX name.
94 * If it isn't found, return 0.
96 Template const * getTemplateByName(std::string const & name) const;
97 /** return the preamble definition by LyX name.
98 * If it isn't found, return an empty std::string.
100 std::string const getPreambleDefByName(std::string const & name) const;
103 void readTemplates(std::string const & path);
104 void dumpTemplates(std::ostream &) const;
105 void dumpPreambleDefs(std::ostream &) const;
108 PreambleDefs preambledefs;
111 } // namespace external
114 #endif // EXTERNALTEMPLATE_H