Migrate deprecated StringPiece::CopyToString to string::assign, or construction of string, or absl::CopyToString, as appropriate.
REF_BUG=
REF_CL=165245504
REF_TIME=2017-08-14T16:21:28-07:00
REF_TIME_RAW=1502752888 -0700
Jorg Brown
6 years ago
431 | 431 | StringPiece e; |
432 | 432 | string s2; |
433 | 433 | |
434 | // CopyToString | |
435 | a.CopyToString(&s2); | |
436 | ASSERT_SIZE_EQ(s2.size(), 6); | |
437 | ASSERT_EQ(s2, "foobar"); | |
438 | b.CopyToString(&s2); | |
439 | ASSERT_SIZE_EQ(s2.size(), 7); | |
440 | ASSERT_EQ(s1, s2); | |
441 | e.CopyToString(&s2); | |
442 | ASSERT_TRUE(s2.empty()); | |
443 | ||
444 | 434 | // starts_with |
445 | 435 | ASSERT_TRUE(a.starts_with(a)); |
446 | 436 | ASSERT_TRUE(a.starts_with("foo")); |
29 | 29 | |
30 | 30 | MAJOR=2 |
31 | 31 | MINOR=22 |
32 | BUILD=2729 | |
32 | BUILD=2730 | |
33 | 33 | REVISION=102 |
34 | 34 | # This version represents the version of Mozc IME engine (converter, predictor, |
35 | 35 | # etc.). This version info is included both in the Mozc server and in the Mozc |
96 | 96 | Token token; |
97 | 97 | token.attributes = Token::NONE; // Common for all suffix tokens. |
98 | 98 | for (; range.first != range.second; ++range.first) { |
99 | (*range.first).CopyToString(&token.key); | |
99 | token.key.assign((*range.first).data(), (*range.first).size()); | |
100 | 100 | switch (callback->OnKey(token.key)) { |
101 | 101 | case Callback::TRAVERSE_DONE: |
102 | 102 | return; |
112 | 112 | if (value_array_[index].empty()) { |
113 | 113 | token.value = token.key; |
114 | 114 | } else { |
115 | value_array_[index].CopyToString(&token.value); | |
115 | token.value.assign(value_array_[index].data(), | |
116 | value_array_[index].size()); | |
116 | 117 | } |
117 | 118 | token.lid = token_array_[3 * index]; |
118 | 119 | token.rid = token_array_[3 * index + 1]; |
281 | 281 | // of the original (correct) reading. |
282 | 282 | const int kCostPenalty = 2302; // -log(1/100) * 500; |
283 | 283 | std::unique_ptr<Token> token(new Token); |
284 | value_key.second.CopyToString(&token->key); | |
284 | token->key.assign(value_key.second.data(), value_key.second.size()); | |
285 | 285 | token->value = max_cost_token->value; |
286 | 286 | token->lid = max_cost_token->lid; |
287 | 287 | token->rid = max_cost_token->rid; |
200 | 200 | const Segment &conversion_segment = segments->conversion_segment(0); |
201 | 201 | const string &segment_key = conversion_segment.key(); |
202 | 202 | |
203 | // The top candidate, which is about to be commited. | |
203 | // The top candidate, which is about to be committed. | |
204 | 204 | const Segment::Candidate &candidate = conversion_segment.candidate(0); |
205 | 205 | const string &candidate_value = candidate.value; |
206 | 206 | |
1822 | 1822 | SegmentForLearning learning_segment; |
1823 | 1823 | for (Segment::Candidate::InnerSegmentIterator iter(&candidate); |
1824 | 1824 | !iter.Done(); iter.Next()) { |
1825 | iter.GetKey().CopyToString(&learning_segment.key); | |
1826 | iter.GetValue().CopyToString(&learning_segment.value); | |
1827 | iter.GetContentKey().CopyToString(&learning_segment.content_key); | |
1828 | iter.GetContentValue().CopyToString(&learning_segment.content_value); | |
1825 | learning_segment.key.assign(iter.GetKey().data(), iter.GetKey().size()); | |
1826 | learning_segment.value.assign(iter.GetValue().data(), | |
1827 | iter.GetValue().size()); | |
1828 | learning_segment.content_key.assign(iter.GetContentKey().data(), | |
1829 | iter.GetContentKey().size()); | |
1830 | learning_segment.content_value.assign(iter.GetContentValue().data(), | |
1831 | iter.GetContentValue().size()); | |
1829 | 1832 | learning_segments->push_back_conversion_segment(learning_segment); |
1830 | 1833 | } |
1831 | 1834 | } |
116 | 116 | c->lid = sorted_value[i].lid(); |
117 | 117 | c->rid = sorted_value[i].rid(); |
118 | 118 | c->cost = base_candidate.cost; |
119 | sorted_value[i].value().CopyToString(&c->value); | |
119 | c->value.assign(sorted_value[i].value().data(), | |
120 | sorted_value[i].value().size()); | |
120 | 121 | c->content_value = c->value; |
121 | 122 | c->key = base_candidate.key; |
122 | 123 | c->content_key = base_candidate.content_key; |
211 | 211 | candidate->rid = iter.rid(); |
212 | 212 | candidate->cost = base_candidate.cost; |
213 | 213 | candidate->structure_cost = base_candidate.structure_cost; |
214 | iter.value().CopyToString(&candidate->value); | |
215 | iter.value().CopyToString(&candidate->content_value); | |
214 | candidate->value.assign(iter.value().data(), iter.value().size()); | |
215 | candidate->content_value.assign(iter.value().data(), iter.value().size()); | |
216 | 216 | candidate->key = candidate_key; |
217 | 217 | candidate->content_key = candidate_key; |
218 | 218 |
235 | 235 | |
236 | 236 | const StringPiece value_suffix = string_array_[ |
237 | 237 | base_conjugation_suffix_[2 * iter.conjugation_id()]]; |
238 | string_array_[iter.value_index()].CopyToString(&candidate->usage_title); | |
238 | candidate->usage_title.assign(string_array_[iter.value_index()].data(), | |
239 | string_array_[iter.value_index()].size()); | |
239 | 240 | candidate->usage_title.append(value_suffix.data(), value_suffix.size()); |
240 | 241 | |
241 | string_array_[iter.meaning_index()].CopyToString( | |
242 | &candidate->usage_description); | |
242 | candidate->usage_description.assign( | |
243 | string_array_[iter.meaning_index()].data(), | |
244 | string_array_[iter.meaning_index()].size()); | |
243 | 245 | |
244 | 246 | VLOG(2) << i << ":" << j |
245 | 247 | << ":" << candidate->content_key |
280 | 280 | AppendString(kPlatformDependent, &description); |
281 | 281 | } |
282 | 282 | |
283 | // The follwoing description tries to overwrite exisiting description. | |
283 | // The follwoing description tries to overwrite existing description. | |
284 | 284 | // TODO(taku): reconsider this behavior. |
285 | 285 | // Zipcode description |
286 | 286 | if ((description_type & ZIPCODE) && |
291 | 291 | AppendString(candidate->description, &description); |
292 | 292 | } |
293 | 293 | |
294 | // The follwoing description tries to overwrite exisiting description. | |
294 | // The follwoing description tries to overwrite existing description. | |
295 | 295 | // TODO(taku): reconsider this behavior. |
296 | 296 | // Spelling Correction description |
297 | 297 | if ((description_type & SPELLING_CORRECTION) && |
481 | 481 | string inner_default_content_value, inner_alternative_content_value; |
482 | 482 | for (Segment::Candidate::InnerSegmentIterator iter(&original); |
483 | 483 | !iter.Done(); iter.Next()) { |
484 | iter.GetValue().CopyToString(&tmp); | |
484 | tmp.assign(iter.GetValue().data(), iter.GetValue().size()); | |
485 | 485 | inner_default_value.clear(); |
486 | 486 | inner_alternative_value.clear(); |
487 | 487 | if (!manager->ConvertConversionStringWithAlternative( |
488 | 488 | tmp, &inner_default_value, &inner_alternative_value)) { |
489 | iter.GetValue().CopyToString(&inner_default_value); | |
490 | iter.GetValue().CopyToString(&inner_alternative_value); | |
489 | inner_default_value.assign(iter.GetValue().data(), | |
490 | iter.GetValue().size()); | |
491 | inner_alternative_value.assign(iter.GetValue().data(), | |
492 | iter.GetValue().size()); | |
491 | 493 | } else { |
492 | 494 | at_least_one_modified = true; |
493 | 495 | } |
494 | 496 | if (iter.GetValue() != iter.GetContentValue()) { |
495 | 497 | inner_default_content_value.clear(); |
496 | 498 | inner_alternative_content_value.clear(); |
497 | iter.GetContentValue().CopyToString(&tmp); | |
499 | tmp.assign(iter.GetContentValue().data(), iter.GetContentValue().size()); | |
498 | 500 | manager->ConvertConversionStringWithAlternative( |
499 | 501 | tmp, &inner_default_content_value, |
500 | 502 | &inner_alternative_content_value); |