From d7a3f981fdc6bf9aef306854505638db7b4b51c7 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Mon, 6 Nov 2017 19:00:21 +0000 Subject: Improve ByteString{View}::operator<(). Make it possible to compare: 1) const char* < ByteStringView 2) ByteString < const char* 3) ByteString < ByteStringView 4) const char* < ByteString Do the same for WideString{View}. With new unit test cases. Change-Id: I31da526b1ab78b8d51ec1c99bf29046fe13754d5 Reviewed-on: https://pdfium-review.googlesource.com/17872 Commit-Queue: Lei Zhang Reviewed-by: Tom Sepez --- core/fxcrt/bytestring.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'core/fxcrt/bytestring.h') diff --git a/core/fxcrt/bytestring.h b/core/fxcrt/bytestring.h index 67fdd1d9ac..6d5843efcd 100644 --- a/core/fxcrt/bytestring.h +++ b/core/fxcrt/bytestring.h @@ -110,7 +110,9 @@ class ByteString { bool operator!=(const ByteStringView& str) const { return !(*this == str); } bool operator!=(const ByteString& other) const { return !(*this == other); } - bool operator<(const ByteString& str) const; + bool operator<(const char* ptr) const; + bool operator<(const ByteStringView& str) const; + bool operator<(const ByteString& other) const; const ByteString& operator=(const char* str); const ByteString& operator=(const ByteStringView& bstrc); @@ -209,6 +211,9 @@ inline bool operator!=(const char* lhs, const ByteString& rhs) { inline bool operator!=(const ByteStringView& lhs, const ByteString& rhs) { return rhs != lhs; } +inline bool operator<(const char* lhs, const ByteString& rhs) { + return rhs.Compare(lhs) > 0; +} inline ByteString operator+(const ByteStringView& str1, const ByteStringView& str2) { -- cgit v1.2.3