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 <boost/filesystem.hpp> 11 #include <rime/dict/user_db.h> 12 13 namespace rime { 14 15 class Deployer; 16 17 using UserDictList = vector<string>; 18 19 class 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 string& snapshot_file); 30 bool UpgradeUserDict(const string& dict_name); 31 // returns num of exported entires, -1 denotes failure 32 int Export(const string& dict_name, const string& text_file); 33 // returns num of imported entires, -1 denotes failure 34 int Import(const string& dict_name, const string& text_file); 35 36 bool Synchronize(const string& dict_name); 37 bool SynchronizeAll(); 38 39 protected: 40 Deployer* deployer_; 41 boost::filesystem::path path_; 42 UserDb::Component* user_db_component_; 43 }; 44 45 } // namespace rime 46 47 #endif // RIME_USER_DICT_MANAGER_H_ 48