// -*- C++ -*-
/* This file is part of
- * ======================================================
+ * ======================================================
*
* LyX, The Document Processor
* Copyright 1995 Matthias Ettrich
* This file is Copyright 1996
* Lars Gullik Bjønnes
*
- * ======================================================*/
+ * ====================================================== */
#ifndef BUFFER_LIST_H
#define BUFFER_LIST_H
class BufferStorage {
public:
///
- BufferStorage();
+ typedef vector<Buffer *> Container;
///
- bool isEmpty();
+ typedef Container::iterator iterator;
///
- void release(Buffer* buf);
+ bool empty() const { return container.empty(); }
///
- Buffer* newBuffer(string const &s, LyXRC *, bool =false);
-private:
- enum {
- /** The max number of buffers there are possible to have
- loaded at the same time. (this only applies when we use an
- array)
- */
- NUMBER_OF_BUFFERS = 50
- };
-
- /** The Bufferlist is currently implemented as a static array.
- The buffers are new'ed and deleted as reqested.
- */
- Buffer *buffer[NUMBER_OF_BUFFERS];
+ void release(Buffer * buf);
///
- friend class BufferStorage_Iter;
-};
-
-/// An Iterator class for BufferStorage
-class BufferStorage_Iter {
-public:
+ Buffer * newBuffer(string const & s, LyXRC *, bool = false);
///
- BufferStorage_Iter(const BufferStorage & bs)
- { cs=&bs; index=0;}
- /// next
- Buffer* operator() ();
+ Container::iterator begin() { return container.begin(); }
///
- Buffer* operator[] (int a);
-private:
+ Container::iterator end() { return container.end(); }
///
- const BufferStorage *cs;
+ Buffer * front() { return container.front(); }
///
- unsigned char index;
+ Buffer * operator[](int c) { return container[c]; }
+ ///
+ int size() const { return container.size(); }
+private:
+ ///
+ Container container;
};
-
/** The class governing all the open buffers
This class governs all the currently open buffers. Currently all the buffer
are located in a static array, soon this will change and we will have a
///
BufferList();
- ///
- ~BufferList();
-
/// state info
enum list_state {
///
list_state getState() { return _state; }
/** loads a LyX file or...
- If the optional argument tolastfiles is false (default is
+ If the optional argument tolastfiles is false (default is
true), the file name will not be added to the last opened
files list
- */
- Buffer* loadLyXFile(string const & filename,
- bool tolastfiles = true);
+ */
+ Buffer * loadLyXFile(string const & filename,
+ bool tolastfiles = true);
///
- bool isEmpty();
+ bool empty();
/// Saves buffer. Returns false if unsuccesful.
bool write(Buffer *, bool makeBackup = true);
void resize();
/// Read a file into a buffer readonly or not.
- Buffer* readFile(string const &, bool ro);
+ Buffer * readFile(string const &, bool ro);
/// Make a new file (buffer) using a template
- Buffer* newFile(string const &, string);
+ Buffer * newFile(string const &, string);
/** This one must be moved to some other place.
*/
void makePup(int);
- ///** Later with multiple frames this should not be here.
- // */
- //Buffer* switchBuffer(Buffer *from, int);
-
///
- void updateInset(Inset*, bool = true);
+ void updateInset(Inset *, bool = true);
///
- int unlockInset(UpdatableInset*);
+ int unlockInset(UpdatableInset *);
///
void updateIncludedTeXfiles(string const &);
bool close(Buffer *);
///
- Buffer* first();
+ Buffer * first();
/// returns true if the buffer exists already
bool exists(string const &);
/// returns a pointer to the buffer with the given name.
- Buffer* getBuffer(string const &);
+ Buffer * getBuffer(string const &);
/// returns a pointer to the buffer with the given number.
- Buffer* getBuffer(int);
+ Buffer * getBuffer(int);
private:
///