]> git.lyx.org Git - lyx.git/blob - src/insets/ExternalTemplate.h
Rename LatexRunParams::fragile as moving_arg.
[lyx.git] / src / insets / ExternalTemplate.h
1 // -*- C++ -*-
2 /**
3  * \file ExternalTemplate.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Asger Alstrup Nielsen
8  *
9  * Full author contact details are available in file CREDITS
10  */
11
12 #ifndef EXTERNALTEMPLATE_H
13 #define EXTERNALTEMPLATE_H
14
15
16 #include <iosfwd>
17 #include <map>
18 #include "LString.h"
19 #include <boost/utility.hpp>
20
21 class LyXLex;
22
23 ///
24 struct ExternalTemplate {
25         /// What is the name of this template in the LyX format?
26         string lyxName;
27         /// What will the button in the GUI say?
28         string guiName;
29         /// A short help text
30         string helpText;
31         /// A file extension regular expression for the file browser
32         string fileRegExp;
33         /// What command should be executed to view the file?
34         string viewCommand;
35         /// What command should be executed to edit the file?
36         string editCommand;
37         /// Should we do automatic production of the output?
38         bool automaticProduction;
39         /// This is the information needed to support a specific output format
40         struct FormatTemplate {
41                 /// The text that should be inserted into the exported file
42                 string product;
43                 /// The shell command to produce a resulting file
44                 string updateCommand;
45                 /// The filename of the resulting file
46                 string updateResult;
47                 /// What features does this external inset require?
48                 string requirement;
49                 /// What should be inserted into the preamble
50                 string preamble;
51                 ///
52                 void readFormat(LyXLex &);
53                 /// This constructor has to default a command for safety reasons!
54                 FormatTemplate();
55         };
56         ///
57         void readTemplate(LyXLex &);
58         ///
59         typedef std::map<string, FormatTemplate> Formats;
60         ///
61         Formats formats;
62         ///
63         void dumpFormats(std::ostream &) const;
64
65         /// We have to have default commands for safety reasons!
66         ExternalTemplate();
67
68 };
69
70
71 /**
72    A singleton class that manages the external inset templates
73 */
74 class ExternalTemplateManager : boost::noncopyable {
75 public:
76         /// Map from the LyX name of the template to the template structure
77         typedef std::map<string, ExternalTemplate> Templates;
78
79         static ExternalTemplateManager & get();
80         Templates & getTemplates();
81         Templates const & getTemplates() const;
82         /// return the template by LyX name
83         ExternalTemplate const & getTemplateByName(const string & name);
84 private:
85         ExternalTemplateManager();
86         void readTemplates(string const & path);
87         void dumpTemplates() const;
88         Templates templates;
89 };
90
91 #endif