2002-08-11 15:03:52 +00:00
|
|
|
// -*- C++ -*-
|
2003-08-23 00:17:00 +00:00
|
|
|
/**
|
|
|
|
* \file InsetList.h
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author Lars Gullik Bjønnes
|
2003-08-23 00:17:00 +00:00
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
2002-08-11 15:03:52 +00:00
|
|
|
|
|
|
|
#ifndef INSET_LIST_H
|
|
|
|
#define INSET_LIST_H
|
|
|
|
|
2007-10-24 15:32:43 +00:00
|
|
|
#include "insets/InsetCode.h"
|
|
|
|
|
2002-08-11 15:03:52 +00:00
|
|
|
#include "support/types.h"
|
|
|
|
|
2003-10-09 10:52:12 +00:00
|
|
|
#include <vector>
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
|
2007-04-29 13:39:47 +00:00
|
|
|
class Inset;
|
2003-11-21 17:26:11 +00:00
|
|
|
class Buffer;
|
2002-08-11 15:03:52 +00:00
|
|
|
|
|
|
|
///
|
|
|
|
class InsetList {
|
|
|
|
public:
|
2007-10-19 08:57:22 +00:00
|
|
|
///
|
|
|
|
InsetList() {}
|
|
|
|
///
|
|
|
|
InsetList(InsetList const &);
|
2008-08-07 08:50:41 +00:00
|
|
|
/// Partial copy constructor.
|
|
|
|
/// Copy the InsetList contents from \p beg to \p end (without end).
|
|
|
|
InsetList(InsetList const &, pos_type beg, pos_type end);
|
2008-07-23 12:49:22 +00:00
|
|
|
///
|
|
|
|
void setBuffer(Buffer &);
|
2007-10-19 08:57:22 +00:00
|
|
|
|
2002-08-11 15:03:52 +00:00
|
|
|
///
|
2005-01-19 15:03:31 +00:00
|
|
|
class InsetTable {
|
|
|
|
public:
|
|
|
|
///
|
2007-04-29 13:39:47 +00:00
|
|
|
InsetTable(pos_type p, Inset * i) : pos(p), inset(i) {}
|
2002-08-11 15:03:52 +00:00
|
|
|
///
|
2006-10-21 00:16:43 +00:00
|
|
|
pos_type pos;
|
2002-08-11 15:03:52 +00:00
|
|
|
///
|
2007-04-29 13:39:47 +00:00
|
|
|
Inset * inset;
|
2002-08-11 15:03:52 +00:00
|
|
|
};
|
|
|
|
///
|
|
|
|
typedef std::vector<InsetTable> List;
|
|
|
|
///
|
2003-05-29 01:13:18 +00:00
|
|
|
typedef List::iterator iterator;
|
|
|
|
///
|
|
|
|
typedef List::const_iterator const_iterator;
|
2003-07-25 21:20:24 +00:00
|
|
|
|
2002-08-11 15:03:52 +00:00
|
|
|
///
|
|
|
|
~InsetList();
|
|
|
|
///
|
2004-07-25 00:04:42 +00:00
|
|
|
iterator begin() { return list_.begin(); }
|
2002-08-11 15:03:52 +00:00
|
|
|
///
|
2004-07-25 00:04:42 +00:00
|
|
|
iterator end() { return list_.end(); }
|
2002-08-11 15:03:52 +00:00
|
|
|
///
|
2004-07-25 00:04:42 +00:00
|
|
|
const_iterator begin() const { return list_.begin(); }
|
2002-08-11 15:03:52 +00:00
|
|
|
///
|
2004-07-25 00:04:42 +00:00
|
|
|
const_iterator end() const { return list_.end(); }
|
2003-11-25 11:17:27 +00:00
|
|
|
///
|
2004-07-25 00:04:42 +00:00
|
|
|
bool empty() const { return list_.empty(); }
|
2002-08-11 15:03:52 +00:00
|
|
|
///
|
2006-10-21 00:16:43 +00:00
|
|
|
iterator insetIterator(pos_type pos);
|
2003-11-13 13:43:44 +00:00
|
|
|
///
|
2006-10-21 00:16:43 +00:00
|
|
|
const_iterator insetIterator(pos_type pos) const;
|
2002-08-11 15:03:52 +00:00
|
|
|
///
|
2007-04-29 13:39:47 +00:00
|
|
|
void insert(Inset * inset, pos_type pos);
|
2002-08-11 15:03:52 +00:00
|
|
|
///
|
2006-10-21 00:16:43 +00:00
|
|
|
void erase(pos_type pos);
|
2002-08-11 15:03:52 +00:00
|
|
|
///
|
2007-04-29 13:39:47 +00:00
|
|
|
Inset * release(pos_type);
|
2002-08-11 15:03:52 +00:00
|
|
|
///
|
2007-04-29 13:39:47 +00:00
|
|
|
Inset * get(pos_type pos) const;
|
2002-08-11 15:03:52 +00:00
|
|
|
///
|
2006-10-21 00:16:43 +00:00
|
|
|
void increasePosAfterPos(pos_type pos);
|
2002-08-11 15:03:52 +00:00
|
|
|
///
|
2006-10-21 00:16:43 +00:00
|
|
|
void decreasePosAfterPos(pos_type pos);
|
2003-08-17 11:28:23 +00:00
|
|
|
|
2007-10-24 15:32:43 +00:00
|
|
|
/// search for next occurence of an \c Inset type.
|
|
|
|
/// \return the position of the found inset.
|
|
|
|
/// \retval -1 if no \c Inset is found.
|
|
|
|
pos_type find(
|
|
|
|
InsetCode code, ///< Code of inset to find.
|
|
|
|
pos_type startpos = 0 ///< start position for the search.
|
|
|
|
) const;
|
|
|
|
|
|
|
|
/// count occurences of of an \c Inset type.
|
|
|
|
/// \return the number of found inset(s).
|
|
|
|
int count(
|
|
|
|
InsetCode code, ///< Code of inset type to count.
|
|
|
|
pos_type startpos = 0 ///< start position for the counting.
|
|
|
|
) const;
|
|
|
|
|
2002-08-11 15:03:52 +00:00
|
|
|
private:
|
|
|
|
///
|
2004-07-25 00:04:42 +00:00
|
|
|
List list_;
|
2002-08-11 15:03:52 +00:00
|
|
|
};
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
} // namespace lyx
|
|
|
|
|
2002-08-11 15:03:52 +00:00
|
|
|
#endif
|