]> git.lyx.org Git - features.git/blob - src/mathed/array.h
24c9e4fd0b257d727a6bc3aec052470c9ed1c590
[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 "math_atom.h"
23 #include "LString.h"
24
25 class MathScriptInset;
26 class MathMacro;
27 class MathWriteInfo;
28 class MathMetricsInfo;
29 class LaTeXFeatures;
30
31 #ifdef __GNUG__
32 #pragma interface
33 #endif
34
35
36 /** \class MathArray
37     \brief Low level container for math insets
38     
39     \author Alejandro Aguilar Sierra
40     \author André Pönitz
41     \author Lars Gullik Bjønnes
42     \version February 2001
43   */
44
45 class MathArray  {
46 public:
47         ///
48         typedef std::vector<MathAtom>        buffer_type;
49         ///
50         typedef buffer_type::const_iterator  const_iterator;
51         ///
52         typedef buffer_type::iterator        iterator;
53         ///
54         typedef buffer_type::size_type       size_type;
55
56 public:
57         ///
58         MathArray();
59         ///
60         MathArray(MathArray const &, size_type from, size_type 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(size_type pos1, size_type pos2);
78         ///
79         void erase(size_type pos);
80         ///
81         void erase();
82
83         ///
84         void push_back(MathAtom const &);
85         ///
86         void push_back(MathArray const &);
87         ///
88         void pop_back();
89         ///
90         MathAtom & back();
91
92         ///
93         void dump(std::ostream &) const;
94         ///
95         void dump2(std::ostream &) const;
96         ///
97         void substitute(MathMacro const &);
98
99         ///
100         MathAtom & at(size_type pos);
101         ///
102         MathAtom const & at(size_type pos) const;
103         /// glue chars if necessary
104         void write(MathWriteInfo & os) const;
105         ///
106         void writeNormal(std::ostream &) const;
107         ///
108         void validate(LaTeXFeatures &) const;
109         ///
110         const_iterator begin() const;   
111         ///
112         const_iterator end() const;     
113         ///
114         iterator begin();
115         ///
116         iterator end();
117         ///
118         MathScriptInset const * asScript(const_iterator it) const;
119         /// glues chars with the same attributes into MathStringInsets
120         MathArray glueChars() const;
121         /// insert asterisks in "suitable" places
122         MathArray guessAsterisks() const;
123
124         /// interface to Octave
125         string octavize() const;
126         /// interface to Maple
127         string maplize() const;
128         /// interface to MathML
129         string mathmlize() const;
130
131         ///
132         bool isMatrix() const;
133
134 private:
135         /// Buffer
136         buffer_type bf_;
137 };
138
139
140 std::ostream & operator<<(std::ostream & os, MathArray const & ar);
141
142 #endif