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"
18 #include <boost/utility.hpp>
31 /// We have to have default commands for safety reasons!
34 void readTemplate(LyXLex &);
36 void dumpFormats(std::ostream &) const;
39 Option(std::string const & name_, std::string const & opt_)
40 : name(name_), option(opt_) {}
45 /// What is the name of this template in the LyX format?
47 /// What will the button in the GUI say?
51 /** The format of the input file. Can be "*", in which case we try and
52 * ascertain the format from the contents of the file.
54 std::string inputFormat;
55 /// A file extension regular expression for the file browser
56 std::string fileRegExp;
57 /// Should we do automatic production of the output?
58 bool automaticProduction;
59 /// A collection of transforms that we can use to transform the data.
60 std::vector<TransformID> transformIds;
62 /// This is the information needed to support a specific output format
66 void readFormat(LyXLex &);
68 /// The text that should be inserted into the exported file
70 /// The filename of the resulting file
71 std::string updateResult;
72 /// The format of this file.
73 std::string updateFormat;
74 /// What features does this external inset require?
75 std::string requirement;
76 /// A collection of preamble snippets identified by name.
77 std::vector<std::string> preambleNames;
78 /// A list of options to the basic command.
79 std::vector<Option> options;
81 /// The factory functions for each supported transformation.
82 std::map<TransformID, TransformStore> command_transformers;
83 std::map<TransformID, TransformStore> option_transformers;
86 typedef std::map<std::string, Format> Formats;
91 #include "ExternalTransforms.h"
94 * A singleton class that manages the external inset templates
96 class TemplateManager : boost::noncopyable {
98 /// Map from the LyX name of the template to the template structure
99 typedef std::map<std::string, Template> Templates;
100 /** Map from the LyX name of the preamble definition to the preamble
103 typedef std::map<std::string, std::string> PreambleDefs;
105 static TemplateManager & get();
107 Templates const & getTemplates() const;
108 /** return the template by LyX name.
109 * If it isn't found, return 0.
111 Template const * getTemplateByName(std::string const & name) const;
112 /** return the preamble definition by LyX name.
113 * If it isn't found, return an empty std::string.
115 std::string const getPreambleDefByName(std::string const & name) const;
118 void readTemplates(std::string const & path);
119 void dumpTemplates(std::ostream &) const;
120 void dumpPreambleDefs(std::ostream &) const;
123 PreambleDefs preambledefs;
126 } // namespace external
129 #endif // EXTERNALTEMPLATE_H