home/src/buffer_manager.hh
Maxime Coste e4a23a64fa Support opening files bigger than 2 GiB
The real technical limit is with lines bigger than 2 GiB and buffers
with more than 2 Gi lines, refactor buffer loading to make it possible
to load those files.

Fix an overflow with the hash_data function at the same time
2021-05-28 17:03:41 +10:00

48 lines
1.1 KiB
C++

#ifndef buffer_manager_hh_INCLUDED
#define buffer_manager_hh_INCLUDED
#include "buffer.hh"
#include "vector.hh"
#include <memory>
namespace Kakoune
{
class MappedFile;
class BufferManager : public Singleton<BufferManager>
{
public:
using BufferList = Vector<std::unique_ptr<Buffer>, MemoryDomain::BufferMeta>;
using iterator = BufferList::const_iterator;
~BufferManager();
Buffer* create_buffer(String name, Buffer::Flags flags, BufferLines lines, ByteOrderMark bom, EolFormat eolformat, FsStatus fs_status);
void delete_buffer(Buffer& buffer);
iterator begin() const { return m_buffers.cbegin(); }
iterator end() const { return m_buffers.cend(); }
size_t count() const { return m_buffers.size(); }
Buffer* get_buffer_ifp(StringView name);
Buffer& get_buffer(StringView name);
void arrange_buffers(ConstArrayView<String> first_ones);
Buffer& get_first_buffer();
void backup_modified_buffers();
void clear_buffer_trash();
private:
BufferList m_buffers;
BufferList m_buffer_trash;
};
}
#endif // buffer_manager_hh_INCLUDED