#define MATHEDARRAY_H
#include <vector>
+#include <iosfwd>
+#include "math_atom.h"
-#include "mathed/support.h"
-
-class MathedInset;
+class MathScriptInset;
+class MathMacro;
+class MathWriteInfo;
+class MathMetricsInfo;
+class LaTeXFeatures;
#ifdef __GNUG__
#pragma interface
#endif
-/** \class MathedArray
- \brief A resizable array.
-
- A general purpose resizable array.
+/** \class MathArray
+ \brief Low level container for math insets
\author Alejandro Aguilar Sierra
\author André Pönitz
\author Lars Gullik Bjønnes
\version February 2001
*/
-class MathedArray {
+
+class MathArray {
public:
///
- typedef std::vector<byte> buffer_type;
- typedef byte value_type;
- typedef buffer_type::size_type size_type;
- typedef buffer_type::iterator iterator;
- typedef buffer_type::const_iterator const_iterator;
-
+ typedef std::vector<MathAtom> buffer_type;
///
- enum {
- ///
- ARRAY_STEP = 16,
- ///
- ARRAY_MIN_SIZE = 4
- };
+ typedef buffer_type::const_iterator const_iterator;
+ ///
+ typedef buffer_type::iterator iterator;
+ ///
+ typedef buffer_type::size_type size_type;
+public:
+ ///
+ MathArray();
///
- explicit
- MathedArray(int size = ARRAY_STEP);
+ MathArray(MathArray const &, size_type from, size_type to);
///
- iterator begin();
+ size_type size() const;
///
- iterator end();
+ bool empty() const;
///
- const_iterator begin() const;
+ void clear();
///
- const_iterator end() const;
+ void swap(MathArray &);
///
- int empty() const;
-
+ void insert(size_type pos, MathAtom const &);
+ ///
+ void insert(size_type pos, MathArray const &);
+
+ ///
+ void erase(size_type pos1, size_type pos2);
///
- int last() const;
+ void erase(size_type pos);
///
- void last(int l);
+ void erase();
-#if 0
///
- void insert(iterator pos, const_iterator beg, const_iterator end);
-#else
- /// Merge \a dx elements from array \a a at \apos.
- /// This doesn't changes the size (dangerous)
- void mergeF(MathedArray * a, int pos, int dx);
-#endif
+ void push_back(MathAtom const &);
///
- void raw_pointer_copy(MathedInset ** p, int pos) const;
-#if 0
+ void push_back(MathArray const &);
///
- void insertInset(int pos, MathedInset * p, int type);
+ void pop_back();
///
- MathedInset * getInset(int pos);
-#else
+ MathAtom & back();
+
///
- void raw_pointer_insert(void * p, int pos, int len);
-#endif
+ void dump(std::ostream &) const;
///
- void strange_copy(MathedArray * dest, int dpos, int spos, int len);
+ void dump2(std::ostream &) const;
///
- byte operator[](int) const;
+ void substitute(MathMacro const &);
+
///
- byte & operator[](int i);
-
+ MathAtom & at(size_type pos);
+ ///
+ MathAtom const & at(size_type pos) const;
+ ///
+ void write(MathWriteInfo & os) const;
///
- void move(int p, int shift);
+ void writeNormal(std::ostream &) const;
///
- void resize(int newsize);
- /// Make sure we can access at least \a needed elements
- void need_size(int needed);
+ void validate(LaTeXFeatures &) const;
+ ///
+ const_iterator begin() const;
+ ///
+ const_iterator end() const;
+ ///
+ iterator begin();
+ ///
+ iterator end();
+ ///
+ MathScriptInset const * asScript(const_iterator it) const;
private:
/// Buffer
buffer_type bf_;
-#if 0
- ///
- struct InsetTable {
- ///
- int pos;
- ///
- MathedInset * inset;
- ///
- InsetTable(int p, MathedInset * i)
- : pos(p), inset(i) {}
-
- };
- ///
- typedef std::vector<InsetTable> InsetList;
- /// The list of insets in this array.
- InsetList insetList_;
-#endif
- /// Last position inserted.
- int last_;
};
+
+
+std::ostream & operator<<(std::ostream & os, MathArray const & ar);
+
#endif