Skip to content

Commit

Permalink
Rename UtfView and utfview to utf_view
Browse files Browse the repository at this point in the history
This brings the project more into alignment with the Beman project's
preference for snake_case, which was added to the Beman project by the
following commit:

bemanproject/beman@7016bcc
  • Loading branch information
ednolan committed Oct 12, 2024
1 parent ebd31a8 commit 6655438
Show file tree
Hide file tree
Showing 27 changed files with 93 additions and 93 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ jobs:
- name: Coverage
run: |
lcov --directory ./build --capture --output-file ./build/coverage_all.info
lcov --remove ./build/coverage_all.info -o ./build/coverage.info '/usr/include/*' "$PWD/src/UtfView/tests/*" "$PWD/deps/*"
lcov --remove ./build/coverage_all.info -o ./build/coverage.info '/usr/include/*' "$PWD/src/utf_view/tests/*" "$PWD/deps/*"
- name: Coveralls
uses: coverallsapp/github-action@master
with:
path-to-lcov: ${{runner.workspace}}/UtfView/build/coverage.info
path-to-lcov: ${{runner.workspace}}/utf_view/build/coverage.info
github-token: ${{ secrets.GITHUB_TOKEN }}
clang-linux:
runs-on: ubuntu-latest
Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# https://www.boost.org/LICENSE_1_0.txt)

cmake_minimum_required(VERSION 3.27)
project(utfview CXX)
project(utf_view CXX)

if (BUILD_TESTING)
include(CTest)
Expand All @@ -27,6 +27,6 @@ else()
message(FATAL_ERROR "Conflicting dependency: boost_stl_interfaces already exists, but we need our own fork")
endif()

add_subdirectory(src/UtfView)
add_subdirectory(src/utf_view)

add_subdirectory(paper)
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ Distributed under the Boost Software License, Version 1.0.
https://www.boost.org/LICENSE_1_0.txt)
-->

# UtfView: C++26 UTF Transcoding Views
# utf_view: C++26 UTF Transcoding Views

[![CI](https://github.com/ednolan/UtfView/actions/workflows/ci.yml/badge.svg)](https://github.com/ednolan/utfview/actions) [![Coverage](https://coveralls.io/repos/github/ednolan/UtfView/badge.svg?branch=main)](https://coveralls.io/github/ednolan/UtfView?branch=main)
[![CI](https://github.com/ednolan/utf_view/actions/workflows/ci.yml/badge.svg)](https://github.com/ednolan/utf_view/actions) [![Coverage](https://coveralls.io/repos/github/ednolan/utf_view/badge.svg?branch=main)](https://coveralls.io/github/ednolan/utf_view?branch=main)

This repository implements the functionality proposed by P2728 for C++26, including:

Expand All @@ -23,23 +23,23 @@ Transcoding a UTF-8 string literal to a `std::u32string`:

```
std::u32string hello_world =
u8"こんにちは世界" | utfview::to_utf32 | std::ranges::to<std::u32string>();
u8"こんにちは世界" | utf_view::to_utf32 | std::ranges::to<std::u32string>();
```

Sanitizing potentially invalid Unicode C strings by replacing invalid code units with replacement characters:

```
template <typename CharT>
std::basic_string<CharT> sanitize(CharT const* str) {
return utfview::null_term(str) | utfview::to_utf<CharT> | std::ranges::to<std::basic_string<CharT>>();
return utf_view::null_term(str) | utf_view::to_utf<CharT> | std::ranges::to<std::basic_string<CharT>>();
}
```

Returning the final non-ASCII code point in a string, transcoding backwards lazily:

```
std::optional<char32_t> last_nonascii(std::ranges::view auto str) {
for (auto c : str | utfview::to_utf32 | std::views::reverse
for (auto c : str | utf_view::to_utf32 | std::views::reverse
| std::views::filter([](char32_t c) { return c > 0x7f; })
| std::views::take(1)) {
return c;
Expand Down Expand Up @@ -75,17 +75,17 @@ std::basic_string<ToChar> transcode_or_throw(std::basic_string_view<FromChar> in

### Minimum Requirements

UtfView requires being built in C++23 mode.
utf_view requires being built in C++23 mode.

UtfView has the following minimum compiler requirements:
utf_view has the following minimum compiler requirements:

- GCC 14
- Clang 19
- MSVC 17.11.2 (earlier MSVC versions may also work but are not tested in CI)

### Dependencies

UtfView depends on [Boost.STLInterfaces](https://github.com/boostorg/stl_interfaces). It brings in this library and its dependencies via git submodules. If you add UtfView to your project your project already uses Boost, it will target your project's stl_interfaces instead of using its own submodule.
utf_view depends on [Boost.STLInterfaces](https://github.com/boostorg/stl_interfaces). It brings in this library and its dependencies via git submodules. If you add utf_view to your project your project already uses Boost, it will target your project's stl_interfaces instead of using its own submodule.

### Instructions

Expand All @@ -99,10 +99,10 @@ This excerpt from the project's CI script provides an example of building the pr

### Paper

UtfView is based on P2728.
utf_view is based on P2728.

- The latest official revision of P2728 can be found at https://wg21.link/p2728
- The unofficial latest draft Markdown source for the paper can be found in this repository at [paper/P2828.md](https://github.com/ednolan/UtfView/blob/main/paper/P2728.md)
- The unofficial latest draft Markdown source for the paper can be found in this repository at [paper/P2828.md](https://github.com/ednolan/utf_view/blob/main/paper/P2728.md)
- The paper's committee status page can be found at https://github.com/cplusplus/papers/issues/1422

## Authors
Expand All @@ -111,4 +111,4 @@ This implementation of P2728 is a fork by Eddie Nolan of the implementation of P

## License

UtfView is licensed under BSL 1.0.
utf_view is licensed under BSL 1.0.
8 changes: 0 additions & 8 deletions include/UtfView/utfview.hpp

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
#ifndef UTFVIEW_CODE_UNIT_VIEW_HPP
#define UTFVIEW_CODE_UNIT_VIEW_HPP

#include <UtfView/detail/concepts.hpp>
#include <utf_view/detail/concepts.hpp>
#include <boost/stl_interfaces/iterator_interface.hpp>
#include <iterator>
#include <ranges>
#include <type_traits>
#include <utility>

namespace utfview {
namespace utf_view {

/* PAPER: namespace std::uc { */

Expand Down Expand Up @@ -583,18 +583,18 @@ inline constexpr detail::as_code_unit_impl<char32_t> as_char32_t;
/* PAPER: */
/* PAPER: } */

} // namespace utfview
} // namespace utf_view

template <class V>
inline constexpr bool std::ranges::enable_borrowed_range<utfview::as_char8_t_view<V>> =
inline constexpr bool std::ranges::enable_borrowed_range<utf_view::as_char8_t_view<V>> =
std::ranges::enable_borrowed_range<V>;

template <class V>
inline constexpr bool std::ranges::enable_borrowed_range<utfview::as_char16_t_view<V>> =
inline constexpr bool std::ranges::enable_borrowed_range<utf_view::as_char16_t_view<V>> =
std::ranges::enable_borrowed_range<V>;

template <class V>
inline constexpr bool std::ranges::enable_borrowed_range<utfview::as_char32_t_view<V>> =
inline constexpr bool std::ranges::enable_borrowed_range<utf_view::as_char32_t_view<V>> =
std::ranges::enable_borrowed_range<V>;

/* PAPER: namespace std::ranges { */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <ranges>
#include <type_traits>

namespace utfview {
namespace utf_view {

/* PAPER: namespace std::uc { */

Expand Down Expand Up @@ -49,7 +49,7 @@ concept exposition_only_utf_range = std::ranges::input_range<T> &&

/* !PAPER */

} // namespace utfview
} // namespace utf_view

/* PAPER: } */

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
#ifndef UTFVIEW_DETAIL_ERRONEOUS_BEHAVIOR_GLOBAL_HPP
#define UTFVIEW_DETAIL_ERRONEOUS_BEHAVIOR_GLOBAL_HPP

namespace utfview::detail {
namespace utf_view::detail {

inline bool& erroneous_behavior_global() {
static bool global{};
return global;
}

} // namespace utfview::detail
} // namespace utf_view::detail

#endif // UTFVIEW_DETAIL_ERRONEOUS_BEHAVIOR_GLOBAL_HPP
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <ranges>
#include <utility>

namespace utfview {
namespace utf_view {

/* PAPER: namespace std { */

Expand Down Expand Up @@ -59,7 +59,7 @@ inline constexpr detail::null_term_impl null_term;
/* PAPER: inline constexpr @*unspecified*@ null_term; */
/* PAPER: */

} // namespace utfview
} // namespace utf_view

/* PAPER: } */

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
#ifndef UTFVIEW_TO_UTF_VIEW_HPP
#define UTFVIEW_TO_UTF_VIEW_HPP

#include <UtfView/detail/concepts.hpp>
#include <UtfView/detail/constexpr_unless_msvc.hpp>
#include <UtfView/detail/erroneous_behavior_global.hpp>
#include <UtfView/null_term.hpp>
#include <utf_view/detail/concepts.hpp>
#include <utf_view/detail/constexpr_unless_msvc.hpp>
#include <utf_view/detail/erroneous_behavior_global.hpp>
#include <utf_view/null_term.hpp>
#include <bit>
#include <boost/stl_interfaces/iterator_interface.hpp>
#include <cassert>
Expand All @@ -24,7 +24,7 @@
#include <type_traits>
#include <utility>

namespace utfview {
namespace utf_view {

namespace detail {

Expand Down Expand Up @@ -1174,25 +1174,25 @@ inline constexpr detail::to_utf_impl<char32_t> to_utf32;
/* PAPER: */
/* PAPER: inline constexpr @*unspecified*@ to_utf32; */

} // namespace utfview
} // namespace utf_view

/* PAPER: } */

template <class ToType, class V>
inline constexpr bool std::ranges::enable_borrowed_range<
utfview::exposition_only_to_utf_view_impl<ToType, V>> =
utf_view::exposition_only_to_utf_view_impl<ToType, V>> =
std::ranges::enable_borrowed_range<V>;

template <class V>
inline constexpr bool std::ranges::enable_borrowed_range<utfview::to_utf8_view<V>> =
inline constexpr bool std::ranges::enable_borrowed_range<utf_view::to_utf8_view<V>> =
std::ranges::enable_borrowed_range<V>;

template <class V>
inline constexpr bool std::ranges::enable_borrowed_range<utfview::to_utf16_view<V>> =
inline constexpr bool std::ranges::enable_borrowed_range<utf_view::to_utf16_view<V>> =
std::ranges::enable_borrowed_range<V>;

template <class V>
inline constexpr bool std::ranges::enable_borrowed_range<utfview::to_utf32_view<V>> =
inline constexpr bool std::ranges::enable_borrowed_range<utf_view::to_utf32_view<V>> =
std::ranges::enable_borrowed_range<V>;

/* PAPER: namespace std::ranges { */
Expand Down
8 changes: 8 additions & 0 deletions include/utf_view/utfview.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#ifndef UTFVIEW_UTFVIEW_HPP
#define UTFVIEW_UTFVIEW_HPP

#include <utf_view/code_unit_view.hpp>
#include <utf_view/null_term.hpp>
#include <utf_view/to_utf_view.hpp>

#endif UTFVIEW_UTFVIEW_HPP
2 changes: 1 addition & 1 deletion paper/P2728.md
Original file line number Diff line number Diff line change
Expand Up @@ -6128,7 +6128,7 @@ __Outcome:__ Strong consensus in favor
# Implementation experience
The most recent revision of this paper has a reference implementation called
[UtfView](https://github.com/ednolan/utfview) available on GitHub, which is a
[utf_view](https://github.com/ednolan/utf_view) available on GitHub, which is a
fork of Jonathan Wakely's implementation of P2728R6 as an implementation
detail for libstdc++.

Expand Down
8 changes: 4 additions & 4 deletions paper/generator/generator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ function process_file() {

function main() {
local files=(
include/UtfView/code_unit_view.hpp
include/UtfView/detail/concepts.hpp
include/UtfView/null_term.hpp
include/UtfView/to_utf_view.hpp)
include/utf_view/code_unit_view.hpp
include/utf_view/detail/concepts.hpp
include/utf_view/null_term.hpp
include/utf_view/to_utf_view.hpp)
local build_dir=$generator_script_dir/build
mkdir $build_dir
cp $generator_script_dir/.clang-format $build_dir
Expand Down
10 changes: 5 additions & 5 deletions src/UtfView/CMakeLists.txt → src/utf_view/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@
# (See accompanying file LICENSE.txt or copy at
# https://www.boost.org/LICENSE_1_0.txt)

add_library(utfview INTERFACE)
add_library(utf_view INTERFACE)

include(GNUInstallDirs)
include_directories(${CMAKE_CURRENT_SOURCE_DIR})

target_include_directories(
utfview
utf_view
INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../../include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${CMAKE_LOWER_PROJECT_NAME}> # <prefix>/include/utfview
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${CMAKE_LOWER_PROJECT_NAME}> # <prefix>/include/utf_view
)

target_link_libraries(utfview INTERFACE boost_stl_interfaces)
target_link_libraries(utf_view INTERFACE boost_stl_interfaces)

install(
TARGETS utfview
TARGETS utf_view
EXPORT ${TARGETS_EXPORT_NAME}
DESTINATION ${CMAKE_INSTALL_LIBDIR})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# https://www.boost.org/LICENSE_1_0.txt)

add_library(
utfview_test_lib
utf_view_test_lib
STATIC
code_unit_view.t.cpp
detail/concepts.t.cpp
Expand All @@ -17,12 +17,12 @@ add_library(
std_archetypes/iterator.t.cpp
to_utf_view.t.cpp)

target_link_libraries(utfview_test_lib utfview)
target_link_libraries(utf_view_test_lib utf_view)

add_executable(
utfview_test
utf_view_test
main.t.cpp)

target_link_libraries(utfview_test "$<LINK_LIBRARY:WHOLE_ARCHIVE,utfview_test_lib>")
target_link_libraries(utf_view_test "$<LINK_LIBRARY:WHOLE_ARCHIVE,utf_view_test_lib>")

add_test(NAME utfview_test COMMAND utfview_test)
add_test(NAME utf_view_test COMMAND utf_view_test)
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
// (See accompanying file LICENSE.txt or copy at
// https://www.boost.org/LICENSE_1_0.txt)

#include <UtfView/code_unit_view.hpp>
#include <UtfView/detail/constexpr_unless_msvc.hpp>
#include <utf_view/code_unit_view.hpp>
#include <utf_view/detail/constexpr_unless_msvc.hpp>
#include <ranges>
#include <string_view>
#include <tests/framework.hpp>

namespace utfview::tests {
namespace utf_view::tests {

// TODO: Comprehensive testing for `code_unit_view`

Expand Down Expand Up @@ -44,4 +44,4 @@ static auto const init{[] {
return result;
}()};

} // namespace utfview::tests
} // namespace utf_view::tests
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
// (See accompanying file LICENSE.txt or copy at
// https://www.boost.org/LICENSE_1_0.txt)

#include <UtfView/detail/concepts.hpp>
#include <utf_view/detail/concepts.hpp>
#include <tests/std_archetypes/iterator.hpp>

namespace utfview::tests {
namespace utf_view::tests {

static_assert(exposition_only_code_unit_to<char8_t>);
static_assert(exposition_only_code_unit_to<char16_t>);
Expand All @@ -26,4 +26,4 @@ static_assert(!exposition_only_code_unit_from<int>);

// todo: utf_range

} // namespace utfview::detail::tests
} // namespace utf_view::detail::tests
Loading

0 comments on commit 6655438

Please sign in to comment.