]> git.lyx.org Git - lyx.git/blob - src/mathed/array.h
add std support
[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
22 #include "mathed/support.h"
23
24 class MathedInset;
25
26 #ifdef __GNUG__
27 #pragma interface
28 #endif
29
30 /** \class MathedArray
31     \brief A resizable array.
32     
33     A general purpose resizable array.
34     
35     \author Alejandro Aguilar Sierra
36     \author André Pönitz
37     \author Lars Gullik Bjønnes
38     \version February 2001
39   */
40 class MathedArray  {
41 public:
42         ///
43         typedef std::vector<byte>           buffer_type;
44         typedef byte                        value_type;
45         typedef buffer_type::size_type      size_type;
46         typedef buffer_type::iterator       iterator;
47         typedef buffer_type::const_iterator const_iterator;
48         
49         ///
50         MathedArray();
51         ///
52         MathedArray(MathedArray const &);
53         ///
54         MathedArray & operator=(MathedArray const &);
55         ///
56         ~MathedArray();
57
58         ///
59         iterator begin();
60         ///
61         iterator end();
62         ///
63         const_iterator begin() const;
64         ///
65         const_iterator end() const;
66         
67         ///
68         int empty() const;
69         ///
70         void clear();
71    
72         ///
73         int last() const;
74         ///
75         void last(int l);
76
77         ///
78         void swap(MathedArray &);
79         ///
80         void shrink(int pos1, int pos2);
81
82 #if 0
83         ///
84         void insert(iterator pos, const_iterator beg, const_iterator end);
85 #else
86         /// Merge \a dx elements from array \a a at \apos.
87         /// This doesn't changes the size (dangerous)
88         void merge(MathedArray const & a, int pos); 
89 #endif
90         ///
91         void raw_pointer_copy(MathedInset ** p, int pos) const;
92 #if 0
93         ///
94         void insertInset(int pos, MathedInset * p, int type);
95         ///
96         MathedInset * getInset(int pos);
97 #else
98         ///
99         void raw_pointer_insert(void * p, int pos, int len);
100 #endif
101         ///
102         void strange_copy(MathedArray * dest, int dpos, int spos, int len);
103         ///
104         byte operator[](int) const;
105         ///
106         byte & operator[](int i);
107         
108         ///
109         void move(int p, int shift);
110         ///
111         void resize(int newsize);
112         /// Make sure we can access at least \a needed elements
113         void need_size(int needed);
114         ///
115         void dump(std::ostream &) const;
116 private:
117         /// Buffer
118         buffer_type bf_;
119 #if 0
120         ///
121         struct InsetTable {
122                 ///
123                 int pos;
124                 ///
125                 MathedInset * inset;
126                 ///
127                 InsetTable(int p, MathedInset * i)
128                         : pos(p), inset(i) {}
129                 
130         };
131         /// 
132         typedef std::vector<InsetTable> InsetList;
133         /// The list of insets in this array.
134         InsetList insetList_;
135 #endif
136         /// Last position inserted.
137         int last_;
138 };
139 #endif