4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Lars Gullik Bjønnes
9 * Full author contact details are available in file CREDITS.
15 #include <boost/utility.hpp>
27 * The class holds all all open buffers, and handles construction
28 * and deletions of new ones.
30 class BufferList : boost::noncopyable {
32 typedef std::vector<Buffer *>::iterator iterator;
33 typedef std::vector<Buffer *>::const_iterator const_iterator;
39 const_iterator begin() const;
42 const_iterator end() const;
44 /// write all buffers, asking the user, returns false if cancelled
47 /// create a new buffer
48 Buffer * newBuffer(std::string const & s, bool ronly = false);
51 void release(Buffer * b);
53 /// Close all open buffers.
56 /// returns a vector with all the buffers filenames
57 std::vector<std::string> const getFileNames() const;
60 void updateIncludedTeXfiles(std::string const &, OutputParams const &);
62 /// emergency save for all buffers
63 void emergencyWriteAll();
65 /// close buffer. Returns false if cancelled by user
66 bool close(Buffer * buf, bool ask);
68 /// return true if no buffers loaded
71 /// return head of buffer list if any
74 /// return back of buffer list if any
77 /// returns true if the buffer exists already
78 bool exists(std::string const &) const;
80 /// returns true if the buffer is loaded
81 bool isLoaded(Buffer const * b) const;
83 /// returns a pointer to the buffer with the given name.
84 Buffer * getBuffer(std::string const &);
85 /// returns a pointer to the buffer with the given number.
86 Buffer * getBuffer(unsigned int);
87 /// returns a pointer to the buffer whose temppath matches the string
88 Buffer * getBufferFromTmp(std::string const &);
90 /** returns a pointer to the buffer that follows argument in
91 * buffer list. The buffer following the last in list is the
94 Buffer * next(Buffer const *) const;
96 /** returns a pointer to the buffer that precedes argument in
97 * buffer list. The buffer preceding the first in list is the
100 Buffer * previous(Buffer const *) const;
102 /// reset current author for all buffers
103 void setCurrentAuthor(std::string const & name, std::string const & email);
106 /// ask to save a buffer on quit, returns false if should cancel
107 bool quitWriteBuffer(Buffer * buf);
109 typedef std::vector<Buffer *> BufferStorage;
111 /// storage of all buffers
112 BufferStorage bstore;
114 /// save emergency file for the given buffer
115 void emergencyWrite(Buffer * buf);
118 /// Implementation is in lyx_main.C
119 extern BufferList & theBufferList();
124 #endif // BUFFERLIST_H