]> git.lyx.org Git - lyx.git/blob - src/mathed/array.h
use stream-like syntax for LaTeX output
[lyx.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 #include "math_atom.h"
22
23 class MathScriptInset;
24 class MathMacro;
25 class MathWriteInfo;
26 class MathMetricsInfo;
27 class LaTeXFeatures;
28
29 #ifdef __GNUG__
30 #pragma interface
31 #endif
32
33 /** \class MathArray
34     \brief Low level container for math insets
35     
36     \author Alejandro Aguilar Sierra
37     \author André Pönitz
38     \author Lars Gullik Bjønnes
39     \version February 2001
40   */
41
42 class MathArray  {
43 public:
44         ///
45         typedef std::vector<MathAtom>        buffer_type;
46         ///
47         typedef buffer_type::const_iterator  const_iterator;
48         ///
49         typedef buffer_type::iterator        iterator;
50         ///
51         typedef buffer_type::size_type       size_type;
52
53 public:
54         ///
55         MathArray();
56         ///
57         MathArray(MathArray const &, size_type from, size_type to);
58
59         ///
60         size_type size() const;
61         ///
62         bool empty() const;
63         ///
64         void clear();
65         ///
66         void swap(MathArray &);
67         
68         ///
69         void insert(size_type pos, MathAtom const &);
70         ///
71         void insert(size_type pos, MathArray const &);
72
73         ///
74         void erase(size_type pos1, size_type pos2);
75         ///
76         void erase(size_type pos);
77         ///
78         void erase();
79
80         ///
81         void push_back(MathAtom const &);
82         ///
83         void push_back(MathArray const &);
84         ///
85         void pop_back();
86         ///
87         MathAtom & back();
88
89         ///
90         void dump(std::ostream &) const;
91         ///
92         void dump2(std::ostream &) const;
93         ///
94         void substitute(MathMacro const &);
95
96         ///
97         MathAtom & at(size_type pos);
98         ///
99         MathAtom const & at(size_type pos) const;
100         ///
101         void write(MathWriteInfo & os) const;
102         ///
103         void writeNormal(std::ostream &) const;
104         ///
105         void validate(LaTeXFeatures &) const;
106         ///
107         const_iterator begin() const;   
108         ///
109         const_iterator end() const;     
110         ///
111         iterator begin();
112         ///
113         iterator end();
114         ///
115         MathScriptInset const * asScript(const_iterator it) const;
116 private:
117         /// Buffer
118         buffer_type bf_;
119 };
120
121
122 std::ostream & operator<<(std::ostream & os, MathArray const & ar);
123
124 #endif