2001-02-13 17:08:51 +00:00
|
|
|
|
// -*- C++ -*-
|
2003-08-19 13:00:56 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file math_macrotable.h
|
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
|
*
|
|
|
|
|
* \author Andr<EFBFBD> P<EFBFBD>nitz
|
|
|
|
|
*
|
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
|
*/
|
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
#ifndef MATH_MACROTABLE_H
|
|
|
|
|
#define MATH_MACROTABLE_H
|
2001-02-13 17:08:51 +00:00
|
|
|
|
|
2003-10-06 15:43:21 +00:00
|
|
|
|
#include <map>
|
2003-10-07 06:45:25 +00:00
|
|
|
|
#include <string>
|
2004-04-13 06:27:29 +00:00
|
|
|
|
#include <vector>
|
2003-10-06 15:43:21 +00:00
|
|
|
|
|
2004-04-13 06:27:29 +00:00
|
|
|
|
class MathArray;
|
2001-03-01 14:07:43 +00:00
|
|
|
|
|
2004-04-13 13:54:58 +00:00
|
|
|
|
|
2004-04-13 06:27:29 +00:00
|
|
|
|
///
|
|
|
|
|
class MacroData {
|
2001-02-13 17:08:51 +00:00
|
|
|
|
public:
|
2001-03-01 14:07:43 +00:00
|
|
|
|
///
|
2004-04-13 06:27:29 +00:00
|
|
|
|
MacroData();
|
|
|
|
|
///
|
|
|
|
|
MacroData(std::string const & def, int nargs, std::string const & disp);
|
|
|
|
|
///
|
|
|
|
|
std::string def() const { return def_; }
|
|
|
|
|
///
|
|
|
|
|
std::string disp() const { return disp_; }
|
|
|
|
|
///
|
|
|
|
|
int numargs() const { return numargs_; }
|
|
|
|
|
/// replace #1,#2,... by given MathAtom 0,1,..
|
2004-04-13 13:54:58 +00:00
|
|
|
|
void expand(std::vector<MathArray> const & from, MathArray & to) const;
|
2004-04-13 06:27:29 +00:00
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
///
|
2004-04-20 08:51:15 +00:00
|
|
|
|
std::string def_;
|
2004-04-13 06:27:29 +00:00
|
|
|
|
///
|
|
|
|
|
int numargs_;
|
2001-03-01 14:07:43 +00:00
|
|
|
|
///
|
2004-04-13 06:27:29 +00:00
|
|
|
|
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.
|
|
|
|
|
|
2004-04-13 13:54:58 +00:00
|
|
|
|
class MacroTable : public std::map<std::string, MacroData>
|
|
|
|
|
{
|
2004-04-13 06:27:29 +00:00
|
|
|
|
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;
|
2001-03-01 14:07:43 +00:00
|
|
|
|
///
|
2004-04-13 06:27:29 +00:00
|
|
|
|
MacroData const & get(std::string const & name) const;
|
2002-03-27 11:02:56 +00:00
|
|
|
|
///
|
2004-04-13 06:27:29 +00:00
|
|
|
|
void dump();
|
|
|
|
|
|
|
|
|
|
/// the global list
|
|
|
|
|
static MacroTable & globalMacros();
|
2004-04-13 13:54:58 +00:00
|
|
|
|
/// the local list hack
|
|
|
|
|
//static MacroTable & localMacros();
|
2001-02-13 17:08:51 +00:00
|
|
|
|
};
|
2002-07-12 14:24:47 +00:00
|
|
|
|
|
2001-02-13 17:08:51 +00:00
|
|
|
|
#endif
|