]> git.lyx.org Git - lyx.git/blob - src/mathed/array.h
prepare infrastructure for multicell selection
[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 & operator=(MathArray const &);
51         ///
52         ~MathArray();
53
54         ///
55         int size() const;
56         ///
57         bool empty() const;
58         ///
59         void clear();
60         ///
61         void swap(MathArray &);
62         
63         ///
64         void insert(int pos, MathInset * inset);
65         ///
66         void insert(int pos, unsigned char, MathTextCodes);
67         ///
68         void insert(int pos, MathArray const &);
69
70         ///
71         void erase(int pos1, int pos2);
72         ///
73         void erase(int pos);
74         ///
75         void replace(int pos, MathInset * inset);
76         ///
77         bool prev(int & pos) const;
78         ///
79         bool next(int & pos) const;
80         ///
81         bool last(int & pos) const;
82
83
84         ///
85         void push_back(MathInset * inset);
86         ///
87         void push_back(unsigned char, MathTextCodes);
88         ///
89         void push_back(MathArray const &);
90         ///
91         MathInset * back_inset() 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) const;
103         ///
104         MathInset * prevInset(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         bool isInset(int pos) const;
116         ///
117         void Write(std::ostream &, bool) const;
118         ///
119         void WriteNormal(std::ostream &) const;
120         ///
121         void Validate(LaTeXFeatures &) const;
122 private:
123         ///
124         typedef std::vector<unsigned char>           buffer_type;
125         ///
126         typedef unsigned char                        value_type;
127
128         ///
129         int item_size(int pos) const;
130         /// Buffer
131         buffer_type bf_;
132 };
133
134
135 std::ostream & operator<<(std::ostream & os, MathArray const & ar);
136
137 #endif