#include <config.h>
#include "math_autocorrect.h"
-#include "support/std_sstream.h"
-#include "debug.h"
-#include "support/filetools.h" // LibFileSearch
#include "math_data.h"
#include "math_inset.h"
+#include "math_support.h"
#include "math_parser.h"
+#include "debug.h"
+
+#include "support/std_sstream.h"
+#include "support/filetools.h" // LibFileSearch
#include <fstream>
// << "trying to correct ar: " << at << " from: '" << from1_ << '\'' << endl;
if (from2_ != c)
return false;
- if (!at->match(from1_))
+ if (asString(at) != asString(from1_))
return false;
lyxerr[Debug::MATHED]
<< "match found! subst in " << at
{
return char_ == '=' || char_ == '<' || char_ == '>';
}
-
-
-bool MathCharInset::match(MathInset const * p) const
-{
- MathCharInset const * q = p->asCharInset();
- return q && char_ == q->char_;
-}
char getChar() const { return char_; }
///
bool isRelOp() const;
- ///
- bool match(MathInset const *) const;
private:
/// the character
#include "math_replace.h"
#include "debug.h"
#include "LColor.h"
+
#include "frontends/Painter.h"
+
#include <boost/assert.hpp>
using std::abs;
using std::endl;
using std::min;
+using std::ostringstream;
MathArray::MathArray()
return false;
const_iterator it = begin() + pos;
for (const_iterator jt = ar.begin(); jt != ar.end(); ++jt, ++it)
- if (!(*jt)->match(*it))
+ if (asString(*it) != asString(*jt))
return false;
return true;
}
bool MathArray::find1(MathArray const & ar, size_type pos) const
{
- //lyxerr << "finding '" << ar << "' in '" << *this << "'" << endl;
+ lyxerr << "finding '" << ar << "' in '" << *this << "'" << endl;
for (size_type i = 0, n = ar.size(); i < n; ++i)
- if (!operator[](pos + i)->match(ar[i]))
+ if (asString(operator[](pos + i)) != asString(ar[i]))
return false;
return true;
}
/// char char code if possible
virtual void handleFont(std::string const &) {}
- /// is this inset equal to a given other inset?
- virtual bool match(MathAtom const &) const { return false; }
/// replace things by other things
virtual void replace(ReplaceData &) {}
/// do we contain a given subsequence?
void validate(LaTeXFeatures &) const;
///
bool isMacro() const { return true; }
- ///
- bool match(MathAtom const &) const { return false; }
///
void maple(MapleStream &) const;
}
-bool MathNestInset::match(MathAtom const & at) const
-{
- if (nargs() != at->nargs())
- return false;
- for (idx_type i = 0; i < nargs(); ++i)
- if (!cell(i).match(at->cell(i)))
- return false;
- return true;
-}
-
-
void MathNestInset::replace(ReplaceData & rep)
{
for (idx_type i = 0; i < nargs(); ++i)
#include "math_diminset.h"
-class MathArray;
-
/** Abstract base class for all math objects that contain nested items.
This is basically everything that is not a single character or a
/// request "external features"
void validate(LaTeXFeatures & features) const;
- /// match in all cells
- bool match(MathAtom const &) const;
/// replace in all cells
void replace(ReplaceData &);
/// do we contain a given pattern?
#include <config.h>
#include "math_support.h"
-
#include "math_data.h"
+#include "math_inset.h"
#include "math_mathmlstream.h"
#include "math_parser.h"
{
mathed_parse_cell(ar, str);
}
+
+
+string asString(MathInset const & inset)
+{
+ std::ostringstream os;
+ WriteStream ws(os);
+ inset.write(ws);
+ return os.str();
+}
+
+
+string asString(MathAtom const & at)
+{
+ std::ostringstream os;
+ WriteStream ws(os);
+ at->write(ws);
+ return os.str();
+}
#include <string>
-
class PainterInfo;
class LyXFont;
class Dimension;
class MathArray;
+class MathAtom;
+class MathInset;
+
void mathed_char_dim(LyXFont const &, unsigned char c, Dimension & dim);
int mathed_char_width(LyXFont const &, unsigned char c);
// converts single cell to string
std::string asString(MathArray const & ar);
+// converts single inset to string
+std::string asString(MathInset const &);
+std::string asString(MathAtom const &);
// converts string to single cell
void asArray(std::string const & str, MathArray & ar);
}
-bool MathSymbolInset::match(MathAtom const & at) const
-{
- MathSymbolInset const * q = at->asSymbolInset();
- return q && name() == q->name();
-}
-
-
void MathSymbolInset::mathmlize(MathMLStream & os) const
{
char const * type = MathMLtype(sym_->extra);
MathSymbolInset const * asSymbolInset() const { return this; }
/// the LaTeX name of the symbol (without the backslash)
std::string name() const;
- ///
- bool match(MathAtom const &) const;
/// request "external features"
void validate(LaTeXFeatures & features) const;
}
-bool MathUnknownInset::match(MathAtom const & at) const
-{
- MathUnknownInset const * q = at->asUnknownInset();
- return q && name_ == q->name_;
-}
-
-
void MathUnknownInset::normalize(NormalStream & os) const
{
os << "[unknown " << name_ << ']';
#include "math_diminset.h"
-/// Unknowntions or LaTeX names for objects that we really don't know
+
+/// LaTeX names for objects that we really don't know
class MathUnknownInset : public MathDimInset {
public:
///
explicit MathUnknownInset(std::string const & name,
bool final = true, bool black = false);
///
- virtual std::auto_ptr<InsetBase> clone() const;
+ std::auto_ptr<InsetBase> clone() const;
///
void metrics(MetricsInfo & mi, Dimension & dim) const;
///
MathUnknownInset const * asUnknownInset() const { return this; }
/// identifies UnknownInsets
MathUnknownInset * asUnknownInset() { return this; }
- ///
- bool match(MathAtom const & at) const;
///
void normalize(NormalStream &) const;