Static Public Member Functions
utf_decoder< Traits, opt_swap > Struct Template Reference

List of all members.

Static Public Member Functions

static Traits::value_type decode_utf8_block (const uint8_t *data, size_t size, typename Traits::value_type result)
static Traits::value_type decode_utf16_block (const uint16_t *data, size_t size, typename Traits::value_type result)
static Traits::value_type decode_utf32_block (const uint32_t *data, size_t size, typename Traits::value_type result)
static Traits::value_type decode_latin1_block (const uint8_t *data, size_t size, typename Traits::value_type result)
static Traits::value_type decode_wchar_block_impl (const uint16_t *data, size_t size, typename Traits::value_type result)
static Traits::value_type decode_wchar_block_impl (const uint32_t *data, size_t size, typename Traits::value_type result)
static Traits::value_type decode_wchar_block (const wchar_t *data, size_t size, typename Traits::value_type result)

Detailed Description

template<typename Traits, typename opt_swap = opt_false>
struct utf_decoder< Traits, opt_swap >

Definition at line 952 of file pugixml.cpp.


Member Function Documentation

template<typename Traits , typename opt_swap = opt_false>
static Traits::value_type utf_decoder< Traits, opt_swap >::decode_latin1_block ( const uint8_t *  data,
size_t  size,
typename Traits::value_type  result 
) [inline, static]

Definition at line 1085 of file pugixml.cpp.

Referenced by convert_buffer_latin1().

                {
                        for (size_t i = 0; i < size; ++i)
                        {
                                result = Traits::low(result, data[i]);
                        }

                        return result;
                }
template<typename Traits , typename opt_swap = opt_false>
static Traits::value_type utf_decoder< Traits, opt_swap >::decode_utf16_block ( const uint16_t *  data,
size_t  size,
typename Traits::value_type  result 
) [inline, static]

Definition at line 1016 of file pugixml.cpp.

References endian_swap().

Referenced by convert_buffer_utf16(), and utf_decoder< Traits, opt_swap >::decode_wchar_block_impl().

                {
                        const uint16_t* end = data + size;

                        while (data < end)
                        {
                                unsigned int lead = opt_swap::value ? endian_swap(*data) : *data;

                                // U+0000..U+D7FF
                                if (lead < 0xD800)
                                {
                                        result = Traits::low(result, lead);
                                        data += 1;
                                }
                                // U+E000..U+FFFF
                                else if (static_cast<unsigned int>(lead - 0xE000) < 0x2000)
                                {
                                        result = Traits::low(result, lead);
                                        data += 1;
                                }
                                // surrogate pair lead
                                else if (static_cast<unsigned int>(lead - 0xD800) < 0x400 && data + 1 < end)
                                {
                                        uint16_t next = opt_swap::value ? endian_swap(data[1]) : data[1];

                                        if (static_cast<unsigned int>(next - 0xDC00) < 0x400)
                                        {
                                                result = Traits::high(result, 0x10000 + ((lead & 0x3ff) << 10) + (next & 0x3ff));
                                                data += 2;
                                        }
                                        else
                                        {
                                                data += 1;
                                        }
                                }
                                else
                                {
                                        data += 1;
                                }
                        }

                        return result;
                }
template<typename Traits , typename opt_swap = opt_false>
static Traits::value_type utf_decoder< Traits, opt_swap >::decode_utf32_block ( const uint32_t *  data,
size_t  size,
typename Traits::value_type  result 
) [inline, static]

Definition at line 1060 of file pugixml.cpp.

References endian_swap().

Referenced by convert_buffer_utf32(), and utf_decoder< Traits, opt_swap >::decode_wchar_block_impl().

                {
                        const uint32_t* end = data + size;

                        while (data < end)
                        {
                                uint32_t lead = opt_swap::value ? endian_swap(*data) : *data;

                                // U+0000..U+FFFF
                                if (lead < 0x10000)
                                {
                                        result = Traits::low(result, lead);
                                        data += 1;
                                }
                                // U+10000..U+10FFFF
                                else
                                {
                                        result = Traits::high(result, lead);
                                        data += 1;
                                }
                        }

                        return result;
                }
template<typename Traits , typename opt_swap = opt_false>
static Traits::value_type utf_decoder< Traits, opt_swap >::decode_utf8_block ( const uint8_t *  data,
size_t  size,
typename Traits::value_type  result 
) [inline, static]

Definition at line 954 of file pugixml.cpp.

