00001
00002
00003 #ifndef AITOOLS_BIGHASHMAP_TERMINAL_HPP
00004 #define AITOOLS_BIGHASHMAP_TERMINAL_HPP
00005
00006 #include <memory>
00007 #include <boost/filesystem.hpp>
00008
00009 #include "core/big_hash_map.hpp"
00010 #include "util/memory.hpp"
00011
00012 namespace bfs = boost::filesystem;
00013
00014 namespace aitools {
00015 namespace bighashmap {
00016
00017 template <typename T>
00018 void
00019 terminal(const bfs::path& idx_file, util::memory_type mem)
00020 {
00021 typedef T value_type;
00022
00023 std::auto_ptr<core::big_hash_map<value_type>> bhm(
00024 core::big_hash_map<value_type>::open(idx_file, mem));
00025
00026 value_type value;
00027 std::string query;
00028 while (true)
00029 {
00030 std::cout << "\nEnter query (type 'q' to exit): ";
00031 std::getline(std::cin, query);
00032 if (query == "q") break;
00033 if (bhm->find(query, value))
00034 {
00035 std::cout << value << std::endl;
00036 }
00037 else
00038 {
00039 std::cout << "Nothing found" << std::endl;
00040 }
00041 }
00042 }
00043
00044 }
00045 }
00046
00047 #endif // AITOOLS_BIGHASHMAP_TERMINAL_HPP