Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-04-17 08:39:01

0001 //
0002 // Copyright (c) 2019-2024 Ruben Perez Hidalgo (rubenperez038 at gmail dot com)
0003 //
0004 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0005 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 //
0007 
0008 #ifndef BOOST_MYSQL_IMPL_INTERNAL_CALL_NEXT_CHAR_HPP
0009 #define BOOST_MYSQL_IMPL_INTERNAL_CALL_NEXT_CHAR_HPP
0010 
0011 #include <boost/mysql/character_set.hpp>
0012 
0013 #include <boost/assert.hpp>
0014 
0015 #include <cstddef>
0016 
0017 namespace boost {
0018 namespace mysql {
0019 namespace detail {
0020 
0021 inline std::size_t call_next_char(const character_set& charset, const char* first, const char* last) noexcept
0022 {
0023     // Range must be non-empty
0024     BOOST_ASSERT(last > first);
0025 
0026     // ASCII characters are always 1 byte (UTF-16 and friends are not supported)
0027     auto* data = reinterpret_cast<const unsigned char*>(first);
0028     if (*data < 0x80)
0029         return 1u;
0030 
0031     // May be a multi-byte character. Call the relevant function
0032     return charset.next_char({data, static_cast<std::size_t>(last - first)});
0033 }
0034 
0035 }  // namespace detail
0036 }  // namespace mysql
0037 }  // namespace boost
0038 
0039 #endif