]> git.lyx.org Git - lyx.git/blob - src/mathed/array.h
try to do with super- and subscripts what TeX does
[lyx.git] / src / mathed / array.h
1 // -*- C++ -*-
2 /*
3  *  Purpose:     A general purpose resizable array.  
4  *  Author:      Alejandro Aguilar Sierra <asierra@servidor.unam.mx> 
5  *  Created:     January 1996
6  *
7  *  Dependencies: None (almost)
8  *
9  *  Copyright: 1996, Alejandro Aguilar Sierra
10  *                 1997  The LyX Team!
11  *
12  *   You are free to use and modify this code under the terms of
13  *   the GNU General Public Licence version 2 or later.
14  */
15
16 #ifndef MATHEDARRAY_H
17 #define MATHEDARRAY_H
18
19 #include <vector>
20 #include <iosfwd>
21 #include "math_atom.h"
22
23 class MathInset;
24 class MathMacro;
25 class LaTeXFeatures;
26
27 #ifdef __GNUG__
28 #pragma interface
29 #endif
30
31 /** \class MathArray
32     \brief Low level container for math insets
33     
34     \author Alejandro Aguilar Sierra
35     \author André Pönitz
36     \author Lars Gullik Bjønnes
37     \version February 2001
38   */
39
40 class MathArray  {
41 public:
42         ///
43         typedef std::vector<MathAtom>        buffer_type;
44         ///
45         typedef buffer_type::const_iterator  const_iterator;
46         ///
47         typedef buffer_type::iterator        iterator;
48
49 public:
50         ///
51         MathArray();
52         ///
53         MathArray(MathArray const &, int from, int to);
54
55         ///
56         int size() const;
57         ///
58         bool empty() const;
59         ///
60         void clear();
61         ///
62         void swap(MathArray &);
63         
64         ///
65         void insert(int pos, MathInset * inset);
66         ///
67         void insert(int pos, MathArray const &);
68
69         ///
70         void erase(int pos1, int pos2);
71         ///
72         void erase(int pos);
73         ///
74         void erase();
75         ///
76         int last() const;
77
78
79         ///
80         void push_back(MathInset * inset);
81         ///
82         void push_back(MathArray const &);
83         ///
84         void pop_back();
85         ///
86         MathAtom & back();
87
88         ///
89         void dump(std::ostream &) const;
90         ///
91         void dump2(std::ostream &) const;
92         ///
93         void substitute(MathMacro const &);
94
95         ///
96         MathAtom * at(int pos);
97         ///
98         MathAtom const * at(int pos) const;
99         ///
100         void write(std::ostream &, bool) const;
101         ///
102         void writeNormal(std::ostream &) const;
103         ///
104         void validate(LaTeXFeatures &) const;
105         ///
106         const_iterator begin() const;   
107         ///
108         const_iterator end() const;     
109         ///
110         iterator begin();
111         ///
112         iterator end();
113 private:
114         /// Buffer
115         buffer_type bf_;
116 };
117
118
119 std::ostream & operator<<(std::ostream & os, MathArray const & ar);
120
121 #endif