diff --git a/include/fkYAML/detail/input/lexical_analyzer.hpp b/include/fkYAML/detail/input/lexical_analyzer.hpp index 709e33f9..39e016b2 100644 --- a/include/fkYAML/detail/input/lexical_analyzer.hpp +++ b/include/fkYAML/detail/input/lexical_analyzer.hpp @@ -153,7 +153,7 @@ class lexical_analyzer m_input_handler.get_next(); break; } - m_value_buffer.push_back(next); + m_value_buffer.push_back(char_traits_type::to_char_type(next)); } return m_last_token_type = lexical_token_t::ANCHOR_PREFIX; } @@ -171,7 +171,7 @@ class lexical_analyzer m_input_handler.get_next(); break; } - m_value_buffer.push_back(next); + m_value_buffer.push_back(char_traits_type::to_char_type(next)); } return m_last_token_type = lexical_token_t::ALIAS_PREFIX; } @@ -212,7 +212,7 @@ class lexical_analyzer case '\'': return m_last_token_type = scan_string(); case '~': - m_value_buffer = current; + m_value_buffer = char_traits_type::to_char_type(current); return m_last_token_type = lexical_token_t::NULL_VALUE; case '+': return m_last_token_type = scan_number(); @@ -495,19 +495,19 @@ class lexical_analyzer { throw fkyaml::exception("Invalid YAML major version found."); } - m_value_buffer.push_back(m_input_handler.get_current()); + m_value_buffer.push_back(char_traits_type::to_char_type(m_input_handler.get_current())); if (m_input_handler.get_next() != '.') { throw fkyaml::exception("A period must be followed after the YAML major version."); } - m_value_buffer.push_back(m_input_handler.get_current()); + m_value_buffer.push_back(char_traits_type::to_char_type(m_input_handler.get_current())); switch (m_input_handler.get_next()) { case '1': case '2': - m_value_buffer.push_back(m_input_handler.get_current()); + m_value_buffer.push_back(char_traits_type::to_char_type(m_input_handler.get_current())); break; case '0': case '3': @@ -548,14 +548,14 @@ class lexical_analyzer switch (current) { case '-': - m_value_buffer.push_back(current); + m_value_buffer.push_back(char_traits_type::to_char_type(current)); ret = scan_negative_number(); break; case '+': ret = scan_decimal_number(); break; case '0': - m_value_buffer.push_back(current); + m_value_buffer.push_back(char_traits_type::to_char_type(current)); ret = scan_number_after_zero_at_first(); break; case '1': @@ -567,7 +567,7 @@ class lexical_analyzer case '7': case '8': case '9': - m_value_buffer.push_back(current); + m_value_buffer.push_back(char_traits_type::to_char_type(current)); ret = scan_decimal_number(); break; default: // LCOV_EXCL_LINE @@ -601,7 +601,7 @@ class lexical_analyzer if (std::isdigit(next)) { - m_value_buffer.push_back(next); + m_value_buffer.push_back(char_traits_type::to_char_type(next)); return scan_decimal_number(); } @@ -634,7 +634,7 @@ class lexical_analyzer switch (next) { case '.': - m_value_buffer.push_back(next); + m_value_buffer.push_back(char_traits_type::to_char_type(next)); return scan_decimal_number_after_decimal_point(); case 'o': // Do not store 'o' since std::strtoull does not support "0o" but "0" as the prefix for octal numbers. @@ -642,7 +642,7 @@ class lexical_analyzer // See "10.3.2. Tag Resolution" section in https://yaml.org/spec/1.2.2/ return scan_octal_number(); case 'x': - m_value_buffer.push_back(next); + m_value_buffer.push_back(char_traits_type::to_char_type(next)); return scan_hexadecimal_number(); default: return lexical_token_t::INTEGER_VALUE; @@ -660,7 +660,7 @@ class lexical_analyzer if (std::isdigit(next)) { - m_value_buffer.push_back(next); + m_value_buffer.push_back(char_traits_type::to_char_type(next)); scan_decimal_number(); return lexical_token_t::FLOAT_NUMBER_VALUE; } @@ -678,12 +678,12 @@ class lexical_analyzer char_int_type next = m_input_handler.get_next(); if (next == '+' || next == '-') { - m_value_buffer.push_back(next); + m_value_buffer.push_back(char_traits_type::to_char_type(next)); scan_decimal_number_after_sign(); } else if (std::isdigit(next)) { - m_value_buffer.push_back(next); + m_value_buffer.push_back(char_traits_type::to_char_type(next)); scan_decimal_number(); } else @@ -704,7 +704,7 @@ class lexical_analyzer if (std::isdigit(next)) { - m_value_buffer.push_back(next); + m_value_buffer.push_back(char_traits_type::to_char_type(next)); return scan_decimal_number(); } @@ -722,24 +722,25 @@ class lexical_analyzer if (std::isdigit(next)) { - m_value_buffer.push_back(next); + m_value_buffer.push_back(char_traits_type::to_char_type(next)); return scan_decimal_number(); } if (next == '.') { - if (m_value_buffer.find(next) != string_type::npos) // NOLINT(abseil-string-find-str-contains) + // NOLINTNEXTLINE(abseil-string-find-str-contains) + if (m_value_buffer.find(char_traits_type::to_char_type(next)) != string_type::npos) { // TODO: support this use case (e.g. version info like 1.0.0) throw fkyaml::exception("Multiple decimal points found in a token."); } - m_value_buffer.push_back(next); + m_value_buffer.push_back(char_traits_type::to_char_type(next)); return scan_decimal_number_after_decimal_point(); } if (next == 'e' || next == 'E') { - m_value_buffer.push_back(next); + m_value_buffer.push_back(char_traits_type::to_char_type(next)); return scan_decimal_number_after_exponent(); } @@ -756,7 +757,7 @@ class lexical_analyzer char_int_type next = m_input_handler.get_next(); if ('0' <= next && next <= '7') { - m_value_buffer.push_back(next); + m_value_buffer.push_back(char_traits_type::to_char_type(next)); scan_octal_number(); } return lexical_token_t::INTEGER_VALUE; @@ -772,7 +773,7 @@ class lexical_analyzer char_int_type next = m_input_handler.get_next(); if (std::isxdigit(next)) { - m_value_buffer.push_back(next); + m_value_buffer.push_back(char_traits_type::to_char_type(next)); scan_hexadecimal_number(); } return lexical_token_t::INTEGER_VALUE; @@ -818,7 +819,7 @@ class lexical_analyzer { return lexical_token_t::STRING_VALUE; } - m_value_buffer.push_back(current); + m_value_buffer.push_back(char_traits_type::to_char_type(current)); continue; } @@ -836,7 +837,7 @@ class lexical_analyzer } // if the target is a single-quoted string token. - m_value_buffer.push_back(current); + m_value_buffer.push_back(char_traits_type::to_char_type(current)); continue; } @@ -852,7 +853,7 @@ class lexical_analyzer // an escaped single quotation mark. if (m_input_handler.test_next_char('\'')) { - m_value_buffer.push_back(m_input_handler.get_next()); + m_value_buffer.push_back(char_traits_type::to_char_type(m_input_handler.get_next())); continue; } @@ -865,7 +866,7 @@ class lexical_analyzer // Just regard a colon as a character if surrounded by quotation marks. if (needs_last_double_quote || needs_last_single_quote) { - m_value_buffer.push_back(current); + m_value_buffer.push_back(char_traits_type::to_char_type(current)); continue; } @@ -875,7 +876,7 @@ class lexical_analyzer // A colon as a key separator must be followed by a space or a newline code. if (next != ' ' && next != '\r' && next != '\n') { - m_value_buffer.push_back(current); + m_value_buffer.push_back(char_traits_type::to_char_type(current)); continue; } @@ -895,7 +896,7 @@ class lexical_analyzer // Just regard a comma as a character if surrounded by quotation marks. if (needs_last_double_quote || needs_last_single_quote) { - m_value_buffer.push_back(current); + m_value_buffer.push_back(char_traits_type::to_char_type(current)); continue; } @@ -908,7 +909,7 @@ class lexical_analyzer // just regard a right square bracket as a character if surrounded by quotation marks. if (needs_last_double_quote || needs_last_single_quote) { - m_value_buffer.push_back(current); + m_value_buffer.push_back(char_traits_type::to_char_type(current)); continue; } @@ -921,7 +922,7 @@ class lexical_analyzer // just regard a right curly brace as a character if surrounded by quotation marks. if (needs_last_double_quote || needs_last_single_quote) { - m_value_buffer.push_back(current); + m_value_buffer.push_back(char_traits_type::to_char_type(current)); continue; } @@ -1018,7 +1019,7 @@ class lexical_analyzer // Handle ASCII characters except control characters. if (current <= 0x7E) { - m_value_buffer.push_back(current); + m_value_buffer.push_back(char_traits_type::to_char_type(current)); continue; } @@ -1056,7 +1057,7 @@ class lexical_analyzer case 0x08: throw fkyaml::exception("Control character U+0008 (BS) must be escaped to \\b or \\u0008."); case 0x09: // HT - m_value_buffer.push_back(c); + m_value_buffer.push_back(char_traits_type::to_char_type(c)); break; // 0x0A(LF) has already been handled above. case 0x0B: