]> git.lyx.org Git - lyx.git/blob - src/mathed/math_data.h
forward search in math insets. ugly. seems to work. don't ask why.
[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 <iosfwd>
20 #include <vector>
21
22 #include "math_atom.h"
23
24 class MathMacro;
25 class LaTeXFeatures;
26 class ReplaceData;
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         typedef buffer_type::size_type       idx_type;
55         ///
56         typedef buffer_type::size_type       pos_type;
57
58 public:
59         ///
60         MathArray();
61         ///
62         MathArray(MathArray const &, size_type from, size_type to);
63         ///
64         MathArray(iterator from, iterator to);
65
66         ///
67         size_type size() const;
68         ///
69         bool empty() const;
70         ///
71         void clear();
72         ///
73         void swap(MathArray &);
74         
75         ///
76         void insert(size_type pos, MathAtom const &);
77         ///
78         void insert(size_type pos, MathArray const &);
79
80         ///
81         void erase(iterator pos1, iterator pos2);
82         ///
83         void erase(iterator pos);
84         ///
85         void erase(size_type pos1, size_type pos2);
86         ///
87         void erase(size_type pos);
88         ///
89         void erase();
90
91         ///
92         void push_back(MathAtom const &);
93         ///
94         void push_back(MathArray const &);
95         ///
96         void pop_back();
97         ///
98         MathAtom & back();
99
100         ///
101         MathAtom & front();
102         ///
103         MathAtom const & front() const;
104
105         ///
106         void dump() const;
107         ///
108         void dump2() const;
109         ///
110         void substitute(MathMacro const &);
111         /// looks for exact match
112         bool match(MathArray const &) const;
113         /// looks for inclusion match starting at pos
114         bool matchpart(MathArray const &, pos_type pos) const;
115         /// looks for containment
116         const_iterator find(MathArray const &) const;
117         ///
118         void replace(ReplaceData &);
119
120         ///
121         MathAtom & at(size_type pos);
122         ///
123         MathAtom const & at(size_type pos) const;
124         ///
125         void validate(LaTeXFeatures &) const;
126         ///
127         const_iterator begin() const;   
128         ///
129         const_iterator end() const;     
130         ///
131         iterator begin();
132         ///
133         iterator end();
134
135 private:
136         /// Buffer
137         buffer_type bf_;
138 };
139
140 ///
141 std::ostream & operator<<(std::ostream & os, MathArray const & ar);
142
143
144 #endif