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
18 #include "support/std_string.h"
19 #include <boost/utility.hpp>
25 struct ExternalTemplate {
26 /// What is the name of this template in the LyX format?
28 /// What will the button in the GUI say?
32 /** The format of the input file. Can be "*", in which case we try and
33 ascertain the format from the contents of the file.
36 /// A file extension regular expression for the file browser
38 /// What command should be executed to edit the file?
40 /// Should we do automatic production of the output?
41 bool automaticProduction;
42 /// This is the information needed to support a specific output format
43 struct FormatTemplate {
44 /// The text that should be inserted into the exported file
46 /// The filename of the resulting file
48 /// The format of this file.
50 /// What features does this external inset require?
52 /// A collection of preamble snippets identified by name.
53 std::vector<string> preambleNames;
55 void readFormat(LyXLex &);
56 /// This constructor has to default a command for safety reasons!
60 void readTemplate(LyXLex &);
62 typedef std::map<string, FormatTemplate> Formats;
66 void dumpFormats(std::ostream &) const;
68 /// We have to have default commands for safety reasons!
74 A singleton class that manages the external inset templates
76 class ExternalTemplateManager : boost::noncopyable {
78 /// Map from the LyX name of the template to the template structure
79 typedef std::map<string, ExternalTemplate> Templates;
80 /** Map from the LyX name of the preamble definition to the preamble
83 typedef std::map<string, string> PreambleDefs;
85 static ExternalTemplateManager & get();
86 Templates & getTemplates();
87 Templates const & getTemplates() const;
88 /// return the template by LyX name
89 ExternalTemplate const & getTemplateByName(string const & name);
90 string const getPreambleDefByName(string const & name) const;
92 ExternalTemplateManager();
93 void readTemplates(string const & path);
94 void dumpTemplates(std::ostream &) const;
95 void dumpPreambleDefs(std::ostream &) const;
98 PreambleDefs preambledefs;