6 #ifndef _FCITX_LIBIME_CORE_INPUTBUFFER_H_ 7 #define _FCITX_LIBIME_CORE_INPUTBUFFER_H_ 10 #include <string_view> 11 #include <boost/iterator/iterator_categories.hpp> 12 #include <boost/iterator/iterator_facade.hpp> 13 #include <fcitx-utils/inputbuffer.h> 14 #include <libime/core/libimecore_export.h> 17 class InputBufferPrivate;
19 class LIBIMECORE_EXPORT
InputBuffer :
public fcitx::InputBuffer {
22 :
public boost::iterator_facade<iterator, std::string_view,
23 boost::bidirectional_traversal_tag,
28 : buffer_(buffer), idx_(idx) {}
30 bool equal(
iterator const &other)
const {
31 return buffer_ == other.buffer_ && idx_ == other.idx_;
34 void increment() { idx_++; }
36 void decrement() { idx_--; }
38 std::string_view dereference()
const {
return buffer_->at(idx_); }
45 using fcitx::InputBuffer::InputBuffer;
47 using fcitx::InputBuffer::type;
49 bool type(std::string_view s) {
return type(s.data(), s.length()); }
50 std::string_view at(
size_t i)
const;
52 std::string_view operator[](
size_t i)
const {
return at(i); }
54 iterator begin() {
return {
this, 0}; }
56 iterator end() {
return {
this, size()}; }
60 #endif // _FCITX_LIBIME_CORE_INPUTBUFFER_H_