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