All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Static Public Member Functions | List of all members
nlohmann::detail::wide_string_input_helper< WideStringType, T > Struct Template Reference

#include <json.hpp>

Static Public Member Functions

static void fill_buffer (const WideStringType &str, size_t &current_wchar, std::array< std::char_traits< char >::int_type, 4 > &utf8_bytes, size_t &utf8_bytes_index, size_t &utf8_bytes_filled)
 

Detailed Description

template<typename WideStringType, size_t T>
struct nlohmann::detail::wide_string_input_helper< WideStringType, T >

Definition at line 4027 of file json.hpp.

Member Function Documentation

template<typename WideStringType , size_t T>
static void nlohmann::detail::wide_string_input_helper< WideStringType, T >::fill_buffer ( const WideStringType &  str,
size_t &  current_wchar,
std::array< std::char_traits< char >::int_type, 4 > &  utf8_bytes,
size_t &  utf8_bytes_index,
size_t &  utf8_bytes_filled 
)
inlinestatic

Definition at line 4030 of file json.hpp.

4035  {
4036  utf8_bytes_index = 0;
4037 
4038  if (current_wchar == str.size())
4039  {
4040  utf8_bytes[0] = std::char_traits<char>::eof();
4041  utf8_bytes_filled = 1;
4042  }
4043  else
4044  {
4045  // get the current character
4046  const auto wc = static_cast<unsigned int>(str[current_wchar++]);
4047 
4048  // UTF-32 to UTF-8 encoding
4049  if (wc < 0x80)
4050  {
4051  utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(wc);
4052  utf8_bytes_filled = 1;
4053  }
4054  else if (wc <= 0x7FF)
4055  {
4056  utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xC0u | ((wc >> 6u) & 0x1Fu));
4057  utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | (wc & 0x3Fu));
4058  utf8_bytes_filled = 2;
4059  }
4060  else if (wc <= 0xFFFF)
4061  {
4062  utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xE0u | ((wc >> 12u) & 0x0Fu));
4063  utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | ((wc >> 6u) & 0x3Fu));
4064  utf8_bytes[2] = static_cast<std::char_traits<char>::int_type>(0x80u | (wc & 0x3Fu));
4065  utf8_bytes_filled = 3;
4066  }
4067  else if (wc <= 0x10FFFF)
4068  {
4069  utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(0xF0u | ((wc >> 18u) & 0x07u));
4070  utf8_bytes[1] = static_cast<std::char_traits<char>::int_type>(0x80u | ((wc >> 12u) & 0x3Fu));
4071  utf8_bytes[2] = static_cast<std::char_traits<char>::int_type>(0x80u | ((wc >> 6u) & 0x3Fu));
4072  utf8_bytes[3] = static_cast<std::char_traits<char>::int_type>(0x80u | (wc & 0x3Fu));
4073  utf8_bytes_filled = 4;
4074  }
4075  else
4076  {
4077  // unknown character
4078  utf8_bytes[0] = static_cast<std::char_traits<char>::int_type>(wc);
4079  utf8_bytes_filled = 1;
4080  }
4081  }
4082  }

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