summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorRoland Reichwein <mail@reichwein.it>2021-12-25 20:20:02 +0100
committerRoland Reichwein <mail@reichwein.it>2021-12-25 20:20:02 +0100
commit23c31aef916dbfd17774a80258676a963426a698 (patch)
tree00d151c87204cc577af0790f45526e57f7c65fd3 /include
parenta6a6c121e9e45c15a61802da739cd8ca257bf22c (diff)
Consistent use of internal_type
Diffstat (limited to 'include')
-rw-r--r--include/unicode.h20
1 files changed, 11 insertions, 9 deletions
diff --git a/include/unicode.h b/include/unicode.h
index 8e120ad..3d6477c 100644
--- a/include/unicode.h
+++ b/include/unicode.h
@@ -228,6 +228,7 @@ namespace unicode::detail {
static_assert(sizeof(T) == 1 || sizeof(T) == 2 || sizeof(T) == 4);
typedef T value_type;
+ typedef char32_t internal_type;
typedef Container string_type;
typedef utf_back_insert_iterator& reference;
typedef utf_back_insert_iterator* pointer;
@@ -258,14 +259,14 @@ namespace unicode::detail {
// n is number of UTF-8 bytes in sequence
template<size_t n>
- inline static value_type byte0_of(char32_t value)
+ inline static value_type byte0_of(internal_type value)
{
return (value >> 6 * (n - 1)) | (0xFF << (8 - n));
}
// n is index of 6-bit groups, counting from bit 0
template<size_t n>
- inline static value_type trailing_byte(char32_t value)
+ inline static value_type trailing_byte(internal_type value)
{
return ((value >> n * 6) & 0b111111) | 0b10000000;
}
@@ -273,7 +274,7 @@ namespace unicode::detail {
// calculate UTF-8 sequence byte for m >= 2 bytes sequences (i.e. non-ASCII)
// assume value to be valid Unicode value for given byte position
template<size_t n, size_t m>
- inline static value_type byte_n_of_m(char32_t value)
+ inline static value_type byte_n_of_m(internal_type value)
{
if constexpr (n == 0)
return byte0_of<m>(value);
@@ -303,7 +304,7 @@ namespace unicode::detail {
}
template<class X = value_type, typename std::enable_if<(sizeof(X) == 1), bool>::type = true>
- inline void append_utf(const char32_t& value)
+ inline void append_utf(const internal_type& value)
{
if (value < 0x80) { // 1 byte
append(static_cast<value_type>(value));
@@ -318,24 +319,24 @@ namespace unicode::detail {
}
template<class X = value_type, typename std::enable_if<(sizeof(X) == 2), bool>::type = true>
- inline void append_utf(const char32_t& value)
+ inline void append_utf(const internal_type& value)
{
if (value <= 0xFFFF) { // expect value to be already valid Unicode values (checked in input iterator)
append(static_cast<value_type>(value));
} else {
- char32_t value_reduced{value - 0x10000};
+ internal_type value_reduced{value - 0x10000};
append(static_cast<value_type>((value_reduced >> 10) + 0xD800), static_cast<value_type>((value_reduced & 0x3FF) + 0xDC00));
}
}
template<class X = value_type, typename std::enable_if<(sizeof(X) == 4), bool>::type = true>
- inline void append_utf(const char32_t& value)
+ inline void append_utf(const internal_type& value)
{
// expect value to be already valid Unicode values (checked in input iterator)
append(static_cast<value_type>(value));
}
- reference operator=(const char32_t& value)
+ reference operator=(const internal_type& value)
{
append_utf(value);
return *this;
@@ -442,6 +443,7 @@ namespace unicode {
typedef iso_back_insert_iterator* pointer;
typedef size_t difference_type;
typedef iso_t value_type;
+ typedef char32_t internal_type;
typedef std::output_iterator_tag iterator_category;
typedef Container string_type;
@@ -467,7 +469,7 @@ namespace unicode {
return *this;
}
- reference operator=(const char32_t& value)
+ reference operator=(const internal_type& value)
{
if constexpr(std::addressof(Map) != std::addressof(iso_8859_1_map_reverse)) // mapping of 128 <= x <= 255 needed
{