-2001-02-14 André Pönitz <poenitz@htwm.de>
+2001-03-06 André Pönitz <poenitz@htwm.de>
+ * array.[Ch]: factor out deep_copy,
+ remove third argument from raw_pointer_insert
+
+ * mathiter.[Ch]: remove unused function Clear()
+
+2001-03-04 André Pönitz <poenitz@htwm.de>
* math_macrotemplate.[Ch]:
math_macro.C: move update() functionality to the macro
last_ = array.last_;
// deep copy
- // we'll not yet get exeption safety
+ deep_copy();
+}
+
+void MathedArray::deep_copy()
+{
MathedIter it(this);
while (it.OK()) {
if (it.IsInset()) {
MathedInset * inset = it.GetInset();
inset = inset->Clone();
- raw_pointer_insert(inset, it.getPos() + 1, sizeof(inset));
+ raw_pointer_insert(inset, it.getPos() + 1);
}
it.Next();
}
a.last(dx);
a[dx] = '\0';
- MathedIter it(&a);
- it.Reset();
-
- while (it.OK()) {
- if (it.IsInset()) {
- MathedInset * inset = it.GetInset();
- inset = inset->Clone();
- a.raw_pointer_insert(inset, it.getPos() + 1, sizeof(inset));
- }
- it.Next();
- }
swap(a);
+ deep_copy();
}
}
#else
-void MathedArray::raw_pointer_insert(void * p, int pos, int len)
+void MathedArray::raw_pointer_insert(void * p, int pos)
{
- my_memcpy(&bf_[pos], &p, len);
+ my_memcpy(&bf_[pos], &p, sizeof(p));
}
#endif
MathedInset * getInset(int pos);
#else
///
- void raw_pointer_insert(void * p, int pos, int len);
+ void raw_pointer_insert(void * p, int pos);
#endif
///
void strange_copy(MathedArray * dest, int dpos, int spos, int len);
void need_size(int needed);
///
void dump(std::ostream &) const;
+ /// creates copies of all embedded insets
+ void deep_copy();
private:
/// Buffer
buffer_type bf_;
split(shift);
(*array)[pos] = type;
- array->raw_pointer_insert(p, pos + 1, sizeof(p));
+ array->raw_pointer_insert(p, pos + 1);
pos += SizeInset;
(*array)[pos - 1] = type;
(*array)[array->last()] = '\0';
return false;
}
-
-void MathedIter::Clear()
-{
- if (!array) {
- lyxerr << "Math error: Attempting to clean a void array." << endl;
- return;
- }
-
- Reset();
- while (OK()) {
- if (IsInset()) {
- MathedInset * inset = GetInset();
- if (inset->GetType()!= LM_OT_MACRO_ARG)
- delete inset;
- Delete();
- } else
- Next();
- }
-}
-
-
// Check consistency of tabs and crs
void MathedIter::checkTabs()
{
void setNumCols(int n) { ncols = n; }
///
MathedArray * GetData() const;
- /// Copy every object from position p1 to p2
- void Clear();
protected:
///
void split(int);