Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(264)

Unified Diff: mojo/public/cpp/bindings/string.h

Issue 611633002: mojom: Add associative arrays to the mojom language. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..fcc4739f252dec4c3c210515d3e856babb3ca28c 100644
--- a/mojo/public/cpp/bindings/string.h
+++ b/mojo/public/cpp/bindings/string.h
@@ -40,6 +40,11 @@ class String {
return TypeConverter<U, String>::Convert(*this);
}
+ String& operator=(const mojo::String& str) {
yzshen1 2014/09/27 00:01:58 Do you also want to add a copy constructor?
Elliot Glaysher 2014/10/02 19:54:03 Done.
+ value_ = str.value_;
+ is_null_ = str.is_null_;
+ return *this;
+ }
String& operator=(const std::string& str) {
value_ = str;
is_null_ = false;
@@ -110,6 +115,19 @@ inline std::ostream& operator<<(std::ostream& out, const String& s) {
return out << s.get();
}
+inline bool operator<(const String& a, const String& b) {
+ // TODO(erg): This needs a test.
+ 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 <>

Powered by Google App Engine
This is Rietveld 408576698