diff --git a/common/include/utf8string.hpp b/common/include/utf8string.hpp index 1b56bbaee6e739d3c2cb661cda9f07388dd05850..005bd58d2c677b6c5bf99ecb7920d4aef82b333c 100644 --- a/common/include/utf8string.hpp +++ b/common/include/utf8string.hpp @@ -18,9 +18,9 @@ class utf8char : public std::array<char, 4> utf8char(const char * other); utf8char & operator=(char other); utf8char & operator=(const std::string & other); - bool operator==(char other); - bool operator==(const std::string & other); - bool operator!=(char other); + bool operator==(char other) const; + bool operator==(const std::string & other) const; + bool operator!=(char other) const; }; class utf8string : public std::vector<utf8char> @@ -30,7 +30,7 @@ class utf8string : public std::vector<utf8char> utf8string & operator=(const std::string & other); utf8string & operator=(const char * const other); - bool operator==(const std::string & other); + bool operator==(const std::string & other) const; void replace(utf8char from, utf8char to); }; diff --git a/common/src/utf8string.cpp b/common/src/utf8string.cpp index 374ff9dd58adccc5b276ac82cc05bc4696815772..70cdb3411f768b360ecb4df5858f8c17ed91a6a4 100644 --- a/common/src/utf8string.cpp +++ b/common/src/utf8string.cpp @@ -31,7 +31,7 @@ util::utf8char & util::utf8char::operator=(const std::string & other) return *this = splited[0]; } -bool util::utf8char::operator==(const std::string & other) +bool util::utf8char::operator==(const std::string & other) const { auto splited = splitAsUtf8(other); if (splited.size() > 1) @@ -39,12 +39,12 @@ bool util::utf8char::operator==(const std::string & other) return *this == splited[0]; } -bool util::utf8char::operator==(char other) +bool util::utf8char::operator==(char other) const { return (*this)[0] == other && !(*this)[1] && !(*this)[2] && !(*this)[3]; } -bool util::utf8char::operator!=(char other) +bool util::utf8char::operator!=(char other) const { return ! (*this==other); } @@ -63,7 +63,7 @@ util::utf8string & util::utf8string::operator=(const char * const other) return operator=(std::string(other)); } -bool util::utf8string::operator==(const std::string & other) +bool util::utf8string::operator==(const std::string & other) const { if (size() != other.size()) return false;