2021-06-25 17:18:57 +00:00
|
|
|
#pragma once
|
2021-06-26 14:48:29 +00:00
|
|
|
|
2021-06-27 05:06:08 +00:00
|
|
|
#include "xcdat/bc_vector_7.hpp"
|
2021-06-27 04:12:35 +00:00
|
|
|
#include "xcdat/bc_vector_8.hpp"
|
2021-06-27 05:06:08 +00:00
|
|
|
|
2021-06-26 14:48:29 +00:00
|
|
|
#include "xcdat/io.hpp"
|
|
|
|
#include "xcdat/trie.hpp"
|
2021-06-26 22:40:15 +00:00
|
|
|
|
2021-06-29 00:06:40 +00:00
|
|
|
#include "xcdat/load_visitor.hpp"
|
|
|
|
#include "xcdat/mmap_visitor.hpp"
|
|
|
|
#include "xcdat/save_visitor.hpp"
|
|
|
|
#include "xcdat/size_visitor.hpp"
|
|
|
|
|
2021-06-26 22:40:15 +00:00
|
|
|
namespace xcdat {
|
|
|
|
|
2021-06-27 05:06:08 +00:00
|
|
|
using trie_7_type = trie<bc_vector_7>;
|
2021-06-27 04:12:35 +00:00
|
|
|
using trie_8_type = trie<bc_vector_8>;
|
2021-06-26 22:40:15 +00:00
|
|
|
|
2021-06-29 00:06:40 +00:00
|
|
|
template <class Trie>
|
2021-06-29 00:12:13 +00:00
|
|
|
Trie mmap(const char* address) {
|
2021-06-29 00:06:40 +00:00
|
|
|
Trie idx;
|
|
|
|
mmap_visitor visitor(address);
|
|
|
|
visitor.visit(idx);
|
|
|
|
return idx;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Trie>
|
2021-06-29 00:12:13 +00:00
|
|
|
Trie load(std::string_view filepath) {
|
2021-06-29 00:06:40 +00:00
|
|
|
Trie idx;
|
|
|
|
load_visitor visitor(filepath);
|
|
|
|
visitor.visit(idx);
|
|
|
|
return idx;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Trie>
|
2021-06-29 00:12:13 +00:00
|
|
|
std::uint64_t save(const Trie& idx, std::string_view filepath) {
|
2021-06-29 00:06:40 +00:00
|
|
|
save_visitor visitor(filepath);
|
|
|
|
visitor.visit(const_cast<Trie&>(idx));
|
|
|
|
return visitor.bytes();
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Trie>
|
2021-06-29 00:12:13 +00:00
|
|
|
std::uint64_t memory_in_bytes(const Trie& idx) {
|
2021-06-29 00:06:40 +00:00
|
|
|
size_visitor visitor;
|
|
|
|
visitor.visit(const_cast<Trie&>(idx));
|
|
|
|
return visitor.bytes();
|
|
|
|
}
|
|
|
|
|
2021-06-27 05:06:08 +00:00
|
|
|
} // namespace xcdat
|