|
@ -13,16 +13,19 @@ |
|
|
|
|
|
|
|
|
namespace pEp { |
|
|
namespace pEp { |
|
|
|
|
|
|
|
|
|
|
|
/// Tri-sate return value of isNFC_quick_check()
|
|
|
enum class IsNFC |
|
|
enum class IsNFC |
|
|
{ |
|
|
{ |
|
|
No=0, // contains a character that cannot occur in NFC
|
|
|
No=0, //!< string contains a character that cannot occur in NFC
|
|
|
Maybe=1, // contains a character that is only allowed in certain positions in NFC
|
|
|
Maybe=1, //!< string contains a character that is only allowed in certain positions in NFC
|
|
|
Yes=2 // contains no invalid or partially valid character
|
|
|
Yes=2 //!< string contains no invalid or partially valid character
|
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
std::ostream& operator<<(std::ostream& o, IsNFC is_nfc); |
|
|
std::ostream& operator<<(std::ostream& o, IsNFC is_nfc); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Exception class thrown whenever a string is parsed that is not a valid
|
|
|
|
|
|
/// UTF-8 or UTF-16 sequence.
|
|
|
class illegal_utf : public std::runtime_error |
|
|
class illegal_utf : public std::runtime_error |
|
|
{ |
|
|
{ |
|
|
public: |
|
|
public: |
|
@ -51,8 +54,9 @@ public: |
|
|
static |
|
|
static |
|
|
bool is_safe_NFC_start(std::basic_string_view<CharT> s); |
|
|
bool is_safe_NFC_start(std::basic_string_view<CharT> s); |
|
|
|
|
|
|
|
|
/// returns No or Maybe, if at least one character with NFC_Quickcheck class is "No" or "Maybe"
|
|
|
/// returns No or Maybe, if at least one character with NFC_Quickcheck class is "No" or "Maybe".
|
|
|
/// might throw illegal_utf exception
|
|
|
/// use isNFC() for a comprehensive NFC check.
|
|
|
|
|
|
/// Might throw illegal_utf exception
|
|
|
static |
|
|
static |
|
|
IsNFC isNFC_quick_check(std::basic_string_view<CharT> s); |
|
|
IsNFC isNFC_quick_check(std::basic_string_view<CharT> s); |
|
|
|
|
|
|
|
@ -129,6 +133,7 @@ public: |
|
|
/// read-only: shares representation
|
|
|
/// read-only: shares representation
|
|
|
operator const String&() const noexcept { return s; } |
|
|
operator const String&() const noexcept { return s; } |
|
|
|
|
|
|
|
|
|
|
|
/// read-only: shares representation
|
|
|
const String& get() const noexcept { return s;} |
|
|
const String& get() const noexcept { return s;} |
|
|
|
|
|
|
|
|
/// read write: copy content
|
|
|
/// read write: copy content
|
|
@ -185,6 +190,7 @@ public: |
|
|
return *this; |
|
|
return *this; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// more expensive, because 's' might not be in NFC.
|
|
|
nfc_string& operator+=(StringView s); |
|
|
nfc_string& operator+=(StringView s); |
|
|
|
|
|
|
|
|
/// optimization possible to avoid re-normalization in most cases.
|
|
|
/// optimization possible to avoid re-normalization in most cases.
|
|
|