]> git.lyx.org Git - lyx.git/blob - src/mathed/math_data.h
007d75850ee8ea4bd80f283b878712495aeebfa3
[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 MathWriteInfo;
27 class MathMetricsInfo;
28 class LaTeXFeatures;
29 class NormalStream;
30 class MapleStream;
31 class MathMLStream;
32 class OctaveStream;
33
34
35 #ifdef __GNUG__
36 #pragma interface
37 #endif
38
39
40 /** \class MathArray
41     \brief Low level container for math insets
42     
43     \author Alejandro Aguilar Sierra
44     \author André Pönitz
45     \author Lars Gullik Bjønnes
46     \version February 2001
47   */
48
49 class MathArray  {
50 public:
51         ///
52         typedef std::vector<MathAtom>        buffer_type;
53         ///
54         typedef buffer_type::const_iterator  const_iterator;
55         ///
56         typedef buffer_type::iterator        iterator;
57         ///
58         typedef buffer_type::size_type       size_type;
59
60 public:
61         ///
62         MathArray();
63         ///
64         MathArray(MathArray const &, size_type from, size_type 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(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         void dump() const;
98         ///
99         void dump2() const;
100         ///
101         void substitute(MathMacro const &);
102
103         ///
104         MathAtom & at(size_type pos);
105         ///
106         MathAtom const & at(size_type pos) const;
107         /// glue chars if necessary
108         void write(MathWriteInfo & os) const;
109         ///
110         void writeNormal(NormalStream &) const;
111         ///
112         void validate(LaTeXFeatures &) const;
113         ///
114         const_iterator begin() const;   
115         ///
116         const_iterator end() const;     
117         ///
118         iterator begin();
119         ///
120         iterator end();
121         ///
122         MathScriptInset const * asScript(const_iterator it) const;
123         /// glues chars with the same attributes into MathStringInsets
124         MathArray glueChars() const;
125         /// insert asterisks in "suitable" places
126         MathArray guessAsterisks() const;
127
128         /// interface to Octave
129         void octavize(OctaveStream &) const;
130         /// interface to Maple
131         void maplize(MapleStream &) const;
132         /// interface to MathML
133         void mathmlize(MathMLStream &) const;
134
135         ///
136         bool isMatrix() const;
137
138 private:
139         /// Buffer
140         buffer_type bf_;
141 };
142
143 #endif