Fast Methods for Cosmological Simulations
FastSim serves as a tool for quick N-body simulations in modified gravity.
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 2173 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 2176 of file json.hpp.

Referenced by nlohmann::detail::wide_string_input_adapter< WideStringType >::fill_buffer().

2177  {
2178  utf8_bytes_index = 0;
2179 
2180  if (current_wchar == str.size())
2181  {
2182  utf8_bytes[0] = std::char_traits<char>::eof();
2183  utf8_bytes_filled = 1;
2184  }
2185  else
2186  {
2187  // get the current character
2188  const auto wc = static_cast<int>(str[current_wchar++]);
2189 
2190  // UTF-32 to UTF-8 encoding
2191  if (wc < 0x80)
2192  {
2193  utf8_bytes[0] = wc;
2194  utf8_bytes_filled = 1;
2195  }
2196  else if (wc <= 0x7FF)
2197  {
2198  utf8_bytes[0] = 0xC0 | ((wc >> 6) & 0x1F);
2199  utf8_bytes[1] = 0x80 | (wc & 0x3F);
2200  utf8_bytes_filled = 2;
2201  }
2202  else if (wc <= 0xFFFF)
2203  {
2204  utf8_bytes[0] = 0xE0 | ((wc >> 12) & 0x0F);
2205  utf8_bytes[1] = 0x80 | ((wc >> 6) & 0x3F);
2206  utf8_bytes[2] = 0x80 | (wc & 0x3F);
2207  utf8_bytes_filled = 3;
2208  }
2209  else if (wc <= 0x10FFFF)
2210  {
2211  utf8_bytes[0] = 0xF0 | ((wc >> 18) & 0x07);
2212  utf8_bytes[1] = 0x80 | ((wc >> 12) & 0x3F);
2213  utf8_bytes[2] = 0x80 | ((wc >> 6) & 0x3F);
2214  utf8_bytes[3] = 0x80 | (wc & 0x3F);
2215  utf8_bytes_filled = 4;
2216  }
2217  else
2218  {
2219  // unknown character
2220  utf8_bytes[0] = wc;
2221  utf8_bytes_filled = 1;
2222  }
2223  }
2224  }

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