Browse Source

implement more and more missing member functions of nfc_string.

master
roker 4 years ago
parent
commit
8f75ed8ed9
  1. 39
      src/nfc.cc
  2. 6
      src/nfc.hh

39
src/nfc.cc

@ -573,7 +573,6 @@ bool UTF<CharT>::is_safe_NFC_start(std::basic_string_view<CharT> s)
}
template<class CharT>
IsNFC UTF<CharT>::isNFC_quick_check(std::basic_string_view<CharT> s)
{
@ -730,6 +729,44 @@ UTF<CharT>::nfc_string& UTF<CharT>::nfc_string::assign(String&& src)
return *this;
}
template<class CharT>
typename
UTF<CharT>::nfc_string& UTF<CharT>::nfc_string::push_back(CharT c)
{
s += c;
if( !is_safe_NFC_start(StringView{&c, 1}) )
{
normalize();
}
return *this;
}
template<class CharT>
typename
UTF<CharT>::nfc_string& UTF<CharT>::nfc_string::operator+=(StringView sv)
{
const String& sv_nfc = toNFC(sv);
s += sv_nfc;
if( !is_safe_NFC_start(sv_nfc) )
{
normalize();
}
return *this;
}
template<class CharT>
typename
UTF<CharT>::nfc_string& UTF<CharT>::nfc_string::operator+=(const UTF<CharT>::nfc_string& ns)
{
s += ns.get();
if( !is_safe_NFC_start(ns) )
{
normalize();
}
return *this;
}
// convenience function to avoid ::strdup(pEp::toNFC<char>(text).c_str());
// and unecessary temporary std::string etc.

6
src/nfc.hh

@ -123,6 +123,8 @@ public:
/// read-only: shares representation
operator const String&() const noexcept { return s; }
const String& get() const noexcept { return s;}
/// read write: copy content
operator String() const { return s; }
@ -177,13 +179,13 @@ public:
return *this;
}
nfc_string& operator+=(const StringView& s);
nfc_string& operator+=(StringView s);
/// optimization possible to avoid re-normalization in most cases.
nfc_string& operator+=(const nfc_string& s);
/// optimization possible to avoid re-normalization in most cases.
nfc_string& operator+=(CharT c);
nfc_string& operator+=(CharT c) { push_back(c); return *this; }
/// delegates all 9 compare() overloads to s
template<typename... Args>

Loading…
Cancel
Save