2014-01-16 23:07:42 +01:00
|
|
|
#ifndef word_db_hh_INCLUDED
|
|
|
|
#define word_db_hh_INCLUDED
|
|
|
|
|
|
|
|
#include "buffer.hh"
|
|
|
|
|
2014-01-24 01:56:33 +01:00
|
|
|
#include <map>
|
2014-01-16 23:07:42 +01:00
|
|
|
|
|
|
|
namespace Kakoune
|
|
|
|
{
|
|
|
|
|
|
|
|
class String;
|
|
|
|
|
|
|
|
// maintain a database of words available in a buffer
|
2014-01-24 01:56:33 +01:00
|
|
|
class WordDB
|
2014-01-16 23:07:42 +01:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
WordDB(const Buffer& buffer);
|
|
|
|
|
2014-01-24 01:56:33 +01:00
|
|
|
std::vector<String> find_prefix(const String& prefix);
|
2014-07-30 20:58:34 +02:00
|
|
|
std::vector<String> find_subsequence(const String& subsequence);
|
2014-04-22 20:31:31 +02:00
|
|
|
int get_word_occurences(const String& word) const;
|
2014-01-16 23:07:42 +01:00
|
|
|
|
2014-01-24 01:56:33 +01:00
|
|
|
using WordList = std::map<String, int>;
|
2014-01-16 23:07:42 +01:00
|
|
|
private:
|
2014-01-24 01:56:33 +01:00
|
|
|
using LineToWords = std::vector<std::vector<String>>;
|
2014-01-16 23:07:42 +01:00
|
|
|
|
2014-01-24 01:56:33 +01:00
|
|
|
void update_db();
|
2014-01-16 23:07:42 +01:00
|
|
|
|
2014-05-14 22:19:19 +02:00
|
|
|
safe_ptr<const Buffer> m_buffer;
|
|
|
|
size_t m_timestamp;
|
2014-01-24 01:56:33 +01:00
|
|
|
WordList m_words;
|
2014-01-16 23:07:42 +01:00
|
|
|
LineToWords m_line_to_words;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // word_db_hh_INCLUDED
|
|
|
|
|