Fabric: Equality operators for AttributedString and derivatives

Summary: We will need this eventually.

Reviewed By: mdvacca

Differential Revision: D9799852

fbshipit-source-id: 0411e2f41540273c80f425e04c877fe51b9b2374
This commit is contained in:
Valentin Shergin
2018-09-14 15:21:11 -07:00
committed by Facebook Github Bot
parent 4eb9b40979
commit e663b1ed59
4 changed files with 104 additions and 0 deletions
@@ -15,6 +15,30 @@ namespace react {
using Fragment = AttributedString::Fragment;
using Fragments = AttributedString::Fragments;
#pragma mark - Fragment
bool Fragment::operator==(const Fragment &rhs) const {
return
std::tie(
string,
textAttributes,
shadowNode,
parentShadowNode
) ==
std::tie(
rhs.string,
rhs.textAttributes,
rhs.shadowNode,
rhs.parentShadowNode
);
}
bool Fragment::operator!=(const Fragment &rhs) const {
return !(*this == rhs);
}
#pragma mark - AttributedString
void AttributedString::appendFragment(const Fragment &fragment) {
ensureUnsealed();
fragments_.push_back(fragment);
@@ -47,6 +71,14 @@ std::string AttributedString::getString() const {
return string;
}
bool AttributedString::operator==(const AttributedString &rhs) const {
return fragments_ != rhs.fragments_;
}
bool AttributedString::operator!=(const AttributedString &rhs) const {
return !(*this == rhs);
}
#pragma mark - DebugStringConvertible
SharedDebugStringConvertibleList AttributedString::getDebugChildren() const {