kakoune/src/word_db.hh
Maxime Coste d55d041c6a Add support for interned strings
Use interned strings for Modification contents and word database.
Interned strings are guaranteed not to move in memory and are
reference counted.
2014-10-01 00:20:12 +01:00

38 lines
754 B
C++

#ifndef word_db_hh_INCLUDED
#define word_db_hh_INCLUDED
#include "buffer.hh"
#include "interned_string.hh"
#include <map>
namespace Kakoune
{
// maintain a database of words available in a buffer
class WordDB
{
public:
WordDB(const Buffer& buffer);
std::vector<InternedString> find_prefix(StringView prefix);
std::vector<InternedString> find_subsequence(StringView subsequence);
int get_word_occurences(StringView word) const;
using WordList = std::map<InternedString, int>;
private:
using LineToWords = std::vector<std::vector<InternedString>>;
void update_db();
safe_ptr<const Buffer> m_buffer;
size_t m_timestamp;
WordList m_words;
LineToWords m_line_to_words;
};
}
#endif // word_db_hh_INCLUDED