]> git.lyx.org Git - lyx.git/blob - src/mathed/array.h
remove more forms.h cruft
[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
25 class MathInset;
26 class MathScriptInset;
27 class MathMacro;
28 class Painter;
29
30 #ifdef __GNUG__
31 #pragma interface
32 #endif
33
34 /** \class MathArray
35     \brief A resizable array.
36     
37     A general purpose resizable array.
38     
39     \author Alejandro Aguilar Sierra
40     \author André Pönitz
41     \author Lars Gullik Bjønnes
42     \version February 2001
43   */
44 class MathArray  {
45 public:
46         ///
47         MathArray();
48         ///
49         MathArray(MathArray const &);
50         ///
51         MathArray & operator=(MathArray const &);
52         ///
53         ~MathArray();
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, byte, MathTextCodes);
68         ///
69         void insert(int pos, MathArray const &);
70
71         ///
72         void erase(int pos1, int pos2);
73         ///
74         void erase(int pos);
75         ///
76         void replace(int pos, MathInset * inset);
77         ///
78         bool prev(int & pos) const;
79         ///
80         bool next(int & pos) const;
81         ///
82         bool last(int & pos) const;
83
84
85         ///
86         void push_back(MathInset * inset);
87         ///
88         void push_back(byte, MathTextCodes);
89         ///
90         void push_back(MathArray const &);
91         ///
92         MathInset * back_inset() const;
93
94         ///
95         void dump(std::ostream &) const;
96         ///
97         void dump2(std::ostream &) const;
98         ///
99         void substitute(MathMacro const &);
100         ///
101
102         ///
103         MathInset * GetInset(int pos) const;
104         ///
105         MathScriptInset * prevScriptInset(int pos) const;
106         ///
107         MathScriptInset * nextScriptInset(int pos) const;
108         ///
109         byte GetChar(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 private:
121         ///
122         typedef std::vector<byte>           buffer_type;
123         ///
124         typedef byte                        value_type;
125
126         ///
127         int item_size(int pos) const;
128         /// Buffer
129         buffer_type bf_;
130 };
131
132
133 std::ostream & operator<<(std::ostream & os, MathArray const & ar);
134
135 #endif