From 58336526043b3e1b4ce583f3392d261438b6eb35 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Tue, 4 Feb 2003 23:33:07 +0000 Subject: [PATCH] add operator== --- otk/ustring.cc | 15 +++++++++++++++ otk/ustring.hh | 6 ++++++ 2 files changed, 21 insertions(+) diff --git a/otk/ustring.cc b/otk/ustring.cc index 7ac89bf7..7dbe8ece 100644 --- a/otk/ustring.cc +++ b/otk/ustring.cc @@ -229,6 +229,21 @@ ustring::value_type ustring::operator[](ustring::size_type i) const return utf8_get_char(utf8_offset_to_ptr(_string.data(), i)); } +bool ustring::operator==(const ustring &other) const +{ + return _string == other._string && _utf8 == other._utf8; +} + +bool ustring::operator==(const std::string &other) const +{ + return _string == other; +} + +bool ustring::operator==(const char *other) const +{ + return _string == other; +} + const char* ustring::data() const { return _string.data(); diff --git a/otk/ustring.hh b/otk/ustring.hh index 8ee066d3..0031e1c5 100644 --- a/otk/ustring.hh +++ b/otk/ustring.hh @@ -155,6 +155,12 @@ public: // No reference return; use replace() to write characters. value_type operator[](size_type i) const; + // compare strings + + bool operator==(const ustring &other) const; + bool operator==(const std::string &other) const; + bool operator==(const char *other) const; + // internal data const char* data() const; -- 2.45.2