Referenced by as_wide_impl(), and convert_buffer_output().

                {
                        const uint8_t utf8_byte_mask = 0x3f;

                        while (size)
                        {
                                uint8_t lead = *data;

                                // 0xxxxxxx -> U+0000..U+007F
                                if (lead < 0x80)
                                {
                                        result = Traits::low(result, lead);
                                        data += 1;
                                        size -= 1;

                                        // process aligned single-byte (ascii) blocks
                                        if ((reinterpret_cast<uintptr_t>(data) & 3) == 0)
                                        {
                                                // round-trip through void* to silence 'cast increases required alignment of target type' warnings
                                                while (size >= 4 && (*static_cast<const uint32_t*>(static_cast<const void*>(data)) & 0x80808080) == 0)
                                                {
                                                        result = Traits::low(result, data[0]);
                                                        result = Traits::low(result, data[1]);
                                                        result = Traits::low(result, data[2]);
                                                        result = Traits::low(result, data[3]);
                                                        data += 4;
                                                        size -= 4;
                                                }
                                        }
                                }
                                // 110xxxxx -> U+0080..U+07FF
                                else if (static_cast<unsigned int>(lead - 0xC0) < 0x20 && size >= 2 && (data[1] & 0xc0) == 0x80)
                                {
                                        result = Traits::low(result, ((lead & ~0xC0) << 6) | (data[1] & utf8_byte_mask));
                                        data += 2;
                                        size -= 2;
                                }
                                // 1110xxxx -> U+0800-U+FFFF
                                else if (static_cast<unsigned int>(lead - 0xE0) < 0x10 && size >= 3 && (data[1] & 0xc0) == 0x80 && (data[2] & 0xc0) == 0x80)
                                {
                                        result = Traits::low(result, ((lead & ~0xE0) << 12) | ((data[1] & utf8_byte_mask) << 6) | (data[2] & utf8_byte_mask));
                                        data += 3;
                                        size -= 3;
                                }
                                // 11110xxx -> U+10000..U+10FFFF
                                else if (static_cast<unsigned int>(lead - 0xF0) < 0x08 && size >= 4 && (data[1] & 0xc0) == 0x80 && (data[2] & 0xc0) == 0x80 && (data[3] & 0xc0) == 0x80)
                                {
                                        result = Traits::high(result, ((lead & ~0xF0) << 18) | ((data[1] & utf8_byte_mask) << 12) | ((data[2] & utf8_byte_mask) << 6) | (data[3] & utf8_byte_mask));
                                        data += 4;
                                        size -= 4;
                                }
                                // 10xxxxxx or 11111xxx -> invalid
                                else
                                {
                                        data += 1;
                                        size -= 1;
                                }
                        }

                        return result;
                }
template<typename Traits , typename opt_swap = opt_false>
static Traits::value_type utf_decoder< Traits, opt_swap >::decode_wchar_block ( const wchar_t *  data,
size_t  size,
typename Traits::value_type  result 
) [inline, static]

Definition at line 1105 of file pugixml.cpp.

References utf_decoder< Traits, opt_swap >::decode_wchar_block_impl().

Referenced by as_utf8_begin(), and as_utf8_end().

                {
                        return decode_wchar_block_impl(reinterpret_cast<const wchar_selector<sizeof(wchar_t)>::type*>(data), size, result);
                }
template<typename Traits , typename opt_swap = opt_false>
static Traits::value_type utf_decoder< Traits, opt_swap >::decode_wchar_block_impl ( const uint16_t *  data,
size_t  size,
typename Traits::value_type  result 
) [inline, static]

Definition at line 1095 of file pugixml.cpp.

References utf_decoder< Traits, opt_swap >::decode_utf16_block().

Referenced by utf_decoder< Traits, opt_swap >::decode_wchar_block().

                {
                        return decode_utf16_block(data, size, result);
                }
template<typename Traits , typename opt_swap = opt_false>
static Traits::value_type utf_decoder< Traits, opt_swap >::decode_wchar_block_impl ( const uint32_t *  data,
size_t  size,
typename Traits::value_type  result 
) [inline, static]

Definition at line 1100 of file pugixml.cpp.

References utf_decoder< Traits, opt_swap >::decode_utf32_block().

                {
                        return decode_utf32_block(data, size, result);
                }

The documentation for this struct was generated from the following file:

Generated on Mon Sep 15 2014 01:23:55 for QuickFIX by doxygen 1.7.6.1 written by Dimitri van Heesch, © 1997-2001