]> git.lyx.org Git - lyx.git/blobdiff - src/bufferlist.h
Tiny things found while peering at chset code
[lyx.git] / src / bufferlist.h
index aadda105f1726308e0d4824b2bd0b2e86976d962..72105a3e7157d2b81dac0ec79f6228b5e9c387b8 100644 (file)
@@ -1,6 +1,6 @@
 // -*- C++ -*-
 /* This file is part of
 // -*- C++ -*-
 /* This file is part of
- * ======================================================
+ * ====================================================== 
  * 
  *           LyX, The Document Processor        
  *           Copyright 1995 Matthias Ettrich
  * 
  *           LyX, The Document Processor        
  *           Copyright 1995 Matthias Ettrich
@@ -9,7 +9,7 @@
  *           This file is Copyright 1996
  *           Lars Gullik Bjønnes
  *
  *           This file is Copyright 1996
  *           Lars Gullik Bjønnes
  *
- * ======================================================*/
+ * ====================================================== */
 
 #ifndef BUFFER_LIST_H
 #define BUFFER_LIST_H
 
 #ifndef BUFFER_LIST_H
 #define BUFFER_LIST_H
 class BufferStorage {
 public:
        ///
 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
 /** 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();
 
-       ///
-       ~BufferList();
-
        /// state info
        enum list_state {
                ///
        /// state info
        enum list_state {
                ///
@@ -100,15 +79,15 @@ public:
        list_state getState() { return _state; }
        
        /** loads a LyX file or...
        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
             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);
 
        /// 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.
        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
 
        /// 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);
 
 
        /** 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 &);
 
        ///
        void updateIncludedTeXfiles(string const &);
@@ -154,15 +129,15 @@ public:
        bool close(Buffer *);
 
        ///
        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.
        
        /// 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.
        /// returns a pointer to the buffer with the given number.
-       Buffer* getBuffer(int);
+       Buffer * getBuffer(int);
 
 private:
        ///
 
 private:
        ///