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 * ====================================================== */
24 /** A class to hold all the buffers in a structure
25 The point of this class is to hide from bufferlist what kind
26 of structure the buffers are stored in. Should be no concern for
27 bufferlist if the buffers is in a array or in a linked list.
29 This class should ideally be enclosed inside class BufferList, but that
30 gave me an "internal gcc error".
35 typedef vector<Buffer *> Container;
37 typedef Container::iterator iterator;
39 typedef Container::const_iterator const_iterator;
41 bool empty() const { return container.empty(); }
43 void release(Buffer * buf);
45 Buffer * newBuffer(string const & s, LyXRC *, bool = false);
47 Container::iterator begin() { return container.begin(); }
49 Container::iterator end() { return container.end(); }
51 Container::const_iterator begin() const { return container.begin(); }
53 Container::const_iterator end() const { return container.end(); }
55 Buffer * front() { return container.front(); }
57 Buffer * operator[](int c) { return container[c]; }
59 int size() const { return container.size(); }
66 /** The class governing all the open buffers
67 This class governs all the currently open buffers. Currently all the buffer
68 are located in a static array, soon this will change and we will have a
84 /// returns the state of the bufferlist
85 list_state getState() const { return state_; }
87 /** loads a LyX file or...
88 If the optional argument tolastfiles is false (default is
89 true), the file name will not be added to the last opened
92 Buffer * loadLyXFile(string const & filename,
93 bool tolastfiles = true);
98 /// Saves buffer. Returns false if unsuccesful.
99 bool write(Buffer *, bool makeBackup);
104 /// Close all open buffers.
110 /// Read a file into a buffer readonly or not.
111 Buffer * readFile(string const &, bool ro);
113 /// Make a new file (buffer) using a template
114 Buffer * newFile(string const &, string);
115 /// returns a vector with all the buffers filenames
116 vector<string> getFileNames() const;
119 void updateInset(Inset *, bool = true);
122 int unlockInset(UpdatableInset *);
125 void updateIncludedTeXfiles(string const &);
128 void emergencyWriteAll();
131 Returns false if operation was canceled
133 bool close(Buffer *);
138 /// returns true if the buffer exists already
139 bool exists(string const &) const;
141 /// returns true if the buffer is loaded
142 bool isLoaded(Buffer const * b) const;
144 /// returns a pointer to the buffer with the given name.
145 Buffer * getBuffer(string const &);
146 /// returns a pointer to the buffer with the given number.
147 Buffer * getBuffer(int);
151 BufferStorage bstore;