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_BYTE_TO_HEX_HPP
0009 #define BOOST_MYSQL_IMPL_INTERNAL_BYTE_TO_HEX_HPP
0010 
0011 #include <boost/config.hpp>
0012 
0013 namespace boost {
0014 namespace mysql {
0015 namespace detail {
0016 
0017 // We implement the translation to hex ourselves, since it's easy enough.
0018 // We use a table to look up characters
0019 BOOST_INLINE_CONSTEXPR char byte_to_hex_table[16] =
0020     {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
0021 
0022 // it should point to a buffer of size 2, at least
0023 inline char* byte_to_hex(unsigned char byte, char* it)
0024 {
0025     *it++ = byte_to_hex_table[(byte & ~15) >> 4];
0026     *it++ = byte_to_hex_table[byte & 15];
0027     return it;
0028 }
0029 
0030 }  // namespace detail
0031 }  // namespace mysql
0032 }  // namespace boost
0033 
0034 #endif