-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
130 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// | ||
// Copyright (c) 2019-2023 Ruben Perez Hidalgo (rubenperez038 at gmail dot com) | ||
// | ||
// Distributed under the Boost Software License, Version 1.0. (See accompanying | ||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | ||
// | ||
|
||
#ifndef BOOST_MYSQL_IMPL_INTERNAL_CALL_NEXT_CHAR_HPP | ||
#define BOOST_MYSQL_IMPL_INTERNAL_CALL_NEXT_CHAR_HPP | ||
|
||
#include <boost/mysql/character_set.hpp> | ||
|
||
#include <boost/assert.hpp> | ||
|
||
#include <cstddef> | ||
|
||
namespace boost { | ||
namespace mysql { | ||
namespace detail { | ||
|
||
inline std::size_t call_next_char(const character_set& charset, const char* first, const char* last) noexcept | ||
{ | ||
// Range must be non-empty | ||
BOOST_ASSERT(last > first); | ||
|
||
// ASCII characters are always 1 byte (UTF-16 and friends are not supported) | ||
auto* data = reinterpret_cast<const unsigned char*>(first); | ||
if (*data < 0x80) | ||
return 1u; | ||
|
||
// May be a multi-byte character. Call the relevant function | ||
return charset.next_char({data, static_cast<std::size_t>(last - first)}); | ||
} | ||
|
||
} // namespace detail | ||
} // namespace mysql | ||
} // namespace boost | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// | ||
// Copyright (c) 2019-2023 Ruben Perez Hidalgo (rubenperez038 at gmail dot com) | ||
// | ||
// Distributed under the Boost Software License, Version 1.0. (See accompanying | ||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | ||
// | ||
|
||
#ifndef BOOST_MYSQL_TEST_UNIT_INCLUDE_TEST_UNIT_FF_CHARSET_HPP | ||
#define BOOST_MYSQL_TEST_UNIT_INCLUDE_TEST_UNIT_FF_CHARSET_HPP | ||
|
||
#include <boost/mysql/character_set.hpp> | ||
|
||
#include <boost/mysql/detail/make_string_view.hpp> | ||
|
||
namespace boost { | ||
namespace mysql { | ||
namespace test { | ||
|
||
// A hypothetical character set with rules that may confuse formatting algorithms. | ||
// Some MySQL charsets (e.g. gbk) contain ASCII-compatible continuation characters, like this one. | ||
inline std::size_t ff_charset_next_char(boost::span<const unsigned char> r) noexcept | ||
{ | ||
if (r[0] == 0xff) // 0xff marks a two-byte character | ||
return r.size() > 1u ? 2u : 0u; | ||
return 1u; | ||
}; | ||
constexpr character_set ff_charset{detail::make_string_view("ff_charset"), ff_charset_next_char}; | ||
|
||
} // namespace test | ||
} // namespace mysql | ||
} // namespace boost | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.