librime: user_dict_manager.h Source File

| librime 1.2 Rime Input Method Engine, the core library

user_dict_manager.h
Go to the documentation of this file.
1//
2// Copyright RIME Developers
3// Distributed under the BSD License
4//
5// 2012-03-23 GONG Chen <chen.sst@gmail.com>
6//
7#ifndef RIME_USER_DICT_MANAGER_H_
8#define RIME_USER_DICT_MANAGER_H_
9
10#include <rime/common.h>
11#include <rime/dict/user_db.h>
12
13namespace rime {
14
15class Deployer;
16
17 using UserDictList = vector<string>;
18
19 class RIME_DLL UserDictManager {
20 public:
21 UserDictManager(Deployer* deployer);
22
23 // If component is null, the current userdb component is used.
24 void GetUserDictList(UserDictList* user_dict_list,
25 UserDb::Component* component = nullptr);
26
27 // CAVEAT: the user dict should be closed before the following operations
28 bool Backup(const string& dict_name);
29 bool Restore(const path& snapshot_file);
30 bool UpgradeUserDict(const string& dict_name);
31 // returns num of exported entries, -1 denotes failure
32 int Export(const string& dict_name, const path& text_file);
33 // returns num of imported entries, -1 denotes failure
34 int Import(const string& dict_name, const path& text_file);
35
36 bool Synchronize(const string& dict_name);
37 bool SynchronizeAll();
38
39 protected:
40 Deployer* deployer_;
41 path path_;
42 UserDb::Component* user_db_component_;
43};
44
45} // namespace rime
46
47#endif // RIME_USER_DICT_MANAGER_H_
common.h
user_db.h
RIME_DLL
#define RIME_DLL
Definition rime_api.h:33
rime
Definition algebra.cc:12
rime::UserDictList
vector< string > UserDictList
Definition user_dict_manager.h:17
rime::path
Definition common.h:84
rime::Deployer
Definition deployer.h:32
rime::UserDb::Component
Abstract class for a user db component.
Definition user_db.h:44
rime::UserDictManager::Restore
bool Restore(const path &snapshot_file)
Definition user_dict_manager.cc:73
rime::UserDictManager::deployer_
Deployer * deployer_
Definition user_dict_manager.h:40
rime::UserDictManager::GetUserDictList
void GetUserDictList(UserDictList *user_dict_list, UserDb::Component *component=nullptr)
Definition user_dict_manager.cc:30
rime::UserDictManager::Synchronize
bool Synchronize(const string &dict_name)
Definition user_dict_manager.cc:178
rime::UserDictManager::Import
int Import(const string &dict_name, const path &text_file)
Definition user_dict_manager.cc:131
rime::UserDictManager::SynchronizeAll
bool SynchronizeAll()
Definition user_dict_manager.cc:210
rime::UserDictManager::UserDictManager
UserDictManager(Deployer *deployer)
Definition user_dict_manager.cc:23
rime::UserDictManager::Backup
bool Backup(const string &dict_name)
Definition user_dict_manager.cc:51
rime::UserDictManager::user_db_component_
UserDb::Component * user_db_component_
Definition user_dict_manager.h:42
rime::UserDictManager::UpgradeUserDict
bool UpgradeUserDict(const string &dict_name)
Definition user_dict_manager.cc:154
rime::UserDictManager::Export
int Export(const string &dict_name, const path &text_file)
Definition user_dict_manager.cc:107
rime::UserDictManager::path_
path path_
Definition user_dict_manager.h:41