]> git.lyx.org Git - lyx.git/blob - src/mathed/MathMacroTable.h
hopefully fix tex2lyx linking.
[lyx.git] / src / mathed / MathMacroTable.h
1 // -*- C++ -*-
2 /**
3  * \file MathMacroTable.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author André Pönitz
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef MATH_MACROTABLE_H
13 #define MATH_MACROTABLE_H
14
15 #include <map>
16 #include <string>
17 #include <vector>
18
19 #include "support/docstring.h"
20
21 namespace lyx {
22
23 class MathArray;
24
25 ///
26 class MacroData {
27 public:
28         ///
29         MacroData();
30         ///
31         MacroData(docstring const & def, int nargs, docstring const & disp, std::string const &);
32         ///
33         docstring def() const { return def_; }
34         ///
35         docstring disp() const { return disp_; }
36         ///
37         int numargs() const { return numargs_; }
38         /// replace #1,#2,... by given MathAtom 0,1,..
39         void expand(std::vector<MathArray> const & from, MathArray & to) const;
40         ///
41         std::string requires() const { return requires_; }
42         ///
43         std::string & requires() { return requires_; }
44
45 private:
46         ///
47         docstring def_;
48         ///
49         int numargs_;
50         ///
51         docstring disp_;
52         ///
53         std::string requires_;
54 };
55
56
57 // This contains a table of "global" macros that are always accessible,
58 // either because they implement a feature of standard LaTeX or some
59 // hack to display certain contents nicely.
60
61 class MacroTable : public std::map<docstring, MacroData>
62 {
63 public:
64         /// Parse full "\\def..." or "\\newcommand..." or ...
65         void insert(docstring const & definition, std::string const &);
66         /// Insert pre-digested macro definition
67         void insert(docstring const & name, MacroData const & data);
68         /// Do we have a macro by that name?
69         bool has(docstring const & name) const;
70         ///
71         MacroData const & get(docstring const & name) const;
72         ///
73         void dump();
74
75         /// the global list
76         static MacroTable & globalMacros();
77         /// the local list hack
78         //static MacroTable & localMacros();
79 };
80
81
82 } // namespace lyx
83
84 #endif