]> git.lyx.org Git - features.git/blob - src/mathed/array.h
8947ef4d47c00c03ed784959c3123a61ead24766
[features.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 MathMacro;
27 class Painter;
28 class LaTeXFeatures;
29
30 #ifdef __GNUG__
31 #pragma interface
32 #endif
33
34 /** \class MathArray
35     \brief Low level container for math insets
36     
37     \author Alejandro Aguilar Sierra
38     \author André Pönitz
39     \author Lars Gullik Bjønnes
40     \version February 2001
41   */
42 class MathArray  {
43 public:
44         ///
45         MathArray();
46         ///
47         MathArray(MathArray const &);
48         ///
49         MathArray(MathArray const &, int from, int to);
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, unsigned char, 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 erase();
77         ///
78         int last() const;
79
80
81         ///
82         void push_back(MathInset * inset);
83         ///
84         void push_back(unsigned char, MathTextCodes);
85         ///
86         void push_back(MathArray const &);
87         ///
88         void pop_back();
89         ///
90         MathInset * back() const;
91
92         ///
93         void dump(std::ostream &) const;
94         ///
95         void dump2(std::ostream &) const;
96         ///
97         void substitute(MathMacro const &);
98         ///
99
100         ///
101         MathInset * nextInset(int pos);
102         ///
103         MathInset const * nextInset(int pos) const;
104         ///
105         unsigned char getChar(int pos) const;
106         ///
107         MathTextCodes getCode(int pos) const;
108         ///
109         void setCode(int pos, MathTextCodes t);
110         ///
111         void write(std::ostream &, bool) const;
112         ///
113         void writeNormal(std::ostream &) const;
114         ///
115         void validate(LaTeXFeatures &) const;
116 private:
117         ///
118         typedef std::vector<MathInset *>           buffer_type;
119         ///
120         void deep_copy(int pos1, int pos2);
121         /// Buffer
122         buffer_type bf_;
123 };
124
125
126 std::ostream & operator<<(std::ostream & os, MathArray const & ar);
127
128 #endif