summaryrefslogtreecommitdiff
path: root/core/fxcrt/bytestring.h
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2017-11-06 19:00:21 +0000
committerChromium commit bot <commit-bot@chromium.org>2017-11-06 19:00:21 +0000
commitd7a3f981fdc6bf9aef306854505638db7b4b51c7 (patch)
treebb83ad096cf3618b864e93f4cbb07632a9510368 /core/fxcrt/bytestring.h
parentac7ce6ec217ba7b4753f4cf2ed80c921d8ea6898 (diff)
downloadpdfium-d7a3f981fdc6bf9aef306854505638db7b4b51c7.tar.xz
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 <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core/fxcrt/bytestring.h')
-rw-r--r--core/fxcrt/bytestring.h7
1 files changed, 6 insertions, 1 deletions
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) {