]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/array.h
use stream-like syntax for LaTeX output
[lyx.git] / src / mathed / array.h
index e0583eba58831d749637a2e77b67baf52c9b59b4..db0f1d4ea5840f37ad044815c19a5c024c81958b 100644 (file)
 
 #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;
        ///
-       MathedArray();
+       typedef buffer_type::const_iterator  const_iterator;
        ///
-       MathedArray(MathedArray const &);
+       typedef buffer_type::iterator        iterator;
+       ///
+       typedef buffer_type::size_type       size_type;
+
+public:
        ///
-       MathedArray & operator=(MathedArray const &);
+       MathArray();
        ///
-       ~MathedArray();
+       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 clear();
-   
+       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();
 
        ///
-       void swap(MathedArray &);
+       void push_back(MathAtom const &);
+       ///
+       void push_back(MathArray const &);
        ///
-       void shrink(int pos1, int pos2);
+       void pop_back();
+       ///
+       MathAtom & back();
 
-#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 merge(MathedArray const & a, int pos); 
-#endif
+       void dump(std::ostream &) const;
        ///
-       void raw_pointer_copy(MathedInset ** p, int pos) const;
-#if 0
+       void dump2(std::ostream &) const;
        ///
-       void insertInset(int pos, MathedInset * p, int type);
+       void substitute(MathMacro const &);
+
        ///
-       MathedInset * getInset(int pos);
-#else
+       MathAtom & at(size_type pos);
        ///
-       void raw_pointer_insert(void * p, int pos);
-#endif
+       MathAtom const & at(size_type pos) const;
        ///
-       void strange_copy(MathedArray * dest, int dpos, int spos, int len);
+       void write(MathWriteInfo & os) const;
        ///
-       byte operator[](int) const;
+       void writeNormal(std::ostream &) const;
        ///
-       byte & operator[](int i);
-       
+       void validate(LaTeXFeatures &) const;
        ///
-       void move(int p, int shift);
+       const_iterator begin() const;   
        ///
-       void resize(int newsize);
-       /// Make sure we can access at least \a needed elements
-       void need_size(int needed);
+       const_iterator end() const;     
        ///
-       void dump(std::ostream &) const;
+       iterator begin();
        ///
-       void dump2(std::ostream &) const;
-       /// creates copies of all embedded insets
-       void deep_copy();
+       iterator end();
        ///
-       void substitute(MathMacro *);
+       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_;
 };
 
-inline 
-std::ostream & operator<<(std::ostream & os, MathedArray const & ar)
-{
-       ar.dump(os);
-       return os;
-}
+
+std::ostream & operator<<(std::ostream & os, MathArray const & ar);
 
 #endif