-
Notifications
You must be signed in to change notification settings - Fork 568
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Continue to Migrate from Boost to std (#755)
* refactor: string formatting by sstream * refactor: replace boost::all with std::all_of, etc. * refactor(utilities.cc): improve CompareVersionString implementation * refactor(string_table.cc): use stringstream map and dump marisa trie * refactor(mappped_file.h): self decleared noncopyable * refactor: apply clang format
- Loading branch information
1 parent
af3d4a7
commit 1c78709
Showing
10 changed files
with
54 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,15 +5,16 @@ | |
// 2014-07-04 GONG Chen <[email protected]> | ||
// | ||
|
||
#include <boost/iostreams/device/array.hpp> | ||
#include <boost/iostreams/stream.hpp> | ||
#include <sstream> | ||
#include <rime/common.h> | ||
#include <rime/dict/string_table.h> | ||
|
||
namespace rime { | ||
|
||
StringTable::StringTable(const char* ptr, size_t size) { | ||
trie_.map(ptr, size); | ||
std::stringstream stream; | ||
stream.write(ptr, size); | ||
stream >> trie_; | ||
} | ||
|
||
bool StringTable::HasKey(const string& key) { | ||
|
@@ -106,10 +107,10 @@ void StringTableBuilder::Dump(char* ptr, size_t size) { | |
LOG(ERROR) << "insufficient memory to dump string table."; | ||
return; | ||
} | ||
namespace io = boost::iostreams; | ||
io::basic_array_sink<char> sink(ptr, size); | ||
io::stream<io::basic_array_sink<char>> stream(sink); | ||
|
||
std::stringstream stream; | ||
stream << trie_; | ||
stream.read(ptr, size); | ||
} | ||
|
||
} // namespace rime |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,8 +5,8 @@ | |
// 2011-11-02 GONG Chen <[email protected]> | ||
// | ||
#include <cstdlib> | ||
#include <sstream> | ||
#include <boost/algorithm/string.hpp> | ||
#include <boost/format.hpp> | ||
#include <rime/service.h> | ||
#include <rime/algo/dynamics.h> | ||
#include <rime/dict/text_db.h> | ||
|
@@ -19,7 +19,9 @@ UserDbValue::UserDbValue(const string& value) { | |
} | ||
|
||
string UserDbValue::Pack() const { | ||
return boost::str(boost::format("c=%1% d=%2% t=%3%") % commits % dee % tick); | ||
std::ostringstream packed; | ||
packed << "c=" << commits << " d=" << dee << " t=" << tick; | ||
return packed.str(); | ||
} | ||
|
||
bool UserDbValue::Unpack(const string& value) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
// 2013-07-02 GONG Chen <[email protected]> | ||
// | ||
#include <sstream> | ||
#include <boost/algorithm/string.hpp> | ||
#include <algorithm> | ||
#include <rime/context.h> | ||
#include <rime/engine.h> | ||
#include <rime/key_event.h> | ||
|
@@ -17,7 +17,8 @@ void ShapeFormatter::Format(string* text) { | |
if (!engine_->context()->get_option("full_shape")) { | ||
return; | ||
} | ||
if (boost::all(*text, !boost::is_from_range('\x20', '\x7e'))) { | ||
if (std::all_of(text->cbegin(), text->cend(), | ||
[](auto ch) { return (ch >= 0x20 && ch <= 0x7e); })) { | ||
return; | ||
} | ||
std::ostringstream oss; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
// 2011-04-20 GONG Chen <[email protected]> | ||
// | ||
#include <sstream> | ||
#include <boost/format.hpp> | ||
#include <iomanip> | ||
#include <rime/key_event.h> | ||
#include <rime/key_table.h> | ||
|
||
|
@@ -36,15 +36,16 @@ string KeyEvent::repr() const { | |
return modifiers.str() + name; | ||
} | ||
// no name :-| return its hex value | ||
string value; | ||
std::ostringstream value; | ||
value << "0x" << std::setfill('0'); | ||
if (keycode_ <= 0xffff) { | ||
value = boost::str(boost::format("0x%4x") % keycode_); | ||
value << std::setw(4) << std::hex << keycode_; | ||
} else if (keycode_ <= 0xffffff) { | ||
value = boost::str(boost::format("0x%6x") % keycode_); | ||
value << std::setw(6) << std::hex << keycode_; | ||
} else { | ||
return "(unknown)"; // invalid keycode | ||
} | ||
return modifiers.str() + value; | ||
return modifiers.str() + value.str(); | ||
} | ||
|
||
bool KeyEvent::Parse(const string& repr) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters