]> git.lyx.org Git - lyx.git/blob - src/mathed/math_data.h
83c3383d4422e5a41e93c88030793acc33c9c4f2
[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 MATHEDARRAY_H
17 #define MATHEDARRAY_H
18
19 #include <vector>
20
21 #include "math_atom.h"
22 #include "LString.h"
23
24 class MathScriptInset;
25 class MathMacro;
26 class LaTeXFeatures;
27
28
29 #ifdef __GNUG__
30 #pragma interface
31 #endif
32
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
43 class MathArray  {
44 public:
45         ///
46         typedef std::vector<MathAtom>        buffer_type;
47         ///
48         typedef buffer_type::const_iterator  const_iterator;
49         ///
50         typedef buffer_type::iterator        iterator;
51         ///
52         typedef buffer_type::size_type       size_type;
53
54 public:
55         ///
56         MathArray();
57         ///
58         MathArray(MathArray const &, size_type from, size_type to);
59         ///
60         MathArray(iterator from, iterator to);
61
62         ///
63         size_type size() const;
64         ///
65         bool empty() const;
66         ///
67         void clear();
68         ///
69         void swap(MathArray &);
70         
71         ///
72         void insert(size_type pos, MathAtom const &);
73         ///
74         void insert(size_type pos, MathArray const &);
75
76         ///
77         void erase(iterator pos1, iterator pos2);
78         ///
79         void erase(iterator pos);
80         ///
81         void erase(size_type pos1, size_type pos2);
82         ///
83         void erase(size_type pos);
84         ///
85         void erase();
86
87         ///
88         void push_back(MathAtom const &);
89         ///
90         void push_back(MathArray const &);
91         ///
92         void pop_back();
93         ///
94         MathAtom & back();
95
96         ///
97         MathAtom & front();
98         ///
99         MathAtom const & front() const;
100
101         ///
102         void dump() const;
103         ///
104         void dump2() const;
105         ///
106         void substitute(MathMacro const &);
107
108         ///
109         MathAtom & at(size_type pos);
110         ///
111         MathAtom const & at(size_type pos) const;
112         ///
113         void validate(LaTeXFeatures &) const;
114         ///
115         const_iterator begin() const;   
116         ///
117         const_iterator end() const;     
118         ///
119         iterator begin();
120         ///
121         iterator end();
122
123 private:
124         /// Buffer
125         buffer_type bf_;
126 };
127
128 #endif