1999-09-27 18:44:28 +00:00
|
|
|
|
// -*- C++ -*-
|
|
|
|
|
/*
|
|
|
|
|
* Purpose: A general purpose resizable array.
|
|
|
|
|
* Author: Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
|
|
|
|
|
* Created: January 1996
|
|
|
|
|
*
|
|
|
|
|
* Dependencies: None (almost)
|
|
|
|
|
*
|
2000-03-09 03:36:48 +00:00
|
|
|
|
* Copyright: 1996, Alejandro Aguilar Sierra
|
1999-09-27 18:44:28 +00:00
|
|
|
|
* 1997 The LyX Team!
|
|
|
|
|
*
|
|
|
|
|
* You are free to use and modify this code under the terms of
|
|
|
|
|
* the GNU General Public Licence version 2 or later.
|
|
|
|
|
*/
|
|
|
|
|
|
2001-02-12 08:55:14 +00:00
|
|
|
|
#ifndef MATHEDARRAY_H
|
|
|
|
|
#define MATHEDARRAY_H
|
|
|
|
|
|
2001-02-09 17:17:08 +00:00
|
|
|
|
#include <vector>
|
2001-02-28 17:21:16 +00:00
|
|
|
|
#include <iosfwd>
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2001-02-13 19:10:18 +00:00
|
|
|
|
#include "mathed/support.h"
|
2001-04-27 12:35:55 +00:00
|
|
|
|
#include "math_defs.h"
|
2001-07-06 12:09:32 +00:00
|
|
|
|
#include "LString.h"
|
2001-02-12 08:55:14 +00:00
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
class MathInset;
|
2001-04-24 16:13:38 +00:00
|
|
|
|
class MathMacro;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
class Painter;
|
2001-07-13 14:54:56 +00:00
|
|
|
|
class LaTeXFeatures;
|
2001-02-12 08:55:14 +00:00
|
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
|
#pragma interface
|
|
|
|
|
#endif
|
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
/** \class MathArray
|
2001-07-12 07:18:29 +00:00
|
|
|
|
\brief Low level container for math insets
|
2001-02-12 08:55:14 +00:00
|
|
|
|
|
|
|
|
|
\author Alejandro Aguilar Sierra
|
|
|
|
|
\author Andr<EFBFBD> P<EFBFBD>nitz
|
|
|
|
|
\author Lars Gullik Bj<EFBFBD>nnes
|
|
|
|
|
\version February 2001
|
1999-09-27 18:44:28 +00:00
|
|
|
|
*/
|
2001-06-25 00:06:33 +00:00
|
|
|
|
class MathArray {
|
1999-09-27 18:44:28 +00:00
|
|
|
|
public:
|
2001-02-09 17:17:08 +00:00
|
|
|
|
///
|
2001-06-25 00:06:33 +00:00
|
|
|
|
MathArray();
|
2001-02-19 14:16:57 +00:00
|
|
|
|
///
|
2001-06-25 00:06:33 +00:00
|
|
|
|
MathArray(MathArray const &);
|
2001-02-19 14:16:57 +00:00
|
|
|
|
///
|
2001-07-16 15:53:25 +00:00
|
|
|
|
MathArray(MathArray const &, int from, int to);
|
|
|
|
|
///
|
2001-06-25 00:06:33 +00:00
|
|
|
|
MathArray & operator=(MathArray const &);
|
2001-02-19 14:16:57 +00:00
|
|
|
|
///
|
2001-06-25 00:06:33 +00:00
|
|
|
|
~MathArray();
|
2000-04-08 17:02:02 +00:00
|
|
|
|
|
2001-02-14 17:50:58 +00:00
|
|
|
|
///
|
2001-06-25 00:06:33 +00:00
|
|
|
|
int size() const;
|
2001-02-14 17:50:58 +00:00
|
|
|
|
///
|
2001-06-25 00:06:33 +00:00
|
|
|
|
bool empty() const;
|
2001-02-14 17:50:58 +00:00
|
|
|
|
///
|
2001-06-25 00:06:33 +00:00
|
|
|
|
void clear();
|
2001-02-14 17:50:58 +00:00
|
|
|
|
///
|
2001-06-25 00:06:33 +00:00
|
|
|
|
void swap(MathArray &);
|
2001-02-14 17:50:58 +00:00
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2001-06-25 00:06:33 +00:00
|
|
|
|
void insert(int pos, MathInset * inset);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2001-07-13 11:32:22 +00:00
|
|
|
|
void insert(int pos, unsigned char, MathTextCodes);
|
2001-02-12 08:55:14 +00:00
|
|
|
|
///
|
2001-06-25 00:06:33 +00:00
|
|
|
|
void insert(int pos, MathArray const &);
|
2001-02-14 17:50:58 +00:00
|
|
|
|
|
2001-02-19 14:16:57 +00:00
|
|
|
|
///
|
2001-06-25 00:06:33 +00:00
|
|
|
|
void erase(int pos1, int pos2);
|
|
|
|
|
///
|
|
|
|
|
void erase(int pos);
|
2001-02-20 13:16:07 +00:00
|
|
|
|
///
|
2001-07-16 15:53:25 +00:00
|
|
|
|
void erase();
|
|
|
|
|
///
|
2001-06-25 00:06:33 +00:00
|
|
|
|
void replace(int pos, MathInset * inset);
|
|
|
|
|
///
|
|
|
|
|
bool prev(int & pos) const;
|
|
|
|
|
///
|
|
|
|
|
bool next(int & pos) const;
|
|
|
|
|
///
|
|
|
|
|
bool last(int & pos) const;
|
|
|
|
|
|
2001-02-19 14:16:57 +00:00
|
|
|
|
|
2001-02-14 17:50:58 +00:00
|
|
|
|
///
|
2001-06-25 00:06:33 +00:00
|
|
|
|
void push_back(MathInset * inset);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2001-07-13 11:32:22 +00:00
|
|
|
|
void push_back(unsigned char, MathTextCodes);
|
2001-02-17 18:52:53 +00:00
|
|
|
|
///
|
2001-06-25 00:06:33 +00:00
|
|
|
|
void push_back(MathArray const &);
|
2001-02-17 18:52:53 +00:00
|
|
|
|
///
|
2001-07-26 06:46:50 +00:00
|
|
|
|
void pop_back();
|
|
|
|
|
///
|
2001-06-25 00:06:33 +00:00
|
|
|
|
MathInset * back_inset() const;
|
|
|
|
|
|
2001-02-12 08:55:14 +00:00
|
|
|
|
///
|
2001-06-25 00:06:33 +00:00
|
|
|
|
void dump(std::ostream &) const;
|
2001-02-12 08:55:14 +00:00
|
|
|
|
///
|
2001-06-25 00:06:33 +00:00
|
|
|
|
void dump2(std::ostream &) const;
|
2001-02-12 08:55:14 +00:00
|
|
|
|
///
|
2001-06-25 00:06:33 +00:00
|
|
|
|
void substitute(MathMacro const &);
|
2001-02-12 08:55:14 +00:00
|
|
|
|
///
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
2001-02-12 08:55:14 +00:00
|
|
|
|
///
|
2001-07-12 07:18:29 +00:00
|
|
|
|
MathInset * nextInset(int pos) const;
|
2001-02-28 17:21:16 +00:00
|
|
|
|
///
|
2001-07-12 07:18:29 +00:00
|
|
|
|
MathInset * prevInset(int pos) const;
|
2001-06-27 14:10:35 +00:00
|
|
|
|
///
|
2001-07-13 11:32:22 +00:00
|
|
|
|
unsigned char GetChar(int pos) const;
|
2001-07-06 12:09:32 +00:00
|
|
|
|
/// read subsequent chars of the same kind.
|
|
|
|
|
// pos is afterwards one behind the last char belonging to the string
|
|
|
|
|
string GetString(int & pos) const;
|
2001-04-24 16:13:38 +00:00
|
|
|
|
///
|
2001-06-25 00:06:33 +00:00
|
|
|
|
MathTextCodes GetCode(int pos) const;
|
2001-04-24 16:13:38 +00:00
|
|
|
|
///
|
2001-07-03 07:56:55 +00:00
|
|
|
|
void setCode(int pos, MathTextCodes t);
|
|
|
|
|
///
|
2001-06-25 00:06:33 +00:00
|
|
|
|
bool isInset(int pos) const;
|
2001-04-27 12:35:55 +00:00
|
|
|
|
///
|
2001-07-26 06:56:43 +00:00
|
|
|
|
void write(std::ostream &, bool) const;
|
2001-04-27 12:35:55 +00:00
|
|
|
|
///
|
2001-07-26 06:56:43 +00:00
|
|
|
|
void writeNormal(std::ostream &) const;
|
2001-07-13 14:54:56 +00:00
|
|
|
|
///
|
2001-07-26 06:56:43 +00:00
|
|
|
|
void validate(LaTeXFeatures &) const;
|
2001-02-12 08:55:14 +00:00
|
|
|
|
private:
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2001-07-13 11:32:22 +00:00
|
|
|
|
typedef std::vector<unsigned char> buffer_type;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2001-07-13 11:32:22 +00:00
|
|
|
|
typedef unsigned char value_type;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
int item_size(int pos) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
/// Buffer
|
2001-02-12 08:55:14 +00:00
|
|
|
|
buffer_type bf_;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
};
|
2001-04-24 16:13:38 +00:00
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
|
|
|
|
std::ostream & operator<<(std::ostream & os, MathArray const & ar);
|
2001-04-24 16:13:38 +00:00
|
|
|
|
|
2001-02-12 08:55:14 +00:00
|
|
|
|
#endif
|