mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-11 13:46:43 +00:00
0a1d3c186a
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@17839 a592a061-630c-0410-9148-cb99ea01b6c8
95 lines
2.0 KiB
C++
95 lines
2.0 KiB
C++
// -*- C++ -*-
|
||
/**
|
||
* \file MathMacroTable.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.
|
||
*/
|
||
|
||
#ifndef MATH_MACROTABLE_H
|
||
#define MATH_MACROTABLE_H
|
||
|
||
#include "support/docstring.h"
|
||
|
||
#include <boost/assert.hpp>
|
||
|
||
#include <map>
|
||
#include <vector>
|
||
|
||
namespace lyx {
|
||
|
||
class MathArray;
|
||
|
||
///
|
||
class MacroData {
|
||
public:
|
||
///
|
||
MacroData();
|
||
///
|
||
MacroData(docstring const & def, int nargs, docstring const & disp, std::string const &);
|
||
///
|
||
docstring def() const { return def_; }
|
||
///
|
||
docstring disp() const { return disp_; }
|
||
///
|
||
int numargs() const { return numargs_; }
|
||
/// replace #1,#2,... by given MathAtom 0,1,..
|
||
void expand(std::vector<MathArray> const & from, MathArray & to) const;
|
||
///
|
||
std::string requires() const { return requires_; }
|
||
///
|
||
std::string & requires() { return requires_; }
|
||
|
||
///
|
||
int lock() { return ++lockCount_; }
|
||
///
|
||
bool locked() const { return lockCount_ != 0; }
|
||
///
|
||
void unlock() { --lockCount_; BOOST_ASSERT(lockCount_ >= 0); }
|
||
|
||
private:
|
||
///
|
||
docstring def_;
|
||
///
|
||
int numargs_;
|
||
///
|
||
docstring disp_;
|
||
///
|
||
std::string requires_;
|
||
///
|
||
int lockCount_;
|
||
};
|
||
|
||
|
||
// 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<docstring, MacroData>
|
||
{
|
||
public:
|
||
/// Parse full "\\def..." or "\\newcommand..." or ...
|
||
void insert(docstring const & definition, std::string const &);
|
||
/// Insert pre-digested macro definition
|
||
void insert(docstring const & name, MacroData const & data);
|
||
/// Do we have a macro by that name?
|
||
bool has(docstring const & name) const;
|
||
///
|
||
MacroData const & get(docstring const & name) const;
|
||
///
|
||
void dump();
|
||
|
||
/// the global list
|
||
static MacroTable & globalMacros();
|
||
/// the local list hack
|
||
//static MacroTable & localMacros();
|
||
};
|
||
|
||
|
||
} // namespace lyx
|
||
|
||
#endif
|