X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fbufferlist.h;h=72105a3e7157d2b81dac0ec79f6228b5e9c387b8;hb=a320e34382a466574fe174da867a7af21d1fe87f;hp=aadda105f1726308e0d4824b2bd0b2e86976d962;hpb=35584afc1162dec2cf9fff79305e95cb3b75aefb;p=lyx.git diff --git a/src/bufferlist.h b/src/bufferlist.h index aadda105f1..72105a3e71 100644 --- a/src/bufferlist.h +++ b/src/bufferlist.h @@ -1,6 +1,6 @@ // -*- C++ -*- /* This file is part of - * ====================================================== + * ====================================================== * * LyX, The Document Processor * Copyright 1995 Matthias Ettrich @@ -9,7 +9,7 @@ * This file is Copyright 1996 * Lars Gullik Bjønnes * - * ======================================================*/ + * ====================================================== */ #ifndef BUFFER_LIST_H #define BUFFER_LIST_H @@ -32,49 +32,31 @@ class BufferStorage { public: /// - BufferStorage(); + typedef vector 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 @@ -85,9 +67,6 @@ public: /// BufferList(); - /// - ~BufferList(); - /// state info enum list_state { /// @@ -100,15 +79,15 @@ public: 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); @@ -123,24 +102,20 @@ public: 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 &); @@ -154,15 +129,15 @@ public: 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: ///