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>
24 struct ExternalTemplate {
25 /// What is the name of this template in the LyX format?
27 /// What will the button in the GUI say?
31 /** The format of the input file. Can be "*", in which case we try and
32 ascertain the format from the contents of the file.
35 /// A file extension regular expression for the file browser
37 /// What command should be executed to edit the file?
39 /// Should we do automatic production of the output?
40 bool automaticProduction;
41 /// This is the information needed to support a specific output format
42 struct FormatTemplate {
43 /// The text that should be inserted into the exported file
45 /// The filename of the resulting file
47 /// The format of this file.
49 /// What features does this external inset require?
51 /// Identify the preamble snippet using \c preambleName.
54 void readFormat(LyXLex &);
55 /// This constructor has to default a command for safety reasons!
59 void readTemplate(LyXLex &);
61 typedef std::map<string, FormatTemplate> Formats;
65 void dumpFormats(std::ostream &) const;
67 /// We have to have default commands for safety reasons!
73 A singleton class that manages the external inset templates
75 class ExternalTemplateManager : boost::noncopyable {
77 /// Map from the LyX name of the template to the template structure
78 typedef std::map<string, ExternalTemplate> Templates;
79 /** Map from the LyX name of the preamble definition to the preamble
82 typedef std::map<string, string> PreambleDefs;
84 static ExternalTemplateManager & get();
85 Templates & getTemplates();
86 Templates const & getTemplates() const;
87 /// return the template by LyX name
88 ExternalTemplate const & getTemplateByName(string const & name);
89 string const getPreambleDefByName(string const & name) const;
91 ExternalTemplateManager();
92 void readTemplates(string const & path);
93 void dumpTemplates(std::ostream &) const;
94 void dumpPreambleDefs(std::ostream &) const;
97 PreambleDefs preambledefs;