| Index: mojo/public/cpp/bindings/string.h
|
| diff --git a/mojo/public/cpp/bindings/string.h b/mojo/public/cpp/bindings/string.h
|
| index cd7db26e8230a8f1fa1df62822e3d972bb60e571..ef4f2b68163392de684df883556dd2a912862533 100644
|
| --- a/mojo/public/cpp/bindings/string.h
|
| +++ b/mojo/public/cpp/bindings/string.h
|
| @@ -27,6 +27,10 @@ class String {
|
| : value_(chars, num_chars),
|
| is_null_(false) {
|
| }
|
| + String(const mojo::String& str)
|
| + : value_(str.value_),
|
| + is_null_(str.is_null_) {
|
| + }
|
| template <size_t N>
|
| String(const char chars[N]) : value_(chars, N-1), is_null_(false) {}
|
|
|
| @@ -40,6 +44,11 @@ class String {
|
| return TypeConverter<U, String>::Convert(*this);
|
| }
|
|
|
| + String& operator=(const mojo::String& str) {
|
| + value_ = str.value_;
|
| + is_null_ = str.is_null_;
|
| + return *this;
|
| + }
|
| String& operator=(const std::string& str) {
|
| value_ = str;
|
| is_null_ = false;
|
| @@ -110,6 +119,18 @@ inline std::ostream& operator<<(std::ostream& out, const String& s) {
|
| return out << s.get();
|
| }
|
|
|
| +inline bool operator<(const String& a, const String& b) {
|
| + if (a.is_null() && !b.is_null()) {
|
| + // The null string is less than a non-NULL string.
|
| + return true;
|
| + } else if (a.is_null() || b.is_null()) {
|
| + // in all other cases where A or B is NULL, |a| is not less than |b|.
|
| + return false;
|
| + }
|
| +
|
| + return a.get() < b.get();
|
| +}
|
| +
|
| // TODO(darin): Add similar variants of operator<,<=,>,>=
|
|
|
| template <>
|
|
|