// -*- C++ -*-
-#ifndef MATHMACROTABLE
-#define MATHMACROTABLE
+/**
+ * \file math_macrotable.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author André Pönitz
+ *
+ * Full author contact details are available in file CREDITS.
+ */
-#include <map>
-#include "LString.h"
+#ifndef MATH_MACROTABLE_H
+#define MATH_MACROTABLE_H
-#ifdef __GNUG__
-#pragma interface
-#endif
+#include <map>
+#include <string>
+#include <vector>
+class MathArray;
-class MathMacro;
-class MathMacroTemplate;
///
-struct MathMacroTable {
+class MacroData {
public:
///
- static MathMacroTemplate & provideTemplate(string const &, int);
+ MacroData();
+ ///
+ MacroData(std::string const & def, int nargs, std::string const & disp);
///
- static MathMacroTemplate & provideTemplate(string const &);
+ std::string def() const { return def_; }
///
- static bool hasTemplate(string const &);
+ std::string disp() const { return disp_; }
///
- static MathMacro * cloneTemplate(string const &);
+ int numargs() const { return numargs_; }
+ /// replace #1,#2,... by given MathAtom 0,1,..
+ void expand(std::vector<MathArray> const & from, MathArray & to) const;
+
private:
///
- static void builtinMacros();
+ std::string def_;
///
- static bool built;
+ int numargs_;
///
- typedef std::map<string, MathMacroTemplate *> table_type;
- //
- static table_type macro_table;
+ std::string disp_;
+};
+
+
+// This contains a table of "global" macros that are always accessible,
+// either because they implement a feature of standard LaTeX or some
+// hack to display certain contents nicely.
+
+class MacroTable : public std::map<std::string, MacroData>
+{
+public:
+ /// Parse full "\def..." or "\newcommand..." or ...
+ void insert(std::string const & definition);
+ /// Insert pre-digested macro definition
+ void insert(std::string const & name, MacroData const & data);
+ /// Do we have a macro by that name?
+ bool has(std::string const & name) const;
///
- static void dump();
+ MacroData const & get(std::string const & name) const;
+ ///
+ void dump();
+
+ /// the global list
+ static MacroTable & globalMacros();
+ /// the local list hack
+ //static MacroTable & localMacros();
};
+
#endif