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
8 * \author Angus Leeming
10 * Full author contact details are available in file CREDITS.
13 #ifndef EXTERNALTEMPLATE_H
14 #define EXTERNALTEMPLATE_H
16 #include "ExternalTransforms.h"
37 /// We have to have default commands for safety reasons!
40 void readTemplate(support::Lexer &);
42 void dumpFormats(std::ostream &) const;
46 Option(std::string const & name_, std::string const & opt_)
47 : name(name_), option(opt_) {}
52 /// What is the name of this template in the LyX format?
54 /// What will the button in the GUI say?
58 /** The format of the input file. Can be "*", in which case we try and
59 * ascertain the format from the contents of the file.
61 std::string inputFormat;
62 /// A file extension regular expression for the file browser
63 std::string fileRegExp;
64 /// Should we do automatic production of the output?
65 bool automaticProduction;
66 /// How should we preview the data in LyX?
67 PreviewMode preview_mode;
68 /// A collection of transforms that we can use to transform the data.
69 std::vector<TransformID> transformIds;
71 /// This is the information needed to support a specific output format
76 void readFormat(support::Lexer &);
78 /// The text that should be inserted into the exported file
80 /// The filename of the resulting file
81 std::string updateResult;
82 /// The format of this file.
83 std::string updateFormat;
84 /// What features does this external inset require?
85 std::vector<std::string> requirements;
86 /// A collection of preamble snippets identified by name.
87 std::vector<std::string> preambleNames;
88 /// A list of options to the basic command.
89 std::vector<Option> options;
91 /// The factory functions for each supported transformation.
92 std::map<TransformID, TransformStore> command_transformers;
93 std::map<TransformID, TransformStore> option_transformers;
95 typedef std::map<std::string,
96 std::vector<std::string> > FileMap;
97 /// Referenced files for some formats
98 FileMap referencedFiles;
101 typedef std::map<std::string, Format> Formats;
107 * A singleton class that manages the external inset templates
109 class TemplateManager {
111 /// Map from the LyX name of the template to the template structure
112 typedef std::map<std::string, Template> Templates;
113 /** Map from the LyX name of the preamble definition to the preamble
116 typedef std::map<std::string, docstring> PreambleDefs;
118 static TemplateManager & get();
120 Templates const & getTemplates() const;
121 /** return the template by LyX name.
122 * If it isn't found, return 0.
124 Template const * getTemplateByName(std::string const & name) const;
125 /** return the preamble definition by LyX name.
126 * If it isn't found, return an empty std::string.
128 docstring getPreambleDefByName(std::string const & name) const;
130 TemplateManager(TemplateManager const &) = delete;
131 void operator=(TemplateManager const &) = delete;
135 void readTemplates(support::FileName const & path);
136 void dumpTemplates(std::ostream &) const;
137 void dumpPreambleDefs(std::ostream &) const;
140 PreambleDefs preambledefs;
143 } // namespace external
146 #endif // EXTERNALTEMPLATE_H