mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
fulltext: replace plain pointer by std::unique_ptr<>
This was a plain pointer owing to C compatibility. Replacing it by a unique_ptr<> allows us to make it 'self-desctruct' in the constructor. However, we do this with a special twist: the data is _not_ copied when copying the dive, since the copied dive is not registered in the fulltext system. Hackish, but it should(!) work. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
5c7cfb1057
commit
c9d4ce0c15
4 changed files with 25 additions and 26 deletions
|
|
@ -5,11 +5,6 @@
|
|||
// issues such as COW semantics and UTF-16 encoding, it provides
|
||||
// platform independence and reasonable performance. Therefore,
|
||||
// this is based in QString instead of std::string.
|
||||
//
|
||||
// To make this accessible from C, this does manual memory management:
|
||||
// Every dive is associated with a cache of words. Thus, when deleting
|
||||
// a dive, a function freeing that data has to be called.
|
||||
// TODO: remove this complexity.
|
||||
|
||||
#ifndef FULLTEXT_H
|
||||
#define FULLTEXT_H
|
||||
|
|
@ -17,7 +12,6 @@
|
|||
#include <QString>
|
||||
#include <vector>
|
||||
|
||||
struct full_text_cache;
|
||||
struct dive;
|
||||
void fulltext_register(struct dive *d); // Note: can be called repeatedly
|
||||
void fulltext_unregister(struct dive *d); // Note: can be called repeatedly
|
||||
|
|
@ -30,6 +24,11 @@ enum class StringFilterMode {
|
|||
EXACT = 2
|
||||
};
|
||||
|
||||
// This class caches each dives words, so that we can unregister a dive from the full text search
|
||||
struct full_text_cache {
|
||||
std::vector<QString> words;
|
||||
};
|
||||
|
||||
// A fulltext query. Basically a list of normalized words we search for
|
||||
struct FullTextQuery {
|
||||
std::vector<QString> words;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue