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