Skip to content

Commit

Permalink
🛠 Minor compilation fixes for different platforms.
Browse files Browse the repository at this point in the history
  • Loading branch information
ThePhD committed Oct 6, 2022
1 parent b7f418b commit db4962c
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 15 deletions.
3 changes: 2 additions & 1 deletion benchmarks/conversion_speed/source/ctre.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ static void utf8_to_utf32_unchecked_well_formed_ctre(benchmark::State& state) {
std::vector<ztd_char32_t> output_data(c_span_char32_t_size(u32_data));
bool result = true;
for (auto _ : state) {
ctre::utf8_range view(std::basic_string_view<unsigned char>(input_data.data(), input_data.size()));
ctre::utf8_range view(std::basic_string_view<ztd_char8_t>(
reinterpret_cast<const ztd_char8_t*>(input_data.data()), input_data.size()));
auto out_it = output_data.begin();
auto last = view.end();
for (auto it = view.begin(); it != last; (void)++it, ++out_it) {
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/conversion_speed/source/cuneicode_registry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ struct registry_deleter {
cnc_conversion* raw_conversion = nullptr; \
cnc_conversion_info info = {}; \
const cnc_open_error err = cnc_new_registry(&raw_registry, CNC_REGISTRY_OPTIONS_NONE); \
if (err != CNC_OPEN_ERROR_OKAY) { \
if (err != CNC_OPEN_ERROR_OK) { \
/* something went wrong, get out of here quick! */ \
state.SkipWithError("bad benchmark result"); \
return; \
Expand All @@ -77,7 +77,7 @@ struct registry_deleter {
} \
const cnc_open_error conv_err = cnc_conv_new(registry.get(), (const ztd_char8_t*)u8"UTF-" #FROM_N, \
(const ztd_char8_t*)u8"UTF-" #TO_N, &raw_conversion, &info); \
if (conv_err != CNC_OPEN_ERROR_OKAY) { \
if (conv_err != CNC_OPEN_ERROR_OK) { \
/* something went wrong, get out of here quick! */ \
state.SkipWithError("bad benchmark result"); \
return; \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ struct registry_deleter {
cnc_conversion* raw_conversion = nullptr; \
cnc_conversion_info info = {}; \
const cnc_open_error err = cnc_new_registry(&raw_registry, CNC_REGISTRY_OPTIONS_NONE); \
if (err != CNC_OPEN_ERROR_OKAY) { \
if (err != CNC_OPEN_ERROR_OK) { \
/* something went wrong, get out of here quick! */ \
state.SkipWithError("bad benchmark result"); \
return; \
Expand All @@ -78,7 +78,7 @@ struct registry_deleter {
const cnc_open_error conv_err \
= cnc_conv_new(registry.get(), (const ztd_char8_t*)u8"UTF-" #FROM_N "-unchecked", \
(const ztd_char8_t*)u8"UTF-" #TO_N "-unchecked", &raw_conversion, &info); \
if (conv_err != CNC_OPEN_ERROR_OKAY) { \
if (conv_err != CNC_OPEN_ERROR_OK) { \
/* something went wrong, get out of here quick! */ \
state.SkipWithError("bad benchmark result"); \
return; \
Expand Down
9 changes: 5 additions & 4 deletions examples/boost.text/source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,12 @@
#include <cstdint>

int main() {
using rope_t = boost::text::basic_unencoded_rope<char32_t>;
using rope_view_t = boost::text::basic_unencoded_rope_view<char32_t>;
rope_t rope = U"✨🌃⭐❣";
using rope_t = boost::text::basic_unencoded_rope<char16_t>;
using rope_view_t = boost::text::basic_unencoded_rope_view<char16_t>;
rope_t rope = u"✨🌃⭐❣";
rope_view_t rope_view(rope, 0, rope.size());
ztd::text::encode_view<ztd::text::compat_utf8_t, rope_view_t> utf8_rope_view { std::move(rope_view) };
ztd::text::transcode_view<ztd::text::utf16_t, ztd::text::compat_utf8_t, rope_view_t> utf8_rope_view { std::move(
rope_view) };
// allows us to iterate over a rope and print things
for (const auto& code_unit : utf8_rope_view) {
std::cout.write(&code_unit, 1);
Expand Down
4 changes: 2 additions & 2 deletions include/ztd/text/execution.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ namespace ztd { namespace text {
#else
no_encoding_t<char, unicode_code_point>
#error \
"This platform configuration (no POSIX conversions, no <uchar.h> or <cuchar> is currently not supported. One way to" \
"work aroudn this is by making sure iconv is available and turning on ZTD_TEXT_ICONV."
"This platform configuration (no POSIX conversions, no <uchar.h> or <cuchar>) is currently not supported. Please" \
" report the platform you are on and any other relevant information to the maintainer."
#endif
{
};
Expand Down
16 changes: 16 additions & 0 deletions include/ztd/text/normalized_iterator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,22 @@ namespace ztd { namespace text {
/// @brief The code point type.
using value_type = __code_point;

//////
/// @brief The reference type.
using reference = value_type;

//////
/// @brief The difference type.
using difference_type = ranges::range_difference_type_t<_URange>;

//////
/// @brief The iterator category. Always a forward iterator.
using iterator_category = ::std::forward_iterator_tag;

//////
/// @brief The iterator concept. Always considered a forward iterator.
using iterator_concept = ::std::forward_iterator_tag;

//////
/// @brief The code point type.
using range_type = _Range;
Expand Down
9 changes: 5 additions & 4 deletions include/ztd/text/transcode_iterator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,10 @@ namespace ztd { namespace text {
unwrap_remove_cvref_t<_FromErrorHandler>> // cf
&& encode_error_handler_always_returns_ok_v<unwrap_remove_cvref_t<_ToEncoding>,
unwrap_remove_cvref_t<_ToErrorHandler>>>,
private ebco<_Range, 4> {
private ebco<ranges::range_reconstruct_t<unwrap_remove_cvref_t<_Range>>, 4> {
private:
using _URange = unwrap_remove_cvref_t<_Range>;
using _UNonRRange = unwrap_remove_cvref_t<_Range>;
using _URange = ranges::range_reconstruct_t<_UNonRRange>;
using _UFromEncoding = unwrap_remove_cvref_t<_FromEncoding>;
using _UToEncoding = unwrap_remove_cvref_t<_ToEncoding>;
using _UFromErrorHandler = unwrap_remove_cvref_t<_FromErrorHandler>;
Expand All @@ -128,7 +129,7 @@ namespace ztd { namespace text {
= __txt_detail::__state_storage<remove_cvref_t<_FromEncoding>, remove_cvref_t<_FromState>, 0>;
using __base_to_state_t
= __txt_detail::__state_storage<remove_cvref_t<_ToEncoding>, remove_cvref_t<_ToState>, 1>;
using __base_range_t = ebco<_Range, 4>;
using __base_range_t = ebco<_URange, 4>;

inline static constexpr bool _IsBackwards = is_detected_v<__txt_detail::__detect_object_encode_one_backwards,
_UFromEncoding, _URange, _UFromErrorHandler, _UFromState>;
Expand Down Expand Up @@ -284,7 +285,7 @@ namespace ztd { namespace text {
, __base_from_state_t(this->from_encoding(), ::std::move(__from_state))
, __base_to_state_t(this->to_encoding(), ::std::move(__to_state))
, __base_cursor_cache_t()
, __base_range_t(::std::move(__range))
, __base_range_t(ranges::reconstruct(std::in_place_type<_UNonRRange>, ::std::move(__range)))
, _M_cache() {
this->_M_read_one();
}
Expand Down

0 comments on commit db4962c

Please sign in to comment.