Codebase list mozc / 8f821bb
Add std:: prefix for base/, renderer/, and unix/ BUG=#392 TEST=unittest REF_BUG= REF_CL=181915556 REF_TIME=2018-01-15T10:19:45+09:00 REF_TIME_RAW=1515979185 +0900 Hiroyuki Komatsu 6 years ago
15 changed file(s) with 47 addition(s) and 46 deletion(s). Raw diff Collapse all Expand all
204204 void Reset();
205205
206206 int verbose_level() const {
207 return max(FLAGS_v, config_verbose_level_);
207 return std::max(FLAGS_v, config_verbose_level_);
208208 }
209209
210210 void set_verbose_level(int level) {
283283 DCHECK_NE(log_file_path.size(), 0);
284284 std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>, wchar_t> utf8_to_wide;
285285 real_log_stream_ = new std::ofstream(
286 utf8_to_wide.from_bytes(log_file_path).c_str(), ios::app);
286 utf8_to_wide.from_bytes(log_file_path).c_str(), std::ios::app);
287287 #elif !defined(OS_ANDROID)
288288 // On non-Android platform, change file mode in addition.
289289 // Android uses logcat instead of log file.
290290 DCHECK_NE(log_file_path.size(), 0);
291 real_log_stream_ = new std::ofstream(log_file_path.c_str(), ios::app);
291 real_log_stream_ = new std::ofstream(log_file_path.c_str(), std::ios::app);
292292 ::chmod(log_file_path.c_str(), 0600);
293293 #endif // OS_ANDROID
294294 DCHECK(!use_cerr_ || !real_log_stream_);
3838
3939 using size_type = StringPiece::size_type;
4040
41 ostream &operator<<(ostream &o, const StringPiece &piece) {
41 std::ostream &operator<<(std::ostream &o, const StringPiece &piece) {
4242 o.write(piece.data(), static_cast<std::streamsize>(piece.size()));
4343 return o;
4444 }
5454 }
5555
5656 size_type StringPiece::copy(char *buf, size_type n, size_type pos) const {
57 const size_type ret = min(length_ - pos, n);
57 const size_type ret = std::min(length_ - pos, n);
5858 memcpy(buf, ptr_ + pos, ret);
5959 return ret;
6060 }
8787 }
8888
8989 if (s.empty()) {
90 return min(length_, pos);
91 }
92
93 const char *last = ptr_ + min(length_ - s.length_, pos) + s.length_;
90 return std::min(length_, pos);
91 }
92
93 const char *last = ptr_ + std::min(length_ - s.length_, pos) + s.length_;
9494 const char *result = std::find_end(ptr_, last, s.ptr_, s.ptr_ + s.length_);
9595 return result != last ? result - ptr_ : npos;
9696 }
100100 return npos;
101101 }
102102
103 for (size_type i = min(pos, length_ - 1); ; --i) {
103 for (size_type i = std::min(pos, length_ - 1); ; --i) {
104104 if (ptr_[i] == c) {
105105 return i;
106106 }
196196
197197 bool lookup[UCHAR_MAX + 1] = { false };
198198 BuildLookupTable(s, lookup);
199 for (size_type i = min(pos, length_ - 1); ; --i) {
199 for (size_type i = std::min(pos, length_ - 1); ; --i) {
200200 if (lookup[static_cast<unsigned char>(ptr_[i])]) {
201201 return i;
202202 }
213213 return npos;
214214 }
215215
216 size_type i = min(pos, length_ - 1);
216 size_type i = std::min(pos, length_ - 1);
217217 if (s.length_ == 0) {
218218 return i;
219219 }
239239 return npos;
240240 }
241241
242 for (size_type i = min(pos, length_ - 1); ; --i) {
242 for (size_type i = std::min(pos, length_ - 1); ; --i) {
243243 if (ptr_[i] != c)
244244 return i;
245245 if (i == 0)
209209 };
210210
211211 // allow StringPiece to be logged (needed for unit testing).
212 extern ostream &operator<<(ostream &o, const StringPiece &piece);
212 extern std::ostream &operator<<(std::ostream &o, const StringPiece &piece);
213213
214214 inline StringPiece ClippedSubstr(StringPiece sp, size_t pos,
215215 size_t n = StringPiece::npos) {
2929
3030 MAJOR=2
3131 MINOR=23
32 BUILD=2788
32 BUILD=2789
3333 REVISION=102
3434 # This version represents the version of Mozc IME engine (converter, predictor,
3535 # etc.). This version info is included both in the Mozc server and in the Mozc
5454 const int focused_index = candidates.focused_index();
5555 const int total_items = candidates.size();
5656
57 stringstream footer_string;
57 std::stringstream footer_string;
5858 return Util::StringPrintf("%d/%d ", focused_index + 1, total_items);
5959 }
6060
292292 FontSpec::FONTSET_FOOTER_LABEL,
293293 candidates_.footer().label());
294294 footer_size.width += label_string_size.width;
295 footer_size.height = max(footer_size.height, label_string_size.height);
295 footer_size.height = std::max(footer_size.height, label_string_size.height);
296296 } else if (candidates_.footer().has_sub_label()) {
297297 const Size label_string_size = text_renderer_->GetPixelSize(
298298 FontSpec::FONTSET_FOOTER_LABEL,
299299 candidates_.footer().sub_label());
300300 footer_size.width += label_string_size.width;
301 footer_size.height = max(footer_size.height, label_string_size.height);
301 footer_size.height = std::max(footer_size.height, label_string_size.height);
302302 }
303303
304304 if (candidates_.footer().index_visible()) {
306306 FontSpec::FONTSET_FOOTER_INDEX,
307307 GetIndexGuideString(candidates_));
308308 footer_size.width += index_guide_size.width;
309 footer_size.height = max(footer_size.height, index_guide_size.height);
309 footer_size.height = std::max(footer_size.height, index_guide_size.height);
310310 }
311311
312312 if (candidates_.candidate_size() < candidates_.size()) {
5656 protected:
5757 void LoadFontSpec(const string &font_description);
5858 void ReleaseFontSpec();
59 vector<FontInfo> fonts_;
59 std::vector<FontInfo> fonts_;
6060 bool is_initialized_;
6161 std::unique_ptr<GtkWrapperInterface> gtk_;
6262
2828
2929 #include "unix/ibus/key_event_handler.h"
3030
31 #include <map>
32
3331 #include "base/logging.h"
3432 #include "base/port.h"
3533 #include "base/singleton.h"
166164
167165 // Modifier key event fires
168166 key_event->mutable_modifier_keys()->Clear();
169 for (set<commands::KeyEvent::ModifierKey>::const_iterator it =
167 for (std::set<commands::KeyEvent::ModifierKey>::const_iterator it =
170168 modifiers_to_be_sent_.begin();
171169 it != modifiers_to_be_sent_.end();
172170 ++it) {
6565 // Non modifier key is pressed or not after all keys are released.
6666 bool is_non_modifier_key_pressed_;
6767 // Currently pressed modifier keys. It is set of keyval.
68 set<guint> currently_pressed_modifiers_;
68 std::set<guint> currently_pressed_modifiers_;
6969 // Pending modifier keys.
70 set<commands::KeyEvent::ModifierKey> modifiers_to_be_sent_;
70 std::set<commands::KeyEvent::ModifierKey> modifiers_to_be_sent_;
7171
7272 DISALLOW_COPY_AND_ASSIGN(KeyEventHandler);
7373 };
436436
437437 void KeyTranslator::Init() {
438438 for (int i = 0; i < arraysize(special_key_map); ++i) {
439 CHECK(special_key_map_.insert(make_pair(special_key_map[i].from,
440 special_key_map[i].to)).second);
439 CHECK(special_key_map_.insert(
440 std::make_pair(special_key_map[i].from,
441 special_key_map[i].to)).second);
441442 }
442443 for (int i = 0; i < arraysize(modifier_key_map_data); ++i) {
443444 CHECK(modifier_key_map_.insert(
444 make_pair(modifier_key_map_data[i].from,
445 modifier_key_map_data[i].to)).second);
445 std::make_pair(modifier_key_map_data[i].from,
446 modifier_key_map_data[i].to)).second);
446447 }
447448 for (int i = 0; i < arraysize(modifier_mask_map_data); ++i) {
448449 CHECK(modifier_mask_map_.insert(
449 make_pair(modifier_mask_map_data[i].from,
450 modifier_mask_map_data[i].to)).second);
450 std::make_pair(modifier_mask_map_data[i].from,
451 modifier_mask_map_data[i].to)).second);
451452 }
452453 for (int i = 0; i < arraysize(kana_map_jp); ++i) {
453454 CHECK(kana_map_jp_.insert(
454 make_pair(kana_map_jp[i].code, make_pair(
455 kana_map_jp[i].no_shift, kana_map_jp[i].shift))).second);
455 std::make_pair(kana_map_jp[i].code,
456 std::make_pair(kana_map_jp[i].no_shift,
457 kana_map_jp[i].shift))).second);
456458 }
457459 for (int i = 0; i < arraysize(kana_map_us); ++i) {
458460 CHECK(kana_map_us_.insert(
459 make_pair(kana_map_us[i].code, make_pair(
460 kana_map_us[i].no_shift, kana_map_us[i].shift))).second);
461 std::make_pair(kana_map_us[i].code,
462 std::make_pair(kana_map_us[i].no_shift,
463 kana_map_us[i].shift))).second);
461464 }
462465 }
463466
5656 commands::KeyEvent *out_event) const;
5757
5858 private:
59 typedef map<guint, commands::KeyEvent::SpecialKey> SpecialKeyMap;
60 typedef map<guint, commands::KeyEvent::ModifierKey> ModifierKeyMap;
61 typedef map<guint, pair<string, string> > KanaMap;
59 typedef std::map<guint, commands::KeyEvent::SpecialKey> SpecialKeyMap;
60 typedef std::map<guint, commands::KeyEvent::ModifierKey> ModifierKeyMap;
61 typedef std::map<guint, std::pair<string, string> > KanaMap;
6262
6363 // Returns true iff key is modifier key such as SHIFT, ALT, or CAPSLOCK.
6464 bool IsModifierKey(guint keyval,
8080 LocaleBasedMessageTranslator::LocaleBasedMessageTranslator(
8181 const string &locale_name) {
8282 // Currently we support ja_JP.UTF-8 and ja_JP.utf8 only.
83 vector<string> tokens;
83 std::vector<string> tokens;
8484 Util::SplitStringUsing(locale_name, ".", &tokens);
8585 if (tokens.size() != 2) {
8686 return;
107107
108108 string LocaleBasedMessageTranslator::MaybeTranslate(
109109 const string &message) const {
110 map<string, string>::const_iterator itr =
110 std::map<string, string>::const_iterator itr =
111111 utf8_japanese_map_.find(message);
112112 if (itr == utf8_japanese_map_.end()) {
113113 return message;
6969 virtual string MaybeTranslate(const string &message) const;
7070
7171 private:
72 map<string, string> utf8_japanese_map_;
72 std::map<string, string> utf8_japanese_map_;
7373 DISALLOW_COPY_AND_ASSIGN(LocaleBasedMessageTranslator);
7474 };
7575
203203 return false;
204204 }
205205
206 const size_t selection_start = min(cursor_pos, anchor_pos);
206 const size_t selection_start = std::min(cursor_pos, anchor_pos);
207207 const size_t selection_length = abs(info->relative_selected_length);
208208 Util::SubStringPiece(surrounding_text, 0, selection_start)
209209 .CopyToString(&info->preceding_text);
160160 config::Config::PreeditMethod preedit_method_;
161161
162162 // Unique IDs of candidates that are currently shown.
163 vector<int32> unique_candidate_ids_;
163 std::vector<int32> unique_candidate_ids_;
164164
165165 friend class LaunchToolTest;
166166 FRIEND_TEST(LaunchToolTest, LaunchToolTest);
4747 static_assert(sizeof(int64) == sizeof(llabs(0)),
4848 "|llabs(0)| must returns a 64-bit integer.");
4949 const int64 kInt32AbsMax =
50 llabs(static_cast<int64>(numeric_limits<int32>::max()));
50 llabs(static_cast<int64>(std::numeric_limits<int32>::max()));
5151 const int64 kInt32AbsMin =
52 llabs(static_cast<int64>(numeric_limits<int32>::min()));
52 llabs(static_cast<int64>(std::numeric_limits<int32>::min()));
5353 const int64 kInt32SafeAbsMax =
54 min(kInt32AbsMax, kInt32AbsMin);
54 std::min(kInt32AbsMax, kInt32AbsMin);
5555
5656 const int64 diff = static_cast<int64>(from) - static_cast<int64>(to);
5757 if (llabs(diff) > kInt32SafeAbsMax) {