introduce test for "equality"

remove a few unneeded declarations


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3036 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2001-11-16 09:07:40 +00:00
parent 7348a42d8f
commit af2a6c6512
6 changed files with 28 additions and 12 deletions

View File

@ -25,19 +25,9 @@
#include "math_inset.h"
#include "LString.h"
class MathInset;
class MathAtom;
class MathGridInset;
class MathFuncInset;
class MathHullInset;
class MathScriptInset;
class MathSpaceInset;
class InsetFormulaBase;
class MathArray;
class MathXArray;
class Painter;
class Selection;
class latexkeys;
/// Description of a position
struct MathCursorPos {

View File

@ -204,3 +204,14 @@ MathArray::iterator MathArray::end()
{
return bf_.end();
}
bool MathArray::match(MathArray const & ar) const
{
if (size() != ar.size())
return false;
for (const_iterator it = begin(), jt = ar.begin(); it != end(); ++it, ++jt)
if (!it->nucleus()->match(jt->nucleus()))
return false;
return true;
}

View File

@ -19,9 +19,7 @@
#include <vector>
#include "math_atom.h"
#include "LString.h"
class MathScriptInset;
class MathMacro;
class LaTeXFeatures;
@ -104,6 +102,8 @@ public:
void dump2() const;
///
void substitute(MathMacro const &);
///
bool match(MathArray const &) const;
///
MathAtom & at(size_type pos);

View File

@ -229,6 +229,8 @@ public:
virtual void validate(LaTeXFeatures & features) const;
///
virtual void handleFont(MathTextCodes) {}
///
virtual bool match(MathInset *) const { return false; }
/// write normalized content
virtual void normalize(NormalStream &) const;

View File

@ -178,3 +178,14 @@ bool MathNestInset::covers(int x, int y) const
}
return x >= x0 && x <= x1 && y >= y0 && y <= y1;
}
bool MathNestInset::match(MathInset * p) const
{
if (nargs() != p->nargs())
return false;
for (idx_type i = 0; i < nargs(); ++i)
if (!cell(i).match(p->cell(i)))
return false;
return true;
}

View File

@ -65,6 +65,8 @@ public:
void push_back(MathAtom const &);
///
void dump() const;
///
bool match(MathInset *) const;
///
void validate(LaTeXFeatures & features) const;