1999-09-27 18:44:28 +00:00
|
|
|
|
// -*- C++ -*-
|
|
|
|
|
/*
|
2002-03-21 17:42:56 +00:00
|
|
|
|
* Purpose: A general purpose resizable array.
|
|
|
|
|
* Author: Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
|
1999-09-27 18:44:28 +00:00
|
|
|
|
* 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-12-10 10:09:00 +00:00
|
|
|
|
#ifndef MATH_DATA_H
|
|
|
|
|
#define MATH_DATA_H
|
2001-02-12 08:55:14 +00:00
|
|
|
|
|
2001-12-11 10:14:51 +00:00
|
|
|
|
#include <iosfwd>
|
2001-02-09 17:17:08 +00:00
|
|
|
|
#include <vector>
|
2001-11-07 08:51:35 +00:00
|
|
|
|
|
2001-09-11 10:58:17 +00:00
|
|
|
|
#include "math_atom.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2001-04-24 16:13:38 +00:00
|
|
|
|
class MathMacro;
|
2001-11-08 12:06:56 +00:00
|
|
|
|
class LaTeXFeatures;
|
2001-11-16 09:55:37 +00:00
|
|
|
|
class ReplaceData;
|
2001-11-08 12:06:56 +00:00
|
|
|
|
|
2001-02-12 08:55:14 +00:00
|
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
|
#pragma interface
|
|
|
|
|
#endif
|
|
|
|
|
|
2001-11-07 08:51:35 +00:00
|
|
|
|
|
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
|
2002-03-21 17:42:56 +00:00
|
|
|
|
|
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-09-11 10:58:17 +00:00
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
class MathArray {
|
2001-08-09 08:53:16 +00:00
|
|
|
|
public:
|
|
|
|
|
///
|
2001-09-11 10:58:17 +00:00
|
|
|
|
typedef std::vector<MathAtom> buffer_type;
|
2001-08-09 08:53:16 +00:00
|
|
|
|
///
|
|
|
|
|
typedef buffer_type::const_iterator const_iterator;
|
|
|
|
|
///
|
|
|
|
|
typedef buffer_type::iterator iterator;
|
2001-09-14 14:05:57 +00:00
|
|
|
|
///
|
|
|
|
|
typedef buffer_type::size_type size_type;
|
2001-12-10 10:09:00 +00:00
|
|
|
|
///
|
2002-01-08 11:03:34 +00:00
|
|
|
|
typedef buffer_type::difference_type difference_type;
|
|
|
|
|
///
|
2001-12-10 10:09:00 +00:00
|
|
|
|
typedef buffer_type::size_type idx_type;
|
|
|
|
|
///
|
|
|
|
|
typedef buffer_type::size_type pos_type;
|
2001-08-09 08:53:16 +00:00
|
|
|
|
|
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
|
|
|
|
///
|
2002-06-18 15:44:30 +00:00
|
|
|
|
MathArray(MathArray const & ar, size_type from, size_type to);
|
2001-11-09 10:44:24 +00:00
|
|
|
|
///
|
|
|
|
|
MathArray(iterator from, iterator to);
|
2000-04-08 17:02:02 +00:00
|
|
|
|
|
2001-02-14 17:50:58 +00:00
|
|
|
|
///
|
2001-09-14 14:05:57 +00:00
|
|
|
|
size_type 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 &);
|
2002-03-21 17:42:56 +00:00
|
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
|
/// inserts single atom at position pos
|
|
|
|
|
void insert(size_type pos, MathAtom const & at);
|
|
|
|
|
/// inserts multiple atoms at position pos
|
|
|
|
|
void insert(size_type pos, MathArray const & ar);
|
2001-02-14 17:50:58 +00:00
|
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
|
/// erase range from pos1 to pos2
|
2001-11-09 10:44:24 +00:00
|
|
|
|
void erase(iterator pos1, iterator pos2);
|
2002-06-18 15:44:30 +00:00
|
|
|
|
/// erase single atom
|
2001-11-09 10:44:24 +00:00
|
|
|
|
void erase(iterator pos);
|
2002-06-18 15:44:30 +00:00
|
|
|
|
/// erase range from pos1 to pos2
|
2001-09-14 14:05:57 +00:00
|
|
|
|
void erase(size_type pos1, size_type pos2);
|
2002-06-18 15:44:30 +00:00
|
|
|
|
/// erase single atom
|
2001-09-14 14:05:57 +00:00
|
|
|
|
void erase(size_type pos);
|
2002-06-18 15:44:30 +00:00
|
|
|
|
/// erase everythng
|
2001-07-16 15:53:25 +00:00
|
|
|
|
void erase();
|
2001-02-19 14:16:57 +00:00
|
|
|
|
|
2001-02-14 17:50:58 +00:00
|
|
|
|
///
|
2002-06-18 15:44:30 +00:00
|
|
|
|
void push_back(MathAtom const & at);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
///
|
2002-06-18 15:44:30 +00:00
|
|
|
|
void push_back(MathArray const & ar);
|
2001-02-17 18:52:53 +00:00
|
|
|
|
///
|
2001-07-26 06:46:50 +00:00
|
|
|
|
void pop_back();
|
|
|
|
|
///
|
2001-09-11 10:58:17 +00:00
|
|
|
|
MathAtom & back();
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
2001-11-09 16:27:44 +00:00
|
|
|
|
///
|
|
|
|
|
MathAtom & front();
|
|
|
|
|
///
|
|
|
|
|
MathAtom const & front() const;
|
|
|
|
|
|
2001-02-12 08:55:14 +00:00
|
|
|
|
///
|
2001-11-08 12:06:56 +00:00
|
|
|
|
void dump() const;
|
2001-02-12 08:55:14 +00:00
|
|
|
|
///
|
2001-11-08 12:06:56 +00:00
|
|
|
|
void dump2() const;
|
2001-02-12 08:55:14 +00:00
|
|
|
|
///
|
2002-06-18 15:44:30 +00:00
|
|
|
|
void substitute(MathMacro const & macro);
|
2001-11-16 09:55:37 +00:00
|
|
|
|
///
|
|
|
|
|
void replace(ReplaceData &);
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
|
/// looks for exact match
|
|
|
|
|
bool match(MathArray const & ar) const;
|
|
|
|
|
/// looks for inclusion match starting at pos
|
|
|
|
|
bool matchpart(MathArray const & ar, pos_type pos) const;
|
|
|
|
|
/// looks for containment, return == size mean not found
|
|
|
|
|
size_type find(MathArray const & ar) const;
|
|
|
|
|
/// looks for containment, return == size mean not found
|
|
|
|
|
size_type find_last(MathArray const & ar) const;
|
2001-02-12 08:55:14 +00:00
|
|
|
|
///
|
2002-06-18 15:44:30 +00:00
|
|
|
|
bool contains(MathArray const & ar) const;
|
|
|
|
|
|
|
|
|
|
/// write acccess to single atom
|
|
|
|
|
MathAtom & operator[](size_type pos) { return at(pos); }
|
|
|
|
|
/// read access o single atom
|
|
|
|
|
MathAtom const & operator[](size_type pos) const { return at(pos); }
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2002-03-21 17:42:56 +00:00
|
|
|
|
const_iterator begin() const;
|
2001-08-09 08:53:16 +00:00
|
|
|
|
///
|
2002-03-21 17:42:56 +00:00
|
|
|
|
const_iterator end() const;
|
2001-08-09 08:53:16 +00:00
|
|
|
|
///
|
|
|
|
|
iterator begin();
|
|
|
|
|
///
|
|
|
|
|
iterator end();
|
2001-11-07 10:21:51 +00:00
|
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
|
///
|
|
|
|
|
void validate(LaTeXFeatures &) const;
|
|
|
|
|
|
2001-08-09 08:53:16 +00:00
|
|
|
|
private:
|
2002-06-18 15:44:30 +00:00
|
|
|
|
/// is this an exact match at this position?
|
|
|
|
|
bool find1(MathArray const & ar, size_type pos) const;
|
|
|
|
|
/// write acccess to single atom
|
|
|
|
|
MathAtom & at(size_type pos);
|
|
|
|
|
/// read access o single atom
|
|
|
|
|
MathAtom const & at(size_type 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-12-11 10:14:51 +00:00
|
|
|
|
///
|
|
|
|
|
std::ostream & operator<<(std::ostream & os, MathArray const & ar);
|
|
|
|
|
|
|
|
|
|
|
2001-02-12 08:55:14 +00:00
|
|
|
|
#endif
|