]> git.lyx.org Git - lyx.git/blob - src/insets/ExternalTemplate.h
Enable convertDefault.sh to run even if its executable bit is not set.
[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         /** The format of the input file. Can be "*", in which case we try and
32             ascertain the format from the contents of the file.
33         */
34         string inputFormat;
35         /// A file extension regular expression for the file browser
36         string fileRegExp;
37         /// What command should be executed to edit the file?
38         string editCommand;
39         /// Should we do automatic production of the output?
40         bool automaticProduction;
41         /// This is the information needed to support a specific output format
42         struct FormatTemplate {
43                 /// The text that should be inserted into the exported file
44                 string product;
45                 /// The filename of the resulting file
46                 string updateResult;
47                 /// The format of this file.
48                 string updateFormat;
49                 /// What features does this external inset require?
50                 string requirement;
51                 /// What should be inserted into the preamble
52                 string preamble;
53                 ///
54                 void readFormat(LyXLex &);
55                 /// This constructor has to default a command for safety reasons!
56                 FormatTemplate();
57         };
58         ///
59         void readTemplate(LyXLex &);
60         ///
61         typedef std::map<string, FormatTemplate> Formats;
62         ///
63         Formats formats;
64         ///
65         void dumpFormats(std::ostream &) const;
66
67         /// We have to have default commands for safety reasons!
68         ExternalTemplate();
69 };
70
71
72 /**
73    A singleton class that manages the external inset templates
74 */
75 class ExternalTemplateManager : boost::noncopyable {
76 public:
77         /// Map from the LyX name of the template to the template structure
78         typedef std::map<string, ExternalTemplate> Templates;
79
80         static ExternalTemplateManager & get();
81         Templates & getTemplates();
82         Templates const & getTemplates() const;
83         /// return the template by LyX name
84         ExternalTemplate const & getTemplateByName(string const & name);
85 private:
86         ExternalTemplateManager();
87         void readTemplates(string const & path);
88         void dumpTemplates() const;
89         Templates templates;
90 };
91
92 #endif