mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-09-21 15:18:45 +00:00
mathed28.diff
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1534 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
f0c75a909e
commit
1dd613bb03
@ -1,3 +1,10 @@
|
|||||||
|
|
||||||
|
2001-02-14 André Pönitz <poenitz@htwm.de>
|
||||||
|
|
||||||
|
* array.[Ch]: "deep" copy constructor and assignment operator for MathArray
|
||||||
|
|
||||||
|
* math_iter.[Ch]: seperate Copy() from Copy(int, int)
|
||||||
|
|
||||||
2001-02-14 André Pönitz <poenitz@htwm.de>
|
2001-02-14 André Pönitz <poenitz@htwm.de>
|
||||||
|
|
||||||
* array.[Ch]: remove constructor and enums ARRAY_MIN_SIZE and ARRAY_STEP
|
* array.[Ch]: remove constructor and enums ARRAY_MIN_SIZE and ARRAY_STEP
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "array.h"
|
#include "array.h"
|
||||||
|
#include "math_iter.h"
|
||||||
|
#include "math_inset.h"
|
||||||
|
|
||||||
// Is this still needed? (Lgb)
|
// Is this still needed? (Lgb)
|
||||||
static inline
|
static inline
|
||||||
@ -22,6 +24,65 @@ MathedArray::MathedArray()
|
|||||||
: bf_(1, 0), last_(0)
|
: bf_(1, 0), last_(0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
MathedArray::~MathedArray()
|
||||||
|
{
|
||||||
|
// deep destruction
|
||||||
|
// let's leak for a while...
|
||||||
|
/*
|
||||||
|
MathedIter it;
|
||||||
|
it.SetData(this);
|
||||||
|
while (it.OK()) {
|
||||||
|
if (it.IsInset()) {
|
||||||
|
MathedInset * inset = it.GetInset();
|
||||||
|
delete inset;
|
||||||
|
}
|
||||||
|
it.Next();
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
MathedArray::MathedArray(MathedArray const & array)
|
||||||
|
{
|
||||||
|
// this "implementation" is obviously wrong: MathedIter should be
|
||||||
|
// implemented by MathedArray (not the other way round) but I think
|
||||||
|
// getting the _interface_ of MathedArray right is more important right
|
||||||
|
// now (Andre')
|
||||||
|
|
||||||
|
// shallow copy
|
||||||
|
bf_ = array.bf_;
|
||||||
|
last_ = array.last_;
|
||||||
|
|
||||||
|
// deep copy
|
||||||
|
// we'll not yet get exeption safety
|
||||||
|
MathedIter it;
|
||||||
|
it.SetData(this);
|
||||||
|
while (it.OK()) {
|
||||||
|
if (it.IsInset()) {
|
||||||
|
MathedInset * inset = it.GetInset();
|
||||||
|
inset = inset->Clone();
|
||||||
|
raw_pointer_insert(inset, it.getPos() + 1, sizeof(inset));
|
||||||
|
}
|
||||||
|
it.Next();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
MathedArray & MathedArray::operator=(MathedArray const & array)
|
||||||
|
{
|
||||||
|
MathedArray tmp(array);
|
||||||
|
swap(tmp);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MathedArray::swap(MathedArray & array)
|
||||||
|
{
|
||||||
|
if (this != &array) {
|
||||||
|
bf_.swap(array.bf_);
|
||||||
|
std::swap(last_, array.last_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
MathedArray::iterator MathedArray::begin()
|
MathedArray::iterator MathedArray::begin()
|
||||||
{
|
{
|
||||||
|
@ -47,6 +47,12 @@ public:
|
|||||||
|
|
||||||
///
|
///
|
||||||
MathedArray();
|
MathedArray();
|
||||||
|
///
|
||||||
|
MathedArray(MathedArray const &);
|
||||||
|
///
|
||||||
|
MathedArray & operator=(MathedArray const &);
|
||||||
|
///
|
||||||
|
~MathedArray();
|
||||||
|
|
||||||
///
|
///
|
||||||
iterator begin();
|
iterator begin();
|
||||||
@ -65,6 +71,9 @@ public:
|
|||||||
///
|
///
|
||||||
void last(int l);
|
void last(int l);
|
||||||
|
|
||||||
|
///
|
||||||
|
void swap(MathedArray &);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
///
|
///
|
||||||
void insert(iterator pos, const_iterator beg, const_iterator end);
|
void insert(iterator pos, const_iterator beg, const_iterator end);
|
||||||
|
@ -381,6 +381,21 @@ bool MathedIter::Delete()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
MathedArray * MathedIter::Copy()
|
||||||
|
{
|
||||||
|
#if 0
|
||||||
|
return Copy(0, 10000);
|
||||||
|
#else
|
||||||
|
if (!array) {
|
||||||
|
// lyxerr << "Math error: Attempting to copy a void array." << endl;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new MathedArray(*array);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
MathedArray * MathedIter::Copy(int pos1, int pos2)
|
MathedArray * MathedIter::Copy(int pos1, int pos2)
|
||||||
{
|
{
|
||||||
if (!array) {
|
if (!array) {
|
||||||
@ -424,6 +439,10 @@ MathedArray * MathedIter::Copy(int pos1, int pos2)
|
|||||||
} else
|
} else
|
||||||
a = new MathedArray(*array);
|
a = new MathedArray(*array);
|
||||||
|
|
||||||
|
// this should be unnecessary and leak in some (most?) cases since
|
||||||
|
// a = new MathedArray(*array); makes already a deep copy...
|
||||||
|
// I guess it'll go soon... (Andre')
|
||||||
|
|
||||||
SetData(a);
|
SetData(a);
|
||||||
while (OK()) {
|
while (OK()) {
|
||||||
if (IsInset()) {
|
if (IsInset()) {
|
||||||
|
@ -112,8 +112,10 @@ public:
|
|||||||
void SetData(MathedArray * a);
|
void SetData(MathedArray * a);
|
||||||
///
|
///
|
||||||
MathedArray * GetData() const;
|
MathedArray * GetData() const;
|
||||||
|
/// Copy every object
|
||||||
|
MathedArray * Copy();
|
||||||
/// Copy every object from position p1 to p2
|
/// Copy every object from position p1 to p2
|
||||||
MathedArray * Copy(int p1 = 0, int p2 = 10000);
|
MathedArray * Copy(int p1, int p2);
|
||||||
/// Delete every object from position p1 to p2
|
/// Delete every object from position p1 to p2
|
||||||
void Clear();
|
void Clear();
|
||||||
protected:
|
protected:
|
||||||
|
Loading…
Reference in New Issue
Block a user