diff options
| author | 2017-02-09 16:17:15 +0000 | |
|---|---|---|
| committer | 2017-02-09 16:17:18 +0000 | |
| commit | 024d22fdb76a75f72ac1a421c4dd184bbfe2ba12 (patch) | |
| tree | 074240054a9d37547ab9ddd3cac73a05e08b3f0e /tools/aapt2/StringPool.cpp | |
| parent | 34895c404b0153f021094d149cf36918edbd4552 (diff) | |
| parent | 7542162cb1b1fd2ce8a26dd7f3fedc8de8160d38 (diff) | |
Merge "AAPT2: Fix pseudolocalization to respect <xliff:g>"
Diffstat (limited to 'tools/aapt2/StringPool.cpp')
| -rw-r--r-- | tools/aapt2/StringPool.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tools/aapt2/StringPool.cpp b/tools/aapt2/StringPool.cpp index d968d73c44ee..57da5f01dcd1 100644 --- a/tools/aapt2/StringPool.cpp +++ b/tools/aapt2/StringPool.cpp @@ -63,6 +63,14 @@ StringPool::Ref& StringPool::Ref::operator=(const StringPool::Ref& rhs) { return *this; } +bool StringPool::Ref::operator==(const Ref& rhs) const { + return entry_->value == rhs.entry_->value; +} + +bool StringPool::Ref::operator!=(const Ref& rhs) const { + return entry_->value != rhs.entry_->value; +} + const std::string* StringPool::Ref::operator->() const { return &entry_->value; } @@ -109,6 +117,28 @@ StringPool::StyleRef& StringPool::StyleRef::operator=( return *this; } +bool StringPool::StyleRef::operator==(const StyleRef& rhs) const { + if (entry_->str != rhs.entry_->str) { + return false; + } + + if (entry_->spans.size() != rhs.entry_->spans.size()) { + return false; + } + + auto rhs_iter = rhs.entry_->spans.begin(); + for (const Span& span : entry_->spans) { + const Span& rhs_span = *rhs_iter; + if (span.first_char != rhs_span.first_char || span.last_char != rhs_span.last_char || + span.name != rhs_span.name) { + return false; + } + } + return true; +} + +bool StringPool::StyleRef::operator!=(const StyleRef& rhs) const { return !operator==(rhs); } + const StringPool::StyleEntry* StringPool::StyleRef::operator->() const { return entry_; } |