2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
6 * Copyright 1995 Matthias Ettrich
7 * Copyright 1995-2000 The LyX Team
9 * This file is Copyright 1996-2000
12 * ====================================================== */
26 /** A class to hold all the buffers in a structure
27 The point of this class is to hide from bufferlist what kind
28 of structure the buffers are stored in. Should be no concern for
29 bufferlist if the buffers is in a array or in a linked list.
31 This class should ideally be enclosed inside class BufferList, but that
32 gave me an "internal gcc error".
37 typedef vector<Buffer *> Container;
39 typedef Container::iterator iterator;
41 typedef Container::const_iterator const_iterator;
43 bool empty() const { return container.empty(); }
45 void release(Buffer * buf);
47 Buffer * newBuffer(string const & s, bool = false);
49 Container::iterator begin() { return container.begin(); }
51 Container::iterator end() { return container.end(); }
53 Container::const_iterator begin() const { return container.begin(); }
55 Container::const_iterator end() const { return container.end(); }
57 Buffer * front() { return container.front(); }
59 Buffer * operator[](int c) { return container[c]; }
61 int size() const { return container.size(); }
68 /** The class governing all the open buffers
69 This class governs all the currently open buffers. Currently all the buffer
70 are located in a static array, soon this will change and we will have a
86 /// returns the state of the bufferlist
87 list_state getState() const { return state_; }
89 /** loads a LyX file or...
90 If the optional argument tolastfiles is false (default is
91 true), the file name will not be added to the last opened
94 Buffer * loadLyXFile(string const & filename,
95 bool tolastfiles = true);
103 /// Close all open buffers.
109 /// Read a file into a buffer readonly or not.
110 Buffer * readFile(string const &, bool ro);
112 /// Make a new file (buffer) using a template
113 Buffer * newFile(string const &, string);
114 /// returns a vector with all the buffers filenames
115 vector<string> getFileNames() const;
118 int unlockInset(UpdatableInset *);
121 void updateIncludedTeXfiles(string const &);
124 void emergencyWriteAll();
127 Returns false if operation was canceled
129 bool close(Buffer *);
134 /// returns true if the buffer exists already
135 bool exists(string const &) const;
137 /// returns true if the buffer is loaded
138 bool isLoaded(Buffer const * b) const;
140 /// returns a pointer to the buffer with the given name.
141 Buffer * getBuffer(string const &);
142 /// returns a pointer to the buffer with the given number.
143 Buffer * getBuffer(int);
147 BufferStorage bstore;