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>
27 /// We have to have default commands for safety reasons!
30 void readTemplate(LyXLex &);
32 void dumpFormats(std::ostream &) const;
36 Option(std::string const & name_, std::string const & opt_)
37 : name(name_), option(opt_) {}
42 /// What is the name of this template in the LyX format?
44 /// What will the button in the GUI say?
48 /** The format of the input file. Can be "*", in which case we try and
49 * ascertain the format from the contents of the file.
51 std::string inputFormat;
52 /// A file extension regular expression for the file browser
53 std::string fileRegExp;
54 /// Should we do automatic production of the output?
55 bool automaticProduction;
56 /// A collection of transforms that we can use to transform the data.
57 std::vector<TransformID> transformIds;
59 /// This is the information needed to support a specific output format
64 void readFormat(LyXLex &);
66 /// The text that should be inserted into the exported file
68 /// The filename of the resulting file
69 std::string updateResult;
70 /// The format of this file.
71 std::string updateFormat;
72 /// What features does this external inset require?
73 std::vector<std::string> requirements;
74 /// A collection of preamble snippets identified by name.
75 std::vector<std::string> preambleNames;
76 /// A list of options to the basic command.
77 std::vector<Option> options;
79 /// The factory functions for each supported transformation.
80 std::map<TransformID, TransformStore> command_transformers;
81 std::map<TransformID, TransformStore> option_transformers;
83 typedef std::map<std::string,
84 std::vector<std::string> > FileMap;
85 /// Referenced files for some formats
86 FileMap referencedFiles;
89 typedef std::map<std::string, Format> Formats;
95 * A singleton class that manages the external inset templates
97 class TemplateManager : boost::noncopyable {
99 /// Map from the LyX name of the template to the template structure
100 typedef std::map<std::string, Template> Templates;
101 /** Map from the LyX name of the preamble definition to the preamble
104 typedef std::map<std::string, std::string> PreambleDefs;
106 static TemplateManager & get();
108 Templates const & getTemplates() const;
109 /** return the template by LyX name.
110 * If it isn't found, return 0.
112 Template const * getTemplateByName(std::string const & name) const;
113 /** return the preamble definition by LyX name.
114 * If it isn't found, return an empty std::string.
116 std::string const getPreambleDefByName(std::string const & name) const;
119 void readTemplates(std::string const & path);
120 void dumpTemplates(std::ostream &) const;
121 void dumpPreambleDefs(std::ostream &) const;
124 PreambleDefs preambledefs;
127 } // namespace external
130 #endif // EXTERNALTEMPLATE_H