]> git.lyx.org Git - lyx.git/blob - src/mathed/array.h
fix deletion of subscript if superscript is present and vice versa
[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
22 #include "mathed/support.h"
23 #include "math_defs.h"
24 #include "LString.h"
25
26 class MathInset;
27 class MathMacro;
28 class Painter;
29 class LaTeXFeatures;
30
31 #ifdef __GNUG__
32 #pragma interface
33 #endif
34
35 /** \class MathArray
36     \brief Low level container for math insets
37     
38     \author Alejandro Aguilar Sierra
39     \author André Pönitz
40     \author Lars Gullik Bjønnes
41     \version February 2001
42   */
43 class MathArray  {
44 public:
45         ///
46         MathArray();
47         ///
48         MathArray(MathArray const &);
49         ///
50         MathArray(MathArray const &, int from, int to);
51         ///
52         MathArray & operator=(MathArray const &);
53         ///
54         ~MathArray();
55
56         ///
57         int size() const;
58         ///
59         bool empty() const;
60         ///
61         void clear();
62         ///
63         void swap(MathArray &);
64         
65         ///
66         void insert(int pos, MathInset * inset);
67         ///
68         void insert(int pos, unsigned char, MathTextCodes);
69         ///
70         void insert(int pos, MathArray const &);
71
72         ///
73         void erase(int pos1, int pos2);
74         ///
75         void erase(int pos);
76         ///
77         void erase();
78         ///
79         int last() const;
80
81
82         ///
83         void push_back(MathInset * inset);
84         ///
85         void push_back(unsigned char, MathTextCodes);
86         ///
87         void push_back(MathArray const &);
88         ///
89         void pop_back();
90         ///
91         MathInset * back() const;
92
93         ///
94         void dump(std::ostream &) const;
95         ///
96         void dump2(std::ostream &) const;
97         ///
98         void substitute(MathMacro const &);
99         ///
100
101         ///
102         MathInset * nextInset(int pos);
103         ///
104         MathInset const * nextInset(int pos) const;
105         ///
106         unsigned char getChar(int pos) const;
107         /// read subsequent chars of the same kind.
108         // pos is afterwards one behind the last char belonging to the string
109         string getString(int & pos) const;
110         ///
111         MathTextCodes getCode(int pos) const;
112         ///
113         void setCode(int pos, MathTextCodes t);
114         ///
115         void write(std::ostream &, bool) const;
116         ///
117         void writeNormal(std::ostream &) const;
118         ///
119         void validate(LaTeXFeatures &) const;
120 private:
121         ///
122         typedef std::vector<MathInset *>           buffer_type;
123         ///
124         void deep_copy(int pos1, int pos2);
125         /// Buffer
126         buffer_type bf_;
127 };
128
129
130 std::ostream & operator<<(std::ostream & os, MathArray const & ar);
131
132 #endif