diff --git a/src/rime/config/config_types.cc b/src/rime/config/config_types.cc index 47429f0b3..25e299621 100644 --- a/src/rime/config/config_types.cc +++ b/src/rime/config/config_types.cc @@ -6,7 +6,6 @@ // #include #include -#include #include #include @@ -61,7 +60,7 @@ bool ConfigValue::GetInt(int* value) const { } // decimal try { - *value = boost::lexical_cast(value_); + *value = std::stoi(value_); } catch (...) { return false; } @@ -72,7 +71,7 @@ bool ConfigValue::GetDouble(double* value) const { if (!value || value_.empty()) return false; try { - *value = boost::lexical_cast(value_); + *value = std::stod(value_); } catch (...) { return false; } @@ -92,12 +91,12 @@ bool ConfigValue::SetBool(bool value) { } bool ConfigValue::SetInt(int value) { - value_ = boost::lexical_cast(value); + value_ = std::to_string(value); return true; } bool ConfigValue::SetDouble(double value) { - value_ = boost::lexical_cast(value); + value_ = std::to_string(value); return true; } diff --git a/src/rime/dict/entry_collector.cc b/src/rime/dict/entry_collector.cc index 738133132..a91c60d38 100644 --- a/src/rime/dict/entry_collector.cc +++ b/src/rime/dict/entry_collector.cc @@ -8,7 +8,6 @@ #include #include #include -#include #include #include #include diff --git a/src/rime/dict/preset_vocabulary.cc b/src/rime/dict/preset_vocabulary.cc index 218a98bed..4596621a1 100644 --- a/src/rime/dict/preset_vocabulary.cc +++ b/src/rime/dict/preset_vocabulary.cc @@ -5,7 +5,6 @@ // 2011-11-27 GONG Chen // #include -#include #include #include #include @@ -74,7 +73,7 @@ bool PresetVocabulary::GetWeightForEntry(const string& key, double* weight) { if (!db_ || !db_->Fetch(key, &weight_str)) return false; try { - *weight = boost::lexical_cast(weight_str); + *weight = std::stod(weight_str); } catch (...) { return false; } @@ -105,7 +104,7 @@ bool PresetVocabulary::IsQualifiedPhrase(const string& phrase, return false; } if (min_phrase_weight_ > 0.0) { - double weight = boost::lexical_cast(weight_str); + double weight = std::stod(weight_str); if (weight < min_phrase_weight_) return false; } diff --git a/src/rime/dict/reverse_lookup_dictionary.cc b/src/rime/dict/reverse_lookup_dictionary.cc index 117e81e76..b9d1042c6 100644 --- a/src/rime/dict/reverse_lookup_dictionary.cc +++ b/src/rime/dict/reverse_lookup_dictionary.cc @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include diff --git a/src/rime/dict/table_db.cc b/src/rime/dict/table_db.cc index 0b92ba2e5..59bc2cd39 100644 --- a/src/rime/dict/table_db.cc +++ b/src/rime/dict/table_db.cc @@ -5,7 +5,6 @@ // 2013-04-18 GONG Chen // #include -#include #include #include @@ -28,7 +27,7 @@ static bool rime_table_entry_parser(const Tsv& row, UserDbValue v; if (row.size() >= 3 && !row[2].empty()) { try { - v.commits = boost::lexical_cast(row[2]); + v.commits = std::stoi(row[2]); const double kS = 1e8; v.dee = (v.commits + 1) / kS; } catch (...) { @@ -51,7 +50,7 @@ static bool rime_table_entry_formatter(const string& key, return false; boost::algorithm::trim(row[0]); // remove trailing space row[0].swap(row[1]); - row.push_back(boost::lexical_cast(v.commits)); + row.push_back(std::to_string(v.commits)); return true; } diff --git a/src/rime/dict/user_db.cc b/src/rime/dict/user_db.cc index 21d32b98a..3aca42100 100644 --- a/src/rime/dict/user_db.cc +++ b/src/rime/dict/user_db.cc @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include @@ -34,11 +33,11 @@ bool UserDbValue::Unpack(const string& value) { string v(k_eq_v.substr(eq + 1)); try { if (k == "c") { - commits = boost::lexical_cast(v); + commits = std::stoi(v); } else if (k == "d") { - dee = (std::min)(10000.0, boost::lexical_cast(v)); + dee = (std::min)(10000.0, std::stod(v)); } else if (k == "t") { - tick = boost::lexical_cast(v); + tick = std::stoul(v); } } catch (...) { LOG(ERROR) << "failed in parsing key-value from userdb entry '" << k_eq_v @@ -170,7 +169,7 @@ static TickCount get_tick_count(Db* db) { string tick; if (db && db->MetaFetch("/tick", &tick)) { try { - return boost::lexical_cast(tick); + return std::stoul(tick); } catch (...) { } } @@ -190,7 +189,7 @@ UserDbMerger::~UserDbMerger() { bool UserDbMerger::MetaPut(const string& key, const string& value) { if (key == "/tick") { try { - their_tick_ = boost::lexical_cast(value); + their_tick_ = std::stoul(value); max_tick_ = (std::max)(our_tick_, their_tick_); } catch (...) { } @@ -225,7 +224,7 @@ void UserDbMerger::CloseMerge() { return; Deployer& deployer(Service::instance().deployer()); try { - db_->MetaUpdate("/tick", boost::lexical_cast(max_tick_)); + db_->MetaUpdate("/tick", std::to_string(max_tick_)); db_->MetaUpdate("/user_id", deployer.user_id); } catch (...) { LOG(ERROR) << "failed to update tick count."; diff --git a/src/rime/dict/user_dictionary.cc b/src/rime/dict/user_dictionary.cc index 48751a5e7..73630610f 100644 --- a/src/rime/dict/user_dictionary.cc +++ b/src/rime/dict/user_dictionary.cc @@ -8,7 +8,6 @@ #include #include #include -#include #include #include #include @@ -381,7 +380,7 @@ bool UserDictionary::UpdateEntry(const DictEntry& entry, bool UserDictionary::UpdateTickCount(TickCount increment) { tick_ += increment; try { - return db_->MetaUpdate("/tick", boost::lexical_cast(tick_)); + return db_->MetaUpdate("/tick", std::to_string(tick_)); } catch (...) { return false; } @@ -397,7 +396,7 @@ bool UserDictionary::FetchTickCount() { // an earlier version mistakenly wrote tick count into an empty key if (!db_->MetaFetch("/tick", &value) && !db_->Fetch("", &value)) return false; - tick_ = boost::lexical_cast(value); + tick_ = std::stoul(value); return true; } catch (...) { // tick_ = 0; diff --git a/src/rime/gear/key_binder.cc b/src/rime/gear/key_binder.cc index 32631e3a9..818e85cde 100644 --- a/src/rime/gear/key_binder.cc +++ b/src/rime/gear/key_binder.cc @@ -5,7 +5,6 @@ // 2011-11-23 GONG Chen // #include -#include #include #include #include @@ -79,7 +78,7 @@ inline static bool is_switch_index(const string& option) { static Switches::SwitchOption switch_by_index(Switches& switches, const string& option) { try { - size_t index = boost::lexical_cast(option.substr(1)); + size_t index = std::stoul(option.substr(1)); return switches.ByIndex(index); } catch (...) { } diff --git a/src/rime/lever/customizer.cc b/src/rime/lever/customizer.cc index ab10db46a..32bd8a298 100644 --- a/src/rime/lever/customizer.cc +++ b/src/rime/lever/customizer.cc @@ -5,7 +5,6 @@ // 2011-12-12 GONG Chen // #include -#include #include #include #include @@ -73,7 +72,7 @@ bool Customizer::UpdateConfigFile() { } string customization; if (!custom_path.empty() && fs::exists(custom_path)) { - customization = boost::lexical_cast(Checksum(custom_path.string())); + customization = std::to_string(Checksum(custom_path.string())); } if (applied_customization != customization) { need_update = true;