]> git.lyx.org Git - lyx.git/blob - src/mathed/array.h
fix pullArg when pressing <Delete> at the end of an cell
[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         void replace(int pos, MathInset * inset);
80         ///
81         bool prev(int & pos) const;
82         ///
83         bool next(int & pos) const;
84         ///
85         bool last(int & pos) const;
86
87
88         ///
89         void push_back(MathInset * inset);
90         ///
91         void push_back(unsigned char, MathTextCodes);
92         ///
93         void push_back(MathArray const &);
94         ///
95         MathInset * back_inset() const;
96
97         ///
98         void dump(std::ostream &) const;
99         ///
100         void dump2(std::ostream &) const;
101         ///
102         void substitute(MathMacro const &);
103         ///
104
105         ///
106         MathInset * nextInset(int pos) const;
107         ///
108         MathInset * prevInset(int pos) const;
109         ///
110         unsigned char GetChar(int pos) const;
111         /// read subsequent chars of the same kind.
112         // pos is afterwards one behind the last char belonging to the string
113         string GetString(int & pos) const;
114         ///
115         MathTextCodes GetCode(int pos) const;
116         ///
117         void setCode(int pos, MathTextCodes t);
118         ///
119         bool isInset(int pos) const;
120         ///
121         void Write(std::ostream &, bool) const;
122         ///
123         void WriteNormal(std::ostream &) const;
124         ///
125         void Validate(LaTeXFeatures &) const;
126 private:
127         ///
128         typedef std::vector<unsigned char>           buffer_type;
129         ///
130         typedef unsigned char                        value_type;
131
132         ///
133         int item_size(int pos) const;
134         /// Buffer
135         buffer_type bf_;
136 };
137
138
139 std::ostream & operator<<(std::ostream & os, MathArray const & ar);
140
141 #endif