42 lines
1.2 KiB
C++
42 lines
1.2 KiB
C++
#pragma once
|
|
|
|
#include <string>
|
|
#include <list>
|
|
#include <vector>
|
|
#include <set>
|
|
#include <map>
|
|
#include <cstdint>
|
|
|
|
#include <nlohmann/json_fwd.hpp>
|
|
using json = nlohmann::json;
|
|
|
|
#include "filter.h"
|
|
#include "message.h"
|
|
|
|
class Search {
|
|
public:
|
|
Search();
|
|
//copy chatnames from orig, and message list either from orig, or - if set - from list
|
|
Search(const Search& orig, std::list<const Message*>* list = nullptr);
|
|
~Search();
|
|
|
|
void addFile(const std::string& file);
|
|
void finalize(); //stop adding files and finalize deduplication, could be called twice, but then a deduplication is not guaranteed
|
|
|
|
std::list<const Message*> search(const Filter& filter) const;
|
|
const std::string& getChatname(int64_t id) const;
|
|
std::string getShortChatname(int64_t id) const;
|
|
|
|
uint32_t getChatCount() const;
|
|
uint64_t getMessageCount() const;
|
|
private:
|
|
void searchRegex(const std::string& text, bool ignoreCase, std::list<const Message*>& out) const;
|
|
|
|
void runsearch(const Filter& filter, std::list<const Message*>& out) const;
|
|
|
|
void loadMessages(const json& j, int64_t chatid);
|
|
|
|
std::vector<Message> msgs;
|
|
std::set<Message> deduplicate; //intermediate store, for reading files and deduplicate them
|
|
std::map<int64_t, std::string> chatnames;
|
|
}; |