MCPcopy Create free account
hub / github.com/Open-GD/OpenGD / lexer

Class lexer

Source/external/json.hpp:7412–8611  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7410*/
7411template<typename BasicJsonType, typename InputAdapterType>
7412class lexer : public lexer_base<BasicJsonType>
7413{
7414 using number_integer_t = typename BasicJsonType::number_integer_t;
7415 using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
7416 using number_float_t = typename BasicJsonType::number_float_t;
7417 using string_t = typename BasicJsonType::string_t;
7418 using char_type = typename InputAdapterType::char_type;
7419 using char_int_type = typename std::char_traits<char_type>::int_type;
7420
7421 public:
7422 using token_type = typename lexer_base<BasicJsonType>::token_type;
7423
7424 explicit lexer(InputAdapterType&& adapter, bool ignore_comments_ = false) noexcept
7425 : ia(std::move(adapter))
7426 , ignore_comments(ignore_comments_)
7427 , decimal_point_char(static_cast<char_int_type>(get_decimal_point()))
7428 {}
7429
7430 // delete because of pointer members
7431 lexer(const lexer&) = delete;
7432 lexer(lexer&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor)
7433 lexer& operator=(lexer&) = delete;
7434 lexer& operator=(lexer&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor)
7435 ~lexer() = default;
7436
7437 private:
7438 /////////////////////
7439 // locales
7440 /////////////////////
7441
7442 /// return the locale-dependent decimal point
7443 JSON_HEDLEY_PURE
7444 static char get_decimal_point() noexcept
7445 {
7446 const auto* loc = localeconv();
7447 JSON_ASSERT(loc != nullptr);
7448 return (loc->decimal_point == nullptr) ? '.' : *(loc->decimal_point);
7449 }
7450
7451 /////////////////////
7452 // scan functions
7453 /////////////////////
7454
7455 /*!
7456 @brief get codepoint from 4 hex characters following `\u`
7457
7458 For input "\u c1 c2 c3 c4" the codepoint is:
7459 (c1 * 0x1000) + (c2 * 0x0100) + (c3 * 0x0010) + c4
7460 = (c1 << 12) + (c2 << 8) + (c3 << 4) + (c4 << 0)
7461
7462 Furthermore, the possible characters '0'..'9', 'A'..'F', and 'a'..'f'
7463 must be converted to the integers 0x0..0x9, 0xA..0xF, 0xA..0xF, resp. The
7464 conversion is done by subtracting the offset (0x30, 0x37, and 0x57)
7465 between the ASCII value of the character and the desired integer value.
7466
7467 @return codepoint (0x0000..0xFFFF) or -1 in case of an error (e.g. EOF or
7468 non-hex character)
7469 */

Callers

nothing calls this directly

Calls 1

getFunction · 0.85

Tested by

no test coverage detected