summaryrefslogtreecommitdiff
path: root/src/buffer_manager.hh
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2011-09-22 18:55:23 +0000
committerMaxime Coste <frrrwww@gmail.com>2011-09-22 18:55:23 +0000
commit429536d0f4a7c3cbb6f9c690c3d81ab4a25de581 (patch)
treeb0c6aeefe7b3765a0f010dc2eb54c5a88d3bee98 /src/buffer_manager.hh
parentc3faeb6c058da1790b03b2c50bbba1f7ecc572d3 (diff)
BufferManager: allow iteration on Buffers with begin/end methods
Diffstat (limited to 'src/buffer_manager.hh')
-rw-r--r--src/buffer_manager.hh18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/buffer_manager.hh b/src/buffer_manager.hh
index 06fb04f0..b0cd9518 100644
--- a/src/buffer_manager.hh
+++ b/src/buffer_manager.hh
@@ -12,6 +12,21 @@ namespace Kakoune
class BufferManager
{
public:
+ typedef std::unordered_map<std::string, std::unique_ptr<Buffer>> BufferMap;
+
+ struct iterator : public BufferMap::const_iterator
+ {
+ typedef BufferMap::const_iterator parent_type;
+
+ iterator() {}
+ iterator(const parent_type& other) : parent_type(other) {}
+ Buffer& operator*() const { return *(parent_type::operator*().second); }
+ Buffer* operator->() const { return parent_type::operator*().second.get(); }
+ };
+
+ iterator begin() const { return iterator(m_buffers.begin()); }
+ iterator end() const { return iterator(m_buffers.end()); }
+
void register_buffer(Buffer* buffer);
void delete_buffer(Buffer* buffer);
@@ -23,8 +38,7 @@ public:
private:
BufferManager();
static BufferManager* ms_instance;
-
- std::unordered_map<std::string, std::unique_ptr<Buffer>> m_buffers;
+ BufferMap m_buffers;
};
}