#ifndef _RFCSTRING_H #define _RFCSTRING_H 1 namespace bd { class String; } #include "rfc1459.h" #include class RfcString : public bd::String { private: protected: public: using String::String; RfcString(const String &str) : String(str) {}; RfcString(String &&str) : String(std::move(str)) {}; int compare(const RfcString& str, size_t n = npos) const noexcept __attribute__((pure)); friend bool operator==(const RfcString&, const RfcString&); friend bool operator!=(const RfcString&, const RfcString&); friend bool operator<(const RfcString&, const RfcString&); friend bool operator<=(const RfcString&, const RfcString&); friend bool operator>(const RfcString&, const RfcString&); friend bool operator>=(const RfcString&, const RfcString&); virtual size_t hash() const noexcept; }; inline bool __attribute__((pure)) operator==(const RfcString& lhs, const RfcString& rhs) { return (lhs.length() == rhs.length() && lhs.compare(rhs) == 0); } inline bool __attribute__((pure)) operator!=(const RfcString& lhs, const RfcString& rhs) { return ! (lhs == rhs); } inline bool __attribute__((pure)) operator<(const RfcString& lhs, const RfcString& rhs) { return (lhs.compare(rhs) < 0); } inline bool __attribute__((pure)) operator<=(const RfcString& lhs, const RfcString& rhs) { return ! (rhs < lhs); } inline bool __attribute__((pure)) operator>(const RfcString& lhs, const RfcString& rhs) { return (rhs < lhs); } inline bool __attribute__((pure)) operator>=(const RfcString& lhs, const RfcString& rhs) { return ! (lhs < rhs); } namespace std { template<> struct hash { inline size_t operator()(const RfcString& val) const { return val.hash(); } }; } #endif