btu::common namespace

Namespaces

namespace detail

Classes

struct Cards
struct Error
class Exception
class InvalidUTF8
template <typename T>
class Lazy
template <class... Ts>
struct Overload
class UTF8Iterator
template <class T>
struct is_mutable_lambda
template <class>
struct is_mutable_lambda_helper
template <class Ret, class Class, class... Args>
struct is_mutable_lambda_helper<Ret(Class::*)(Args...) const>
template <class Ret, class Class, class... Args>
struct is_mutable_lambda_helper<Ret(Class::*)(Args...)>
template <class T, class U>
struct is_variant_member
template <class T, class... Ts>
struct is_variant_member<T, std::variant<Ts...>>
template <typename GuardedData, basic_lockable MutexType>
class synchronized
template <typename GuardedType, basic_lockable MutexType = std::mutex>
class update_guard

Concepts

template <typename L>
concept basic_lockable
template <class Func, class Arg>
concept invocable_l_or_r

Enums

enum class CaseSensitive: std::uint8_t { Yes, No }

Typedefs

using ThreadPool = BS::thread_pool
using U8Unit = int32_t
template <typename T, typename U>
using is_equiv = std::is_same<std::remove_cvref_t<T>, std::remove_cvref_t<U>>

Functions

template <class... Ts>
Overload(Ts...) →  Overload< Ts... >
auto as_ascii(std::u8string_view str) →  std::string_view
auto as_ascii_string(std::u8string str) →  std::string
auto as_utf8(std::string_view str) →  std::u8string_view
auto as_utf8_string(std::string str) →  std::u8string
template <typename CharT>
void backslash_to_slash(std::basic_string<CharT>& path) noexcept
Convert backslashes to slashes in path.
auto compare_directories(const Path& dir1, const Path& dir2) →  bool noexcept
auto compare_files(const Path& filename1, const Path& filename2) →  bool noexcept
void concat_codepoint(std::u8string& string, U8Unit cp)
template <class Container, class ValueType>
auto contains(const Container& cont, const ValueType& val) →  auto
auto find_matching_paths_icase(const btu::Path& directory, std::span<const btu::Path> relative_lowercase_paths) →  std::vector<btu::Path> noexcept
auto first_codepoint(std::u8string_view string) →  U8Unit constexpr
template <typename Range, typename Func>
auto for_each_mt(Range&& rng, Func&& func) →  auto
template <class T, class U>
auto forward_like(U&& x) →  decltype(auto) constexpr noexcept
See https://en.cppreference.com/w/cpp/utility/forward_like.
auto hard_link(const Path& from, const Path& to) →  tl::expected<void, Error> noexcept
auto hardware_concurrency() →  unsigned noexcept
auto is_lower(std::u8string_view string) →  bool constexpr
auto make_path_canonizer(std::u8string_view start) →  auto constexpr
template <typename Out, typename Range, typename Func>
auto make_producer_mt(Range&& rng, Func&& func) →  auto
Creates a multi-threaded producer for the specified range and function.
auto make_thread_pool()
Creates a thread pool with the number of threads equal to the number of hardware threads minus one.
auto make_valid(std::u8string& string, char8_t replacement) →  std::u8string& noexcept
template <class It, class Predicate, class Sum, class ValueType = typename std::iterator_traits<It>::value_type>
auto merge_if(It first, It last, const Predicate& predicate, const Sum& sum) →  It
template <class It, class Predicate>
auto merge_if(It first, It last, Predicate&& predicate) →  It
template <class Container, class Predicate>
auto merge_if(Container& cont, Predicate&& predicate) →  auto
template <class Container, class Predicate, class Sum>
auto merge_if(Container& cont, Predicate&& pred, Sum&& sum) →  auto
auto operator<<(std::ostream& os, std::source_location loc) →  std::ostream&
auto operator<<(std::ostream& os, const Error& err) →  std::ostream&
auto read_file(const Path& a_path) →  tl::expected<std::vector<std::byte>, Error> noexcept
template <class ValueType>
void remove_duplicates(std::vector<ValueType>& cont)
auto str_compare(std::u8string_view lhs, std::u8string_view rhs, CaseSensitive case_sensitive = CaseSensitive::Yes) →  bool constexpr
auto str_contain(std::u8string_view string, std::u8string_view snippet, CaseSensitive case_sensitive = CaseSensitive::Yes) →  bool constexpr
auto str_find(std::u8string_view string, std::u8string_view snippet, CaseSensitive case_sensitive = CaseSensitive::Yes) →  size_t constexpr
auto str_match(std::u8string_view string, std::u8string_view pattern, CaseSensitive case_sensitive = CaseSensitive::Yes, Cards cards = default_cards) →  bool constexpr
auto str_random(size_t length, std::span<const char8_t> charset = k_lower_alphabetic_charset) →  std::u8string noexcept
auto str_replace_once(std::u8string& string, std::u8string_view from, std::u8string_view to, CaseSensitive case_sensitive) →  std::u8string& constexpr
auto str_starts_with(std::u8string_view string, std::u8string_view snippet, CaseSensitive case_sensitive = CaseSensitive::Yes) →  bool constexpr
auto str_trim(std::u8string_view in) →  std::u8string_view constexpr noexcept
auto to_lower(std::u8string_view string) →  std::u8string
template <typename E>
auto to_underlying(E e) →  std::underlying_type_t<E> constexpr
auto to_utf16(const std::u8string& str) →  std::wstring
auto to_utf8(const std::wstring& str) →  std::u8string
auto write_file(const Path& a_path, std::span<const std::byte> data) →  tl::expected<void, Error> noexcept
auto write_file_new(const Path& a_path, std::span<const std::byte> data) →  tl::expected<void, Error> noexcept

Variables

detail::bind_back_fn bind_back constexpr
Cards default_cards constexpr
template <typename T, typename U>
bool is_equiv_v constexpr
template <class T>
bool is_mutable_lambda_v constexpr
template <class T, class... Ts>
bool is_variant_member_v constexpr
auto k_lower_alphabetic_charset constexpr

Enum documentation

enum class btu::common::CaseSensitive: std::uint8_t

Typedef documentation

using btu::common::ThreadPool = BS::thread_pool

using btu::common::U8Unit = int32_t

template <typename T, typename U>
using btu::common::is_equiv = std::is_same<std::remove_cvref_t<T>, std::remove_cvref_t<U>>

Function documentation

template <class... Ts>
btu::common::Overload(Ts...) →  Overload< Ts... >

template <typename CharT>
void btu::common::backslash_to_slash(std::basic_string<CharT>& path) noexcept

Convert backslashes to slashes in path.

std::fs do not consider '\' as a separator on Linux. In fact, it is a valid character in file names. But in our case, we want to treat it as a separator. Let's hope no one will use it in file names.

bool btu::common::compare_directories(const Path& dir1, const Path& dir2) noexcept

bool btu::common::compare_files(const Path& filename1, const Path& filename2) noexcept

void btu::common::concat_codepoint(std::u8string& string, U8Unit cp)

template <class Container, class ValueType>
auto btu::common::contains(const Container& cont, const ValueType& val)

std::vector<btu::Path> btu::common::find_matching_paths_icase(const btu::Path& directory, std::span<const btu::Path> relative_lowercase_paths) noexcept

U8Unit btu::common::first_codepoint(std::u8string_view string) constexpr

template <typename Range, typename Func>
auto btu::common::for_each_mt(Range&& rng, Func&& func)

template <class T, class U>
decltype(auto) btu::common::forward_like(U&& x) constexpr noexcept

See https://en.cppreference.com/w/cpp/utility/forward_like.

tl::expected<void, Error> btu::common::hard_link(const Path& from, const Path& to) noexcept

unsigned btu::common::hardware_concurrency() noexcept

bool btu::common::is_lower(std::u8string_view string) constexpr

auto btu::common::make_path_canonizer(std::u8string_view start) constexpr

template <typename Out, typename Range, typename Func>
auto btu::common::make_producer_mt(Range&& rng, Func&& func)

Creates a multi-threaded producer for the specified range and function.

Template parameters
Out
Range The type of the range.
Func The type of the function.
Parameters
rng The range of elements to process.
func The function to apply to each element in the range.
Returns The multi-threaded producer object.

This function creates a multi-threaded producer that generates values by applying the specified function to each element in the given range. The producer distributes the workload across multiple threads to improve performance.

auto btu::common::make_thread_pool()

Creates a thread pool with the number of threads equal to the number of hardware threads minus one.

Returns The thread pool object.

std::u8string& btu::common::make_valid(std::u8string& string, char8_t replacement) noexcept

template <class It, class Predicate, class Sum, class ValueType = typename std::iterator_traits<It>::value_type>
It btu::common::merge_if(It first, It last, const Predicate& predicate, const Sum& sum)

template <class It, class Predicate>
It btu::common::merge_if(It first, It last, Predicate&& predicate)

template <class Container, class Predicate>
auto btu::common::merge_if(Container& cont, Predicate&& predicate)

template <class Container, class Predicate, class Sum>
auto btu::common::merge_if(Container& cont, Predicate&& pred, Sum&& sum)

std::ostream& btu::common::operator<<(std::ostream& os, const Error& err)

tl::expected<std::vector<std::byte>, Error> btu::common::read_file(const Path& a_path) noexcept

template <class ValueType>
void btu::common::remove_duplicates(std::vector<ValueType>& cont)

bool btu::common::str_compare(std::u8string_view lhs, std::u8string_view rhs, CaseSensitive case_sensitive = CaseSensitive::Yes) constexpr

bool btu::common::str_contain(std::u8string_view string, std::u8string_view snippet, CaseSensitive case_sensitive = CaseSensitive::Yes) constexpr

size_t btu::common::str_find(std::u8string_view string, std::u8string_view snippet, CaseSensitive case_sensitive = CaseSensitive::Yes) constexpr

bool btu::common::str_match(std::u8string_view string, std::u8string_view pattern, CaseSensitive case_sensitive = CaseSensitive::Yes, Cards cards = default_cards) constexpr

std::u8string btu::common::str_random(size_t length, std::span<const char8_t> charset = k_lower_alphabetic_charset) noexcept

std::u8string& btu::common::str_replace_once(std::u8string& string, std::u8string_view from, std::u8string_view to, CaseSensitive case_sensitive) constexpr

bool btu::common::str_starts_with(std::u8string_view string, std::u8string_view snippet, CaseSensitive case_sensitive = CaseSensitive::Yes) constexpr

std::u8string_view btu::common::str_trim(std::u8string_view in) constexpr noexcept

template <typename E>
std::underlying_type_t<E> btu::common::to_underlying(E e) constexpr

std::wstring btu::common::to_utf16(const std::u8string& str)

std::u8string btu::common::to_utf8(const std::wstring& str)

tl::expected<void, Error> btu::common::write_file(const Path& a_path, std::span<const std::byte> data) noexcept

tl::expected<void, Error> btu::common::write_file_new(const Path& a_path, std::span<const std::byte> data) noexcept

Variable documentation

detail::bind_back_fn btu::common::bind_back constexpr

Cards btu::common::default_cards constexpr

template <typename T, typename U>
bool btu::common::is_equiv_v constexpr

template <class T>
bool btu::common::is_mutable_lambda_v constexpr

template <class T, class... Ts>
bool btu::common::is_variant_member_v constexpr

auto btu::common::k_lower_alphabetic_charset constexpr