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
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 /// What should be inserted into the preamble
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;
80 static ExternalTemplateManager & get();
81 Templates & getTemplates();
82 Templates const & getTemplates() const;
83 /// return the template by LyX name
84 ExternalTemplate const & getTemplateByName(string const & name);
86 ExternalTemplateManager();
87 void readTemplates(string const & path);
88 void dumpTemplates() const;