]> git.lyx.org Git - lyx.git/blob - src/mathed/math_data.h
perhaps a fix for the latest crashes
[lyx.git] / src / mathed / math_data.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 MATH_DATA_H
17 #define MATH_DATA_H
18
19 #include <vector>
20
21 #include "math_atom.h"
22
23 class MathMacro;
24 class LaTeXFeatures;
25 class ReplaceData;
26
27
28 #ifdef __GNUG__
29 #pragma interface
30 #endif
31
32
33 /** \class MathArray
34     \brief Low level container for math insets
35     
36     \author Alejandro Aguilar Sierra
37     \author André Pönitz
38     \author Lars Gullik Bjønnes
39     \version February 2001
40   */
41
42 class MathArray  {
43 public:
44         ///
45         typedef std::vector<MathAtom>        buffer_type;
46         ///
47         typedef buffer_type::const_iterator  const_iterator;
48         ///
49         typedef buffer_type::iterator        iterator;
50         ///
51         typedef buffer_type::size_type       size_type;
52         ///
53         typedef buffer_type::size_type       idx_type;
54         ///
55         typedef buffer_type::size_type       pos_type;
56
57 public:
58         ///
59         MathArray();
60         ///
61         MathArray(MathArray const &, size_type from, size_type to);
62         ///
63         MathArray(iterator from, iterator to);
64
65         ///
66         size_type size() const;
67         ///
68         bool empty() const;
69         ///
70         void clear();
71         ///
72         void swap(MathArray &);
73         
74         ///
75         void insert(size_type pos, MathAtom const &);
76         ///
77         void insert(size_type pos, MathArray const &);
78
79         ///
80         void erase(iterator pos1, iterator pos2);
81         ///
82         void erase(iterator pos);
83         ///
84         void erase(size_type pos1, size_type pos2);
85         ///
86         void erase(size_type pos);
87         ///
88         void erase();
89
90         ///
91         void push_back(MathAtom const &);
92         ///
93         void push_back(MathArray const &);
94         ///
95         void pop_back();
96         ///
97         MathAtom & back();
98
99         ///
100         MathAtom & front();
101         ///
102         MathAtom const & front() const;
103
104         ///
105         void dump() const;
106         ///
107         void dump2() const;
108         ///
109         void substitute(MathMacro const &);
110         ///
111         bool match(MathArray const &) const;
112         ///
113         void replace(ReplaceData &);
114
115         ///
116         MathAtom & at(size_type pos);
117         ///
118         MathAtom const & at(size_type pos) const;
119         ///
120         void validate(LaTeXFeatures &) const;
121         ///
122         const_iterator begin() const;   
123         ///
124         const_iterator end() const;     
125         ///
126         iterator begin();
127         ///
128         iterator end();
129
130 private:
131         /// Buffer
132         buffer_type bf_;
133 };
134
135 #endif