diff options
Diffstat (limited to 'include')
63 files changed, 7356 insertions, 0 deletions
diff --git a/include/dux/algo b/include/dux/algo new file mode 100644 index 0000000..4358784 --- /dev/null +++ b/include/dux/algo @@ -0,0 +1,26 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of dux. + + dux is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your + option) any later version. + + dux is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + License for more details. + + You should have received a copy of the GNU Affero General Public License + along with dux. If not, see <https://www.gnu.org/licenses/>. +*/ + +#if !defined(dux_hdr_algo) +#define dux_hdr_algo + +#include <dux/base> +#include <dux/algo.hh> + +#endif diff --git a/include/dux/algo.d/abs.hh b/include/dux/algo.d/abs.hh new file mode 100644 index 0000000..b713c90 --- /dev/null +++ b/include/dux/algo.d/abs.hh @@ -0,0 +1,30 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of dux. + + dux is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your + option) any later version. + + dux is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + License for more details. + + You should have received a copy of the GNU Affero General Public License + along with dux. If not, see <https://www.gnu.org/licenses/>. +*/ + +template<::dux::arith T> constexpr auto ::dux::abs(T const _val) noexcept -> T { + if constexpr (::dux::isuint<T>) { + return _val; + } + else { + if (_val < T{0x0}) { + return -_val; + } + return _val; + } +} diff --git a/include/dux/algo.d/cpy.hh b/include/dux/algo.d/cpy.hh new file mode 100644 index 0000000..5e287c9 --- /dev/null +++ b/include/dux/algo.d/cpy.hh @@ -0,0 +1,22 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of dux. + + dux is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your + option) any later version. + + dux is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + License for more details. + + You should have received a copy of the GNU Affero General Public License + along with dux. If not, see <https://www.gnu.org/licenses/>. +*/ + +template<typename T> constexpr auto ::dux::cpy(T const * const _begin,T const * const _end,T * const _out) noexcept -> void { + ::dux::cpyn(_begin,static_cast<::dux::usz>(_end - _begin),_out); +} diff --git a/include/dux/algo.d/cpyn.hh b/include/dux/algo.d/cpyn.hh new file mode 100644 index 0000000..6049fab --- /dev/null +++ b/include/dux/algo.d/cpyn.hh @@ -0,0 +1,27 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of dux. + + dux is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your + option) any later version. + + dux is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + License for more details. + + You should have received a copy of the GNU Affero General Public License + along with dux. If not, see <https://www.gnu.org/licenses/>. +*/ + +template<typename T> constexpr auto ::dux::cpyn(T const * const dux_restr _in,::dux::usz const _num,T * const _out) noexcept -> void { + if (!_num) [[unlikely]] { + return; + } + for (auto pos = 0x0uz;pos < _num;pos += 0x1uz) { + _out[pos] = _in[pos]; + } +} diff --git a/include/dux/algo.d/fill.hh b/include/dux/algo.d/fill.hh new file mode 100644 index 0000000..d0a76b9 --- /dev/null +++ b/include/dux/algo.d/fill.hh @@ -0,0 +1,22 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of dux. + + dux is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your + option) any later version. + + dux is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + License for more details. + + You should have received a copy of the GNU Affero General Public License + along with dux. If not, see <https://www.gnu.org/licenses/>. +*/ + +template<typename T,typename T0> constexpr auto ::dux::fill(T * const _begin,T * const _end,T0 const _val) noexcept -> void { + ::dux::filln(_begin,static_cast<::dux::usz>(_end - _begin),_val); +} diff --git a/include/dux/algo.d/filln.hh b/include/dux/algo.d/filln.hh new file mode 100644 index 0000000..f2d6988 --- /dev/null +++ b/include/dux/algo.d/filln.hh @@ -0,0 +1,28 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of dux. + + dux is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your + option) any later version. + + dux is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + License for more details. + + You should have received a copy of the GNU Affero General Public License + along with dux. If not, see <https://www.gnu.org/licenses/>. +*/ + +template<typename T,typename T0> constexpr auto ::dux::filln(T * const dux_restr _in,::dux::usz const _num,T0 const _val) noexcept -> void { + if (!_num) [[unlikely]] { + return; + } + auto const val = static_cast<T>(_val); + for (auto pos = 0x0uz;pos < _num;pos += 0x1uz) { + _in[pos] = val; + } +} diff --git a/include/dux/algo.d/fma.hh b/include/dux/algo.d/fma.hh new file mode 100644 index 0000000..87a59e7 --- /dev/null +++ b/include/dux/algo.d/fma.hh @@ -0,0 +1,22 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of dux. + + dux is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your + option) any later version. + + dux is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + License for more details. + + You should have received a copy of the GNU Affero General Public License + along with dux. If not, see <https://www.gnu.org/licenses/>. +*/ + +template<::dux::arith T> constexpr auto ::dux::fma(T const _x,T const _y,T const _z) noexcept -> T { + return _x * _y + _z; +} diff --git a/include/dux/algo.d/ins.hh b/include/dux/algo.d/ins.hh new file mode 100644 index 0000000..6224951 --- /dev/null +++ b/include/dux/algo.d/ins.hh @@ -0,0 +1,22 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of dux. + + dux is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your + option) any later version. + + dux is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + License for more details. + + You should have received a copy of the GNU Affero General Public License + along with dux. If not, see <https://www.gnu.org/licenses/>. +*/ + +template<typename T> constexpr auto ::dux::ins(T const * const _begin,T const * const _end,T * const _out) noexcept -> void { + ::dux::insn(_begin,static_cast<::dux::usz>(_end - _begin),_out); +} diff --git a/include/dux/algo.d/insn.hh b/include/dux/algo.d/insn.hh new file mode 100644 index 0000000..59392d1 --- /dev/null +++ b/include/dux/algo.d/insn.hh @@ -0,0 +1,23 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of dux. + + dux is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your + option) any later version. + + dux is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + License for more details. + + You should have received a copy of the GNU Affero General Public License + along with dux. If not, see <https://www.gnu.org/licenses/>. +*/ + +template<typename T> constexpr auto ::dux::insn(T const * const _in,::dux::usz const _num,T * const _out) noexcept -> void { + ::dux::cpy(_out,_out + _num,_out + _num); + ::dux::cpy(_in,_in + _num,_out); +} diff --git a/include/dux/algo.d/isinf.hh b/include/dux/algo.d/isinf.hh new file mode 100644 index 0000000..e921cc8 --- /dev/null +++ b/include/dux/algo.d/isinf.hh @@ -0,0 +1,27 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of dux. + + dux is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your + option) any later version. + + dux is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + License for more details. + + You should have received a copy of the GNU Affero General Public License + along with dux. If not, see <https://www.gnu.org/licenses/>. +*/ + +#include <limits> /* ::std::numeric_limits */ + +template<::dux::arith T> constexpr auto ::dux::isinf(T const _val) noexcept -> bool { + if (::std::numeric_limits<T>::has_infinity) { + return _val == ::std::numeric_limits<T>::infinity(); + } + return false; +} diff --git a/include/dux/algo.d/isnan.hh b/include/dux/algo.d/isnan.hh new file mode 100644 index 0000000..26825e6 --- /dev/null +++ b/include/dux/algo.d/isnan.hh @@ -0,0 +1,22 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of dux. + + dux is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your + option) any later version. + + dux is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + License for more details. + + You should have received a copy of the GNU Affero General Public License + along with dux. If not, see <https://www.gnu.org/licenses/>. +*/ + +template<::dux::arith T> constexpr auto ::dux::isnan(T const _val) noexcept -> bool { + return _val != _val; +} diff --git a/include/dux/algo.d/isprime.hh b/include/dux/algo.d/isprime.hh new file mode 100644 index 0000000..a397f58 --- /dev/null +++ b/include/dux/algo.d/isprime.hh @@ -0,0 +1,30 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of dux. + + dux is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your + option) any later version. + + dux is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + License for more details. + + You should have received a copy of the GNU Affero General Public License + along with dux. If not, see <https://www.gnu.org/licenses/>. +*/ + +template<::dux::arith T> constexpr auto ::dux::isprime(T const _val) noexcept -> bool { + if (_val <= T{0x1}) [[unlikely]] { + return false; + } + for (T iter = T{0x2};iter < _val / T{0x2} + T{0x1};iter += T{0x1}) { + if (_val % iter == T{0x0}) [[unlikely]] { + return false; + } + } + return true; +} diff --git a/include/dux/algo.d/min.hh b/include/dux/algo.d/min.hh new file mode 100644 index 0000000..67fc52d --- /dev/null +++ b/include/dux/algo.d/min.hh @@ -0,0 +1,25 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of dux. + + dux is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your + option) any later version. + + dux is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + License for more details. + + You should have received a copy of the GNU Affero General Public License + along with dux. If not, see <https://www.gnu.org/licenses/>. +*/ + +template<typename T> constexpr auto ::dux::min(T const & _lval,T const & _rval) noexcept -> T const & { + if (_lval < _rval) { + return _lval; + } + return _rval; +} diff --git a/include/dux/algo.d/mv.hh b/include/dux/algo.d/mv.hh new file mode 100644 index 0000000..29fc766 --- /dev/null +++ b/include/dux/algo.d/mv.hh @@ -0,0 +1,22 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of dux. + + dux is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your + option) any later version. + + dux is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + License for more details. + + You should have received a copy of the GNU Affero General Public License + along with dux. If not, see <https://www.gnu.org/licenses/>. +*/ + +template<typename T> constexpr auto ::dux::mv(T * const _begin,T * const _end,T * const _out) noexcept -> void { + ::dux::mvn(_begin,static_cast<::dux::usz>(_end - _begin),_out); +} diff --git a/include/dux/algo.d/mvn.hh b/include/dux/algo.d/mvn.hh new file mode 100644 index 0000000..82a1753 --- /dev/null +++ b/include/dux/algo.d/mvn.hh @@ -0,0 +1,25 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of dux. + + dux is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your + option) any later version. + + dux is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + License for more details. + + You should have received a copy of the GNU Affero General Public License + along with dux. If not, see <https://www.gnu.org/licenses/>. +*/ + +template<typename T> constexpr auto ::dux::mvn(T * const _in,::dux::usz const _num,T * const _out) noexcept -> void { + for (auto pos = 0x0uz;pos < _num;pos += 0x1uz) { + _out[pos] = _in[pos]; + _in[pos] = T{}; + } +} diff --git a/include/dux/algo.d/pow.hh b/include/dux/algo.d/pow.hh new file mode 100644 index 0000000..58370b0 --- /dev/null +++ b/include/dux/algo.d/pow.hh @@ -0,0 +1,33 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of dux. + + dux is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your + option) any later version. + + dux is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + License for more details. + + You should have received a copy of the GNU Affero General Public License + along with dux. If not, see <https://www.gnu.org/licenses/>. +*/ + +template<::dux::arith T> constexpr auto ::dux::pow(T const _base,T const _exp) noexcept -> T { + //if constexpr (::std::is_floating_point_v<T>) { + //} + //else { + if (::dux::abs(_base) <= T{0x1}) [[unlikely]] { + return _base; + } + T res = _base; + for (T iter = T{0x1};iter < _exp;iter += T{0x1}) { + res *= _base; + } + return res; + //} +} diff --git a/include/dux/algo.d/renew.hh b/include/dux/algo.d/renew.hh new file mode 100644 index 0000000..681a337 --- /dev/null +++ b/include/dux/algo.d/renew.hh @@ -0,0 +1,25 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of dux. + + dux is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your + option) any later version. + + dux is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + License for more details. + + You should have received a copy of the GNU Affero General Public License + along with dux. If not, see <https://www.gnu.org/licenses/>. +*/ + +template<typename T> constexpr auto ::dux::renew(T * const dux_restr _ptr,::dux::usz const _sz,::dux::usz const _newsz) -> T * { + T * const dux_restr ptr = ::new T[_newsz](); + ::dux::cpyn(_ptr,::dux::min(_sz,_newsz),ptr); + ::delete[] _ptr; + return ptr; +} diff --git a/include/dux/algo.d/sqrt.hh b/include/dux/algo.d/sqrt.hh new file mode 100644 index 0000000..418d2c6 --- /dev/null +++ b/include/dux/algo.d/sqrt.hh @@ -0,0 +1,36 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of dux. + + dux is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your + option) any later version. + + dux is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + License for more details. + + You should have received a copy of the GNU Affero General Public License + along with dux. If not, see <https://www.gnu.org/licenses/>. +*/ + +#include <limits> /* ::std::numeric_limits */ + +template<::dux::arith T> constexpr auto ::dux::sqrt(T const _val) noexcept -> T { + if (_val < T{0x0}) [[unlikely]] { + return ::std::numeric_limits<T>::quiet_NaN(); + } + if (_val == T{0x0}) [[unlikely]] { + return _val; + } + /*constexpr auto err = []() { + if constexpr(::std::is_integral_v<T>) { + return T{0x1}; + } + return ::std::numeric_limits<T>::epsilon(); + }();*/ + return _val; +} diff --git a/include/dux/algo.hh b/include/dux/algo.hh new file mode 100644 index 0000000..b11f9a4 --- /dev/null +++ b/include/dux/algo.hh @@ -0,0 +1,68 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of dux. + + dux is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your + option) any later version. + + dux is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + License for more details. + + You should have received a copy of the GNU Affero General Public License + along with dux. If not, see <https://www.gnu.org/licenses/>. +*/ + +namespace dux { + template<::dux::arith T> [[dux_attr_const, nodiscard]] constexpr auto abs( T val) noexcept -> T; + template<typename T> [[dux_attr_hot]] constexpr auto cpy( T const * begin,T const * end, T * out) noexcept -> void; + template<typename T> [[dux_attr_hot]] constexpr auto cpyn( T const * in, ::dux::usz num, T * out) noexcept -> void; + template<typename T,typename T0> [[dux_attr_hot]] constexpr auto fill( T * begin,T * end, T0 val) noexcept -> void; + template<typename T,typename T0> [[dux_attr_hot]] constexpr auto filln( T * in, ::dux::usz num, T0 val) noexcept -> void; + template<::dux::arith T> [[dux_attr_const, nodiscard]] constexpr auto fma( T x, T y, T z) noexcept -> T; + template<typename T> [[dux_attr_hot]] constexpr auto ins( T const * begin,T const * end, T * out) noexcept -> void; + template<typename T> [[dux_attr_hot]] constexpr auto insn( T const * om, ::dux::usz num, T * out) noexcept -> void; + //template<::dux::arith T> [[dux_attr_const]] constexpr auto isinf( T val) noexcept -> bool; + template<::dux::arith T> [[dux_attr_const]] constexpr auto isnan( T val) noexcept -> bool; + template<::dux::arith T> [[dux_attr_const]] constexpr auto isprime(T val) noexcept -> bool; + template<typename T> [[dux_attr_const, nodiscard]] constexpr auto max( T const & lval, T const & rval) noexcept -> T const &; + template<typename T> [[dux_attr_const, nodiscard]] constexpr auto min( T const & lval, T const & rval) noexcept -> T const &; + template<typename T> [[dux_attr_hot]] constexpr auto mv( T * begin,T * end, T * out) noexcept -> void; + template<typename T> [[dux_attr_hot]] constexpr auto mvn( T * in, ::dux::usz num, T * out) noexcept -> void; + template<::dux::arith T> [[dux_attr_const]] constexpr auto pow( T base, T exp) noexcept -> T; + template<typename T> [[dux_attr_allocsz(0x3),dux_attr_hot,dux_attr_malloc,dux_attr_nonnull(0x1),nodiscard]] constexpr auto renew( T * ptr, ::dux::usz sz, ::dux::usz newsz) -> T *; + template<::dux::arith T> [[dux_attr_const]] constexpr auto sqrt( T val) noexcept -> T; + + /* Consteval alternatives for mathematical functions: */ + template<::dux::arith T> [[nodiscard]] consteval auto cabs( T _val) noexcept -> T {return ::dux::abs(_val);} + template<::dux::arith T> [[nodiscard]] consteval auto cfma( T _x, T _y, T _z) noexcept -> T {return ::dux::fma(_x,_y,_z);} + //template<::dux::arith T> consteval auto cisinf( T _val) noexcept -> bool {return ::dux::isinf(_val);} + template<::dux::arith T> consteval auto cisnan( T _val) noexcept -> bool {return ::dux::isnan(_val);} + template<::dux::arith T> consteval auto cisprime(T _val) noexcept -> bool {return ::dux::isprime(_val);} + template<typename T> [[nodiscard]] consteval auto cmax( T const & _lval, T const & _rval) noexcept -> T const & {return ::dux::max(_lval,_rval);} + template<typename T> [[nodiscard]] consteval auto cmin( T const & _lval, T const & _rval) noexcept -> T const & {return ::dux::min(_lval,_rval);} + template<::dux::arith T> [[nodiscard]] consteval auto cpow( T _base, T _exp) noexcept -> T {return ::dux::pow(_base,_exp);} + template<::dux::arith T> [[nodiscard]] consteval auto csqrt( T _val) noexcept -> T {return ::dux::sqrt(_val);} +} + +#include <dux/algo.d/abs.hh> +#include <dux/algo.d/cpy.hh> +#include <dux/algo.d/cpyn.hh> +#include <dux/algo.d/fill.hh> +#include <dux/algo.d/filln.hh> +#include <dux/algo.d/fma.hh> +#include <dux/algo.d/ins.hh> +#include <dux/algo.d/insn.hh> +//#include <dux/algo.d/isinf.hh> +#include <dux/algo.d/isnan.hh> +#include <dux/algo.d/isprime.hh> +#include <dux/algo.d/min.hh> +#include <dux/algo.d/mv.hh> +#include <dux/algo.d/mvn.hh> +#include <dux/algo.d/pow.hh> +#include <dux/algo.d/renew.hh> +#include <dux/algo.d/sqrt.hh> diff --git a/include/dux/arr b/include/dux/arr new file mode 100644 index 0000000..ce83ad7 --- /dev/null +++ b/include/dux/arr @@ -0,0 +1,26 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of dux. + + dux is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your + option) any later version. + + dux is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + License for more details. + + You should have received a copy of the GNU Affero General Public License + along with dux. If not, see <https://www.gnu.org/licenses/>. +*/ + +#if !defined(dux_hdr_arr) +#define dux_hdr_arr + +#include <dux/algo> +#include <dux/arr.hh> + +#endif diff --git a/include/dux/arr.d/arr.hh b/include/dux/arr.d/arr.hh new file mode 100644 index 0000000..4af5df3 --- /dev/null +++ b/include/dux/arr.d/arr.hh @@ -0,0 +1,217 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of dux. + + dux is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your + option) any later version. + + dux is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + License for more details. + + You should have received a copy of the GNU Affero General Public License + along with dux. If not, see <https://www.gnu.org/licenses/>. +*/ + +template<typename T> constexpr auto ::dux::arr<T>::alloc(::dux::usz const _num) -> void { + if (this->isstatic()) [[unlikely]] { + this->_isstatic = false; + } + else { + ::delete[] this->_ptr; + } + if (_num > 0x0uz) [[likely]] { + this->_ptr = ::new T[_num](); + } + this->_sz = _num; +} +template<typename T> template<::dux::cnvto<T> T0> constexpr auto ::dux::arr<T>::alloc(::dux::usz const _num,T0 const _val) -> void { + this->alloc(_num); + this->fill(this->begin(),this->end(),_val); +} +template<typename T> constexpr auto ::dux::arr<T>::app(::dux::arr<T> const & _oth) -> ::dux::arr<T> const & { + this->realloc(this->sz() + _oth.sz()); + ::dux::cpy(_oth.begin(),_oth.end(),this->begin() + this->sz() - _oth.sz()); + return *this; +} +template<typename T> template<::dux::cnvto<T> T0> constexpr auto ::dux::arr<T>::app(T0 const _val) -> ::dux::arr<T> const & { + this->realloc(this->sz() + 0x1uz); + (*this)[this->sz() - 0x1uz] = static_cast<T>(_val); + return *this; +} +template<typename T> constexpr ::dux::arr<T>::arr(T const * const _begin,T const * const _end) { + if constexpr (::dux::dbg) { + if (_begin == nullptr || _end == nullptr) [[unlikely]] { + throw ::dux::invalarg("Provided parameter has value of nullptr."); + } + } + this->alloc(static_cast<::dux::usz>(_end - _begin) + 0x1uz); + ::dux::cpy(_begin,_end,this->begin()); +} +template<typename T> constexpr ::dux::arr<T>::arr(::dux::usz const _num) { + this->alloc(_num); +} +template<typename T> constexpr ::dux::arr<T>::arr(::dux::arr<T> const & _oth) { + if (_oth.isstatic()) [[unlikely]] { + this->_isstatic = true; + this->_ptr = _oth.begin(); + this->_sz = _oth.sz(); + return; + } + this->alloc(_oth.sz()); + this->ins(_oth.begin(),_oth.end(),0x0uz); +} +template<typename T> constexpr ::dux::arr<T>::arr(::dux::arr<T> && _oth) { + this->_isstatic = _oth.isstatic(); + this->_ptr = _oth.begin(); + this->_sz = _oth.sz(); + _oth._ptr = nullptr; + _oth._sz = 0x0uz; +} +template<typename T> template<::dux::usz N> constexpr ::dux::arr<T>::arr(T const (&_arr)[N]) noexcept { + this->_isstatic = true; + this->_ptr = _arr; + this->_sz = N; +} +template<typename T> template<::dux::cnvto<T> T0> constexpr ::dux::arr<T>::arr(::dux::usz const _num,T0 const _val) { + this->alloc(_num,_val); +} +template<typename T> constexpr auto ::dux::arr<T>::begin() noexcept -> T * { + return this->_ptr; +} +template<typename T> constexpr auto ::dux::arr<T>::begin() const noexcept -> T const * { + return this->_ptr; +} +template<typename T> constexpr auto ::dux::arr<T>::cbegin() const noexcept -> T const * { + return this->begin(); +} +template<typename T> constexpr auto ::dux::arr<T>::cend() const noexcept -> T const * { + return this->begin() + this->sz; +} +template<typename T> constexpr auto ::dux::arr<T>::del(::dux::usz const _pos) -> void { + if constexpr (::dux::dbg) { + if (_pos >= this->sz()) [[unlikely]] { + throw ::dux::outofdomain("Position out of bounds!"); + } + } + if (this->sz() <= 0x1uz) [[unlikely]] { + if (this->sz() == 0x0uz) { + this->alloc(0x0uz); + return; + } + return; + } + ::dux::cpy(this->begin() + _pos + 0x1uz,this->end(),this->begin() + _pos); + this->realloc(this->sz() - 0x1uz); +} +template<typename T> constexpr auto ::dux::arr<T>::end() noexcept -> T * { + return this->begin() + this->sz(); +} +template<typename T> constexpr auto ::dux::arr<T>::end() const noexcept -> T const * { + return this->begin() + this->sz(); +} +template<typename T> template<::dux::cnvto<T> T0> constexpr auto ::dux::arr<T>::fill(T0 const _val) -> void { + this->fill(this->begin(),this->end(),_val); +} +template<typename T> template<::dux::cnvto<T> T0> constexpr auto ::dux::arr<T>::fill(T * const dux_restr _begin,T * const dux_restr _end,T0 const _val) -> void { + if (this->sz() == 0x0uz) [[unlikely]] { + return; /* slime incident */ + } + if constexpr (::dux::dbg) { + if (_begin < this->begin() || _end > this->end()) [[unlikely]] { + throw ::dux::outofdomain("Beginning or end are out of this array's range."); + } + } + if (this->isstatic()) [[unlikely]] { + this->alloc(static_cast<::dux::usz>(_end - _begin) + 0x1uz); + } + ::dux::fill(this->begin(),this->end(),_val); +} +template<typename T> constexpr auto ::dux::arr<T>::ins(T const * const _begin,T const * const _end,::dux::usz const _pos) -> ::dux::arr<T> const & { + this->realloc(this->sz() + static_cast<::dux::usz>(_end - _begin) + 0x1uz); + ::dux::ins(_begin,_end,this->begin() + _pos); + return *this; +} +template<typename T> constexpr auto ::dux::arr<T>::ins(::dux::arr<T> const & _oth,::dux::usz const _pos) -> ::dux::arr<T> const & { + return this->ins(_oth.begin(),_oth.end(),_pos); +} +template<typename T> constexpr auto ::dux::arr<T>::isstatic() const noexcept -> bool { + return this->_isstatic; +} +template<typename T> constexpr auto ::dux::arr<T>::operator = (::dux::arr<T> const & _oth) -> ::dux::arr<T> const & { + this->~arr(); + if (_oth.isstatic()) [[unlikely]] { + this->_isstatic = true; + this->_ptr = const_cast<T *>(_oth.begin()); + this->_sz = _oth.sz(); + } + else { + this->alloc(_oth.sz()); + this->ins(_oth.begin(),_oth.end(),0x0uz); + } + return *this; +} +template<typename T> constexpr auto ::dux::arr<T>::operator [] (::dux::usz const _pos) -> T & { + if constexpr (::dux::dbg) { + if (_pos >= this->sz()) [[unlikely]] { + throw ::dux::invalarg("Input parameter is out of range."); + } + } + return this->begin()[_pos]; +} +template<typename T> constexpr auto ::dux::arr<T>::operator [] (::dux::usz const _pos) const -> T const & { + if constexpr (::dux::dbg) { + if (_pos >= this->sz()) [[unlikely]] { + throw ::dux::invalarg("Input parameter is out of range."); + } + } + return this->begin()[_pos]; +} +template<typename T> constexpr auto ::dux::arr<T>::realloc(::dux::usz const _num) -> void { + if (this->sz() == 0x0uz) [[unlikely]] { + return this->alloc(_num); + } + if (this->isstatic()) [[unlikely]] { + this->_isstatic = false; + } + this->_ptr = ::dux::renew(this->begin(),this->sz(),_num); + this->_sz = _num; +} +template<typename T> constexpr auto ::dux::arr<T>::setraw(T const * const dux_restr _ptr,::dux::usz const _sz) noexcept -> void { + if (!this->isstatic()) [[unlikely]] { + ::delete[] this->_ptr; + } + this->_ptr = const_cast<T *>(_ptr); + this->_sz = _sz; +} +template<typename T> constexpr auto ::dux::arr<T>::sub(::dux::usz const _pos,::dux::usz const _sz) const -> ::dux::arr<T> { + auto const sz = [&]() { + if (_sz == 0x0uz) { + return this->sz() - _sz; + } + return _sz; + }(); + ::dux::arr<T> arr; + if (this->isstatic()) [[unlikely]] { + arr._sz = sz; + arr._ptr = const_cast<T *>(this->begin()) + _pos; + } + else { + arr.alloc(sz); + ::dux::cpyn(this->begin(),sz,arr.begin()); + } + return arr; +} +template<typename T> constexpr auto ::dux::arr<T>::sz() const noexcept -> ::dux::usz { + return this->_sz; +} +template<typename T> constexpr ::dux::arr<T>::~arr<T>() noexcept { + if (this->isstatic()) { + return; + } + ::delete[] this->_ptr; +} diff --git a/include/dux/arr.hh b/include/dux/arr.hh new file mode 100644 index 0000000..10822c2 --- /dev/null +++ b/include/dux/arr.hh @@ -0,0 +1,61 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of dux. + + dux is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your + option) any later version. + + dux is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + License for more details. + + You should have received a copy of the GNU Affero General Public License + along with dux. If not, see <https://www.gnu.org/licenses/>. +*/ + +namespace dux { + template<typename T> class arr { + public: + constexpr auto alloc( ::dux::usz num) -> void; + template<::dux::cnvto<T> T0> constexpr auto alloc( ::dux::usz num, T0 val) -> void; + constexpr auto app( ::dux::arr<T> const & oth) -> ::dux::arr<T> const &; + template<::dux::cnvto<T> T0> constexpr auto app( T0 val) -> ::dux::arr<T> const &; + [[nodiscard]] constexpr arr() noexcept = default; + [[nodiscard]] constexpr arr( T const * begin, T const * end); + [[nodiscard]] constexpr arr( ::dux::usz num); + [[nodiscard]] constexpr arr( ::dux::arr<T> const & oth); + [[nodiscard]] constexpr arr( ::dux::arr<T> && oth); + template<::dux::usz N> [[nodiscard]] constexpr arr( T const (& arr)[N]) noexcept; + template<::dux::cnvto<T> T0> [[nodiscard]] constexpr arr( ::dux::usz num, T0 val); + [[nodiscard]] constexpr auto begin() noexcept -> T *; + [[nodiscard]] constexpr auto begin() const noexcept -> T const *; + [[nodiscard]] constexpr auto cbegin() const noexcept -> T const *; + [[nodiscard]] constexpr auto cend() const noexcept -> T const *; + constexpr auto del( ::dux::usz pos) -> void; + [[nodiscard]] constexpr auto end() noexcept -> T *; + [[nodiscard]] constexpr auto end() const noexcept -> T const *; + template<::dux::cnvto<T> T0> constexpr auto fill( T0 val) -> void; + template<::dux::cnvto<T> T0> constexpr auto fill( T * begin, T * end,T0 val) -> void; + constexpr auto ins( ::dux::arr<T> const & oth, ::dux::usz pos) -> ::dux::arr<T> const &; + constexpr auto ins( T const * begin, T const * end,::dux::usz pos) -> ::dux::arr<T> const &; + [[nodiscard]] constexpr auto isstatic() const noexcept -> bool; + constexpr auto operator = ( ::dux::arr<T> const & oth) -> ::dux::arr<T> const &; + [[nodiscard]] constexpr auto operator [] (::dux::usz pos) -> T &; + [[nodiscard]] constexpr auto operator [] (::dux::usz pos) const -> T const &; + constexpr auto realloc( ::dux::usz num) -> void; + constexpr auto setraw( T const * ptr, ::dux::usz sz) noexcept -> void; + [[nodiscard]] constexpr auto sub( ::dux::usz pos, ::dux::usz sz) const -> ::dux::arr<T>; + [[nodiscard]] constexpr auto sz() const noexcept -> ::dux::usz; + constexpr ~arr() noexcept; + private: + bool _isstatic{false}; + T * _ptr {nullptr}; + ::dux::usz _sz {0x0uz}; + }; +} + +#include <dux/arr.d/arr.hh> diff --git a/include/dux/base b/include/dux/base new file mode 100644 index 0000000..bec2c6e --- /dev/null +++ b/include/dux/base @@ -0,0 +1,25 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of dux. + + dux is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your + option) any later version. + + dux is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + License for more details. + + You should have received a copy of the GNU Affero General Public License + along with dux. If not, see <https://www.gnu.org/licenses/>. +*/ + +#if !defined(dux_hdr_base) +#define dux_hdr_base + +#include <dux/base.hh> + +#endif diff --git a/include/dux/base.d/opt.hh b/include/dux/base.d/opt.hh new file mode 100644 index 0000000..e779233 --- /dev/null +++ b/include/dux/base.d/opt.hh @@ -0,0 +1,55 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of dux. + + dux is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your + option) any later version. + + dux is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + License for more details. + + You should have received a copy of the GNU Affero General Public License + along with dux. If not, see <https://www.gnu.org/licenses/>. +*/ + +template<typename T> constexpr auto ::dux::opt<T>::operator * () const -> T const & { + if (!*this) [[unlikely]] { + throw ::dux::badoptacs(); + } + return this->_val; +} +template<typename T> constexpr auto ::dux::opt<T>::operator -> () const -> T const * { + if (!*this) [[unlikely]] { + throw ::dux::badoptacs(); + } + return &**this; +} +template<typename T> constexpr auto ::dux::opt<T>::operator = (::dux::opt<T> const & _oth) -> ::dux::opt<T> const & { + if (!_oth) { + this->reset(); + return *this; + } + this->_has = true; + this->_val = *_oth; + return *this; +} +template<typename T> constexpr ::dux::opt<T>::opt(T const & _val) noexcept { + this->_has = true; + this->_val = _val; +} +template<typename T> constexpr ::dux::opt<T>::opt(::dux::opt<T> const & _oth) noexcept { + this->operator = (_oth); +} +template<typename T> constexpr auto ::dux::opt<T>::set(T const & _val) noexcept { + this->_val = _val; + this->_has = true; +} +template<typename T> constexpr auto ::dux::opt<T>::reset() noexcept -> void { + this->_has = false; + ::new (&this->_val) T; /* Placement new: used for "uninitialising" a variable (I think). */ +} diff --git a/include/dux/base.d/tup.hh b/include/dux/base.d/tup.hh new file mode 100644 index 0000000..432ff9c --- /dev/null +++ b/include/dux/base.d/tup.hh @@ -0,0 +1,43 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of dux. + + dux is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your + option) any later version. + + dux is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + License for more details. + + You should have received a copy of the GNU Affero General Public License + along with dux. If not, see <https://www.gnu.org/licenses/>. +*/ + +namespace dux { + template<typename Fn,typename... Ts,::dux::usz... N> [[nodiscard]] constexpr auto _tupapply(Fn && fn,::dux::tup<Ts...> const & tup,::dux::intseq<::dux::usz,N...>) -> decltype(auto); +} + +template<typename Fn,typename... Ts,::dux::usz... N> [[nodiscard]] constexpr auto ::dux::_tupapply(Fn && _fn,::dux::tup<Ts...> const & _tup,::dux::intseq<::dux::usz,N...>) -> decltype(auto) { + return _fn(_tup.template get<N>()...); +} +template<typename T,typename... Ts> template<typename Fn> constexpr auto ::dux::tup<T,Ts...>::apply(Fn const & _fn) const -> decltype(auto) { + return ::dux::_tupapply(_fn,*this,dux::mkintseq<::dux::usz,0x1uz + sizeof...(Ts)>{}); +} +template<typename T,typename... Ts> template<::dux::usz N> constexpr auto ::dux::tup<T,Ts...>::get() const noexcept -> auto { + return static_cast<::dux::_tupbase<N,typename ::dux::_tupgettyp<N,T,Ts...>::typ> const *>(this)->get(); +} +template<typename T,typename... Ts> template<typename T0,typename... Ts0> constexpr auto ::dux::tup<T,Ts...>::operator == (::dux::tup<T0,Ts0...> const & _oth) noexcept -> bool { + if constexpr (!::dux::issame<decltype(*this),decltype(_oth)>) { + return false; + } + else { + constexpr auto num{sizeof...(Ts)}; + if constexpr (num == 0x0uz) { + return true; + } + } +} diff --git a/include/dux/base.hh b/include/dux/base.hh new file mode 100644 index 0000000..32e4060 --- /dev/null +++ b/include/dux/base.hh @@ -0,0 +1,466 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of dux. + + dux is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your + option) any later version. + + dux is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + License for more details. + + You should have received a copy of the GNU Affero General Public License + along with dux. If not, see <https://www.gnu.org/licenses/>. +*/ + +/* + base > algo ─>┬> arr ─>┬> str > sys >┬> io + └> cstr >┘ ├> media + └> thrd +*/ + +#if defined(__clang__) +#define dux_cmp_clang +#endif +#if defined(__INTEL_COMPILER) +#define dux_cmp_icc +#endif +#if defined(_MSC_VER) +#define dux_cmp_msvc +#endif +#if defined(__GNUG__) && (!defined(dux_cmp_clang) || !defined(dux_cmp_icc)) +#define dux_cmp_gcc +#endif + +#if defined(__TOS_AIX__) || defined(_AIX) +#define dux_os_aix +#endif +#if defined(__amigaos__) +#define dux_os_amigaos +#endif +#if defined(__ANDROID__) +#define dux_os_android +#endif +#if defined(__THW_BLUEGENE__) || defined(__TOS_BGQ__) || defined(__bg__) || defined(__bgq__) +#define dux_os_bluegene +#endif +#if defined(__DragonFly__) +#define dux_os_dragonflybsd +#endif +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) +#define dux_os_freebsd +#endif +#if defined(__BEOS__) +#define dux_os_haiku +#endif +#if defined(__hpux) || defined(_hpux) +#define dux_os_hpux +#endif +#if defined(__GNU__) || defined(__gnu_hurd__) +#define dux_os_hurd +#endif +#if defined(__OS400__) || defined(__OS400_TGTVRM__) +#define dux_os_ibmi +#endif +#if defined(__INTEGRITY) +#define dux_os_integrity +#endif +#if defined(__APPLE__) || defined(__MACH__) +#define dux_os_mac +#endif +#if defined(__minix) +#define dux_os_minix +#endif +#if defined(__DOS__) || defined(__MSDOS__) || defined(_MSDOS) +#define dux_os_msdos +#endif +#if defined(__NetBSD__) +#define dux_os_netbsd +#endif +#if defined(__OpenBSD__) +#define dux_os_openbsd +#endif +#if defined(__OS2__) || defined(__TOS_OS2__) || defined(_OS2) +#define dux_os_os2 +#endif +#if defined(__sun) +#define dux_os_solaris +#endif +#if defined(__TOS_WIN__) || defined(__WIN32__) || defined(__WINDOWS__) || defined(_WIN16) || defined(_WIN32) || defined(_WIN32_CE) || defined(_WIN64) +#define dux_os_win +#endif +#if defined(__HOS_MVS__) || defined(__MVS__) || defined(__TOS_MVS__) +#define dux_os_zos +#endif +#if defined(_SYSTYPE_BSD) || defined(dux_os_dragonflybsd) || defined(dux_os_freebsd) || defined(dux_os_netbsd) || defined(dux_os_openbsd) +#define dux_os_bsd +#elif __has_include(<sys/param.h>) +#include <sys/param.h> +#if defined(BSD) +#define dux_os_bsd +#endif +#endif +#if defined(__linux__) || defined(dux_os_android) +#define dux_os_linux +#endif +#if defined(__unix) || defined(__unix__) || defined(dux_os_aix) || defined(dux_os_android)|| defined(dux_os_bsd) || defined(dux_os_hpux) || defined(dux_os_hurd) || defined(dux_os_linux) || defined(dux_os_mac) || defined(dux_os_minix) || defined(dux_os_solaris) +#define dux_os_posix +#elif __has_include(<unistd.h>) +#include <unistd.h> +#if defined(_POSIX_VERSION) +#define dux_os_posix +#endif +#endif + +#include <exception> /* This is the one STDLIB dependency which we cannot get rid of. By making our exception class ((::dux::except)) inherit from (::std::exception), we can get the exception message to be displayed on terminate. Luckily, this header is (in theory) small. */ + +#if defined(__has_builtin) +#define dux_hasbuiltin(builtin) __has_builtin(builtin) +#else +#define dux_hasbuiltin(builtin) false +#endif + +#if defined(dux_os_posix) /* POSIX requires the size of bytes (in bits) to be exactly 8. We can use this knowledge to decrease our STDLIB dependencies. */ +#define dux_bytesz 0x8u +#elif defined(dux_cmp_clang) || defined(dux_cmp_gcc) /* Nice! Clang and GCC define the (__CHAR_BIT) macro. */ +#define dux_bytesz __CHAR_BIT +#else /* :( */ +#include <climits> /* CHAR_BIT */ +#define dux_bytesz CHAR_BIT +#endif + +#if defined(dux_cmp_clang) || defined(dux_cmp_gcc) +#define dux_intmax __INT_MAX__ +#define dux_llongmax __LONG_LONG_MAX__ +#define dux_longmax __LONG_MAX__ +#define dux_shrtmax __SHRT_MAX__ +#else +#include <climits> +#define dux_intmax INT_MAX +#define dux_llongmax LLONG_MAX +#define dux_longmax LONG_MAX +#define dux_shrtmax SHRT_MAX +#endif + +#if defined(dux_cmp_clang) || defined(dux_cmp_gcc) || defined(dux_cmp_icc) +#define dux_attr_abitag( ...) gnu::abi_tag(__VA_ARGS__) +#define dux_attr_allocsz( ...) gnu::alloc_size(__VA_ARGS__) +#define dux_attr_artif gnu::artificial +#define dux_attr_cold gnu::cold +#define dux_attr_const gnu::const +#define dux_attr_fmt gnu::format +#define dux_attr_malloc gnu::malloc +#define dux_attr_nonnull( ...) gnu::nonnull(__VA_ARGS__) +#define dux_attr_hot gnu::hot +#define dux_attr_inline gnu::always_inline +#define dux_attr_pure gnu::pure +#define dux_attr_retnonnull gnu::returns_nonnull +#define dux_attr_sect( ...) gnu::section(__VA_ARGS__) +#else +#define dux_attr_abitag( ...) +#define dux_attr_allocsz( ...) +#define dux_attr_artif +#define dux_attr_cold +#define dux_attr_const +#define dux_attr_fmt +#define dux_attr_hot +#define dux_attr_inline +#define dux_attr_malloc +#define dux_attr_nonnull( ...) +#define dux_attr_pure +#define dux_attr_retnonnull +#define dux_attr_sect( ...) +#endif +#if defined(dux_cmp_clang) +#define dux_attr_noderef clang::noderef +#define dux_attr_noesc( ...) clang::noescape(__VA_ARGS__) +#else +#define dux_attr_noderef +#define dux_attr_noesc( ...) +#endif + +#if defined(dux_cmp_clang) || defined(dux_cmp_gcc) || defined(dux_cmp_icc) +#define dux_fnnm __PRETTY_FUNCTION__ +#elif defined(dux_cmp_msvc) +#define dux_fnnm __FUNCSIG__ +#else +#define dux_fnnm __func__ +#endif + + +#if defined(dux_cmp_clang) || defined(dux_cmp_gcc) +#define dux_restr __restrict__ +#elif defined(dux_cmp_icc) || defined(dux_cmp_msvc) +#define dux_restr __restrict +#else +#define dux_restr +#endif + +namespace dux { + using ubyte = unsigned char; + using sbyte = signed char; + template<typename T> consteval auto ubytev(T const & _val) noexcept {return static_cast<::dux::ubyte>(_val);} + template<typename T> consteval auto sbytev(T const & _val) noexcept {return static_cast<::dux::sbyte>(static_cast<::dux::ubyte>(_val));} /* We cast to the unsigned equivalent type first to avoid undefined behavoir, which will stop compilation, as we are in an immediate function. */ + + constexpr auto bytesz{static_cast<::dux::ubyte>(dux_bytesz)}; + + template<typename T,typename T0> struct _issame {constexpr static auto issame{false};}; + template<typename T> struct _issame<T,T> {constexpr static auto issame{true};}; + template<typename T,typename T0> constexpr auto issame{::dux::_issame<T,T0>::issame}; + + template<typename T> struct _remconst {using t = T;}; + template<typename T> struct _remconst<T const> {using t = T;}; + template<typename T> using remconst = typename ::dux::_remconst<T>::t; + + template<typename T> struct _remrestr {using t = T;}; + template<typename T> struct _remrestr<T * dux_restr> {using t = T *;}; + template<typename T> using remrestr = typename ::dux::_remrestr<T>::t; + + template<typename T> struct _remvolat {using t = T;}; + template<typename T> struct _remvolat<T volatile> {using t = T;}; + template<typename T> using remvolat = typename ::dux::_remvolat<T>::t; + + template<typename T> using remcr = typename ::dux::remrestr<::dux::remconst<T>>; + template<typename T> using remcrv = typename ::dux::remrestr<::dux::remvolat<::dux::remconst<T>>>; + template<typename T> using remcv = typename ::dux::remvolat<::dux::remconst<T>>; + template<typename T> using remvr = typename ::dux::remrestr<::dux::remvolat<T>>; + + using _flt128 = +#if defined(dux_cmp_clang) || defined(dux_cmp_gcc) + __float128; +#else + long double; +#endif + using _uint128 = +#if defined(dux_cmp_clang) || defined(dux_cmp_gcc) + unsigned __int128; +#else + unsigned long long; +#endif + using _sint128 = +#if defined(dux_cmp_clang) || defined(dux_cmp_gcc) + __int128; +#else + long long; +#endif + + template<typename T,typename T0> constexpr auto iscnvto = requires {static_cast<T>(T0{});}; + template<typename T,typename T0> concept cnvto = ::dux::iscnvto<T,T0>; + template<typename T> constexpr auto issint = ::dux::issame<T,::dux::_sint128> || ::dux::issame<T,int> || ::dux::issame<T,long> || ::dux::issame<T,long long> || ::dux::issame<T,short> || ::dux::issame<T,signed char>; + template<typename T> concept sint = ::dux::issint<T>; + template<typename T> constexpr auto isuint = ::dux::issame<T,::dux::_uint128> || ::dux::issame<T,unsigned> || ::dux::issame<T,unsigned char> || ::dux::issame<T,unsigned long> || ::dux::issame<T,unsigned long long> || ::dux::issame<T,unsigned short>; + template<typename T> concept uint = ::dux::isuint<T>; + template<typename T> constexpr auto ischr = ::dux::issame<T,char> || ::dux::issame<T,char16_t> || ::dux::issame<T,char32_t> || ::dux::issame<T,char8_t> || ::dux::issame<T,wchar_t>; + template<typename T> concept chr = ::dux::ischr<T>; + template<typename T> constexpr auto isflt = ::dux::issame<T,::dux::_flt128> || ::dux::issame<T,double> || ::dux::issame<T,float> || ::dux::issame<T,long double>; + template<typename T> concept flt = ::dux::isflt<T>; + template<typename T> constexpr auto isnullptrtyp = ::dux::issame<T,decltype(nullptr)>; + template<typename T> constexpr auto isutf = ::dux::issame<T,char16_t> || ::dux::issame<T,char32_t> || ::dux::issame<T,char8_t>; + template<typename T> concept utf = ::dux::isutf<T>; + template<typename T> constexpr auto isvoid = ::dux::issame<T,void>; + template<typename T> concept void_ = ::dux::isvoid<T>; + + template<typename T> struct _isptr {constexpr static auto isptr{false};}; + template<typename T> struct _isptr<T *> {constexpr static auto isptr{true};}; + template<typename T> constexpr auto isptr = ::dux::_isptr<T>::isptr; + + template<typename T> constexpr auto isint = ::dux::issame<T,char> || ::dux::issint<T> || ::dux::isuint<T>; + template<typename T> concept int_ = ::dux::isint<T>; + + template<typename T> constexpr auto isarith = ::dux::isflt<T> || ::dux::isint<T>; + template<typename T> concept arith = ::dux::isarith<T>; + + template<typename T> struct _sign {using t = T;}; + template<> struct _sign<char> {using t = signed char;}; + template<> struct _sign<unsigned> {using t = int;}; + template<> struct _sign<unsigned char> {using t = signed char;}; + template<> struct _sign<unsigned long> {using t = long;}; + template<> struct _sign<unsigned long long> {using t = long long;}; +#if defined(dux_cmp_clang) || defined(dux_cmp_gcc) + template<> struct _sign<unsigned __int128> {using t = __int128;}; +#endif + template<::dux::int_ T> using sign = typename ::dux::_sign<T>::t; + + template<typename T> struct _unsign {using t = T;}; + template<> struct _unsign<char> {using t = unsigned char;}; + template<> struct _unsign<int> {using t = unsigned;}; + template<> struct _unsign<long> {using t = unsigned long;}; + template<> struct _unsign<long long> {using t = unsigned long long;}; + template<> struct _unsign<signed char> {using t = unsigned char;}; +#if defined(dux_cmp_clang) || defined(dux_cmp_gcc) + template<> struct _unsign<__int128> {using t = unsigned __int128;}; +#endif + template<::dux::int_ T> using unsign = typename ::dux::_unsign<T>::t; + + using uint16 = +#if dux_bytesz >= 0x10u + unsigned char; +#else + unsigned short; +#endif + using uint32 = +#if dux_bytesz >= 0x20u + unsigned char; +#elif dux_shrtmax >= 0x7FFFFFFFu + unsigned short; +#elif dux_intmax >= 0x7FFFFFFFu + unsigned int; +#else + unsigned long; +#endif + using uint64 = +#if dux_bytesz >= 0x40u + unsigned char; +#elif dux_shrtmax >= 0x7FFFFFFFFFFFFFFFu + unsigned short; +#elif dux_intmax >= 0x7FFFFFFFFFFFFFFFu + unsigned int; +#elif dux_longmax >= 0x7FFFFFFFFFFFFFFFu + unsigned long; +#else + unsigned long long; +#endif + using sint16 = ::dux::sign<::dux::uint16>; + using sint32 = ::dux::sign<::dux::uint32>; + using sint64 = ::dux::sign<::dux::uint64>; + template<typename T> consteval auto uint16v(T const & _val) noexcept {return static_cast<::dux::uint16>(_val);} + template<typename T> consteval auto sint16v(T const & _val) noexcept {return static_cast<::dux::sint16>(static_cast<::dux::uint16>(_val));} + template<typename T> consteval auto uint32v(T const & _val) noexcept {return static_cast<::dux::uint32>(_val);} + template<typename T> consteval auto sint32v(T const & _val) noexcept {return static_cast<::dux::sint32>(static_cast<::dux::uint32>(_val));} + template<typename T> consteval auto uint64v(T const & _val) noexcept {return static_cast<::dux::uint64>(_val);} + template<typename T> consteval auto sint64v(T const & _val) noexcept {return static_cast<::dux::sint64>(static_cast<::dux::uint64>(_val));} + + using usz = decltype(0x0uz); + using ssz = decltype(0x0z); + + using nullptrtyp = decltype(nullptr); + + enum class endi : bool { + big = true, + little = false, + }; + + enum class stat : ::dux::ubyte { + err = ::dux::ubytev(0x1), + ok = ::dux::ubytev(0x0), + }; + + class except : public ::std::exception { + public: + [[nodiscard]] except() noexcept : _what("") {} + [[nodiscard]] except(char const * _what) noexcept : _what(_what) {} + virtual auto what() const noexcept -> char const * {return this->_what;} + private: + char const * const dux_restr _what; + }; + class badalloc : public ::dux::except { + public: + using ::dux::except::except; + }; + class badio : public ::dux::except { + public: + using ::dux::except::except; + }; + class badoptacs : public ::dux::except { + public: + using ::dux::except::except; + }; + class invalarg : public ::dux::except { + public: + using ::dux::except::except; + }; + class invalutf : public ::dux::except { + public: + using ::dux::except::except; + }; + class outofdomain : public ::dux::except { + public: + using ::dux::except::except; + }; + class runerr : public ::dux::except { + public: + using ::dux::except::except; + }; + + template<::dux::int_ T,T... Ints> class intseq { + public: + constexpr static auto sz{0x1uz + sizeof...(Ints)}; + }; + template<::dux::int_ T,T N> using mkintseq = +#if dux_hasbuiltin(__make_integer_seq) /* Clang has this builtin for this exact purpose. */ + __make_integer_seq<::dux::intseq,T,N>; +#elif dux_hasbuiltin(__integer_pack) + ::dux::intseq<__integer_pack(N)...>; +#else + ::dux::intseq<T,N>; +_Pragma("message \"Cannot implement (::dux::mkintseq)!\""); +#endif + + template<typename T> class opt { + public: + [[nodiscard]] constexpr auto operator * () const -> T const &; + [[nodiscard]] constexpr auto operator -> () const -> T const *; + constexpr auto operator = ( ::dux::opt<T> const & oth) -> ::dux::opt<T> const &; + [[nodiscard]] constexpr explicit operator bool () const noexcept {return this->_has;} + [[nodiscard]] constexpr opt() noexcept = default; + [[nodiscard]] constexpr opt( T const & val) noexcept; + [[nodiscard]] constexpr opt( ::dux::opt<T> const & oth) noexcept; + constexpr auto set( T const & val) noexcept; + constexpr auto reset() noexcept -> void; + private: + bool _has{false}; + T _val; + }; + + template<::dux::usz N,typename T> class _tupbase { + public: + [[nodiscard]] constexpr _tupbase() noexcept = default; + [[nodiscard]] constexpr _tupbase(T const & _val) noexcept {this->_val = _val;} + [[nodiscard]] constexpr auto get() const noexcept -> T const & {return this->_val;} + private: + T _val; + }; + template<::dux::usz N, typename... Ts> class _tuprecurbase {}; + template<::dux::usz N, typename T, typename... Ts> class _tuprecurbase<N,T,Ts...> : public ::dux::_tupbase<N,T>,public ::dux::_tuprecurbase<N + 0x1uz,Ts...> { + public: + [[nodiscard]] constexpr _tuprecurbase() noexcept = default; + template<typename T0,typename... Ts0> [[nodiscard]] constexpr _tuprecurbase(T0 const & _val,Ts0 const &... _vals) noexcept : ::dux::_tupbase<N,T0>(_val), ::dux::_tuprecurbase<N + 0x1uz,Ts...>(_vals...) {}; + }; + template<::dux::usz N,typename T,typename... Ts> class _tupgettyp { + public: + using typ = typename ::dux::_tupgettyp<N - 0x1uz,Ts...>::typ; + }; + template<typename T,typename... Ts> class _tupgettyp<0x0uz,T,Ts...> { + public: + using typ = T; + }; + template<typename T, typename... Ts> class tup : public ::dux::_tuprecurbase<0x0uz,T,Ts...> { + public: + template<typename Fn> [[nodiscard]] constexpr auto apply( Fn const & fn) const -> decltype(auto); + template<::dux::usz N> [[nodiscard]] constexpr auto get() const noexcept -> auto; + template<typename T0, typename... Ts0> [[nodiscard]] constexpr auto operator == (::dux::tup<T0,Ts0...> const & oth) noexcept -> bool; + [[nodiscard]] constexpr tup() noexcept = default; + [[nodiscard]] constexpr tup( T const & _val,Ts const &... _vals) noexcept : ::dux::_tuprecurbase<0x0uz,T,Ts...>(_val,_vals...) {} + + constexpr static auto sz{0x1uz + sizeof...(Ts)}; + }; + + constexpr auto dbg{[]() { +#if defined(NDEBUG) + return false; +#else + return true; +#endif + }()}; + constexpr auto lorem {U"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."}; + constexpr auto npos {-0x1uz}; + constexpr auto unimax{U'\U00010FFF'}; + constexpr auto ver {::dux::uint64v(0x1D)}; +} + +#include <dux/base.d/opt.hh> +#include <dux/base.d/tup.hh> diff --git a/include/dux/cstr b/include/dux/cstr new file mode 100644 index 0000000..2089c7c --- /dev/null +++ b/include/dux/cstr @@ -0,0 +1,26 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of dux. + + dux is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your + option) any later version. + + dux is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + License for more details. + + You should have received a copy of the GNU Affero General Public License + along with dux. If not, see <https://www.gnu.org/licenses/>. +*/ + +#if !defined(dux_hdr_cstr) +#define dux_hdr_cstr + +#include <dux/algo> +#include <dux/cstr.hh> + +#endif diff --git a/include/dux/cstr.d/cstrcmp.hh b/include/dux/cstr.d/cstrcmp.hh new file mode 100644 index 0000000..ad262dc --- /dev/null +++ b/include/dux/cstr.d/cstrcmp.hh @@ -0,0 +1,35 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of dux. + + dux is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your + option) any later version. + + dux is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + License for more details. + + You should have received a copy of the GNU Affero General Public License + along with dux. If not, see <https://www.gnu.org/licenses/>. +*/ + +constexpr auto ::dux::cstrcmp(char const * const dux_restr _lstr,char const * const dux_restr _rstr) noexcept -> ::dux::sbyte { + auto const maxn = ::dux::min(::dux::cstrlen(_lstr),::dux::cstrlen(_rstr)); + for (auto n = 0x0uz;n <= maxn;n += 0x1uz) { + auto const lchr = _lstr[n]; + auto const rchr = _rstr[n]; + if (lchr != rchr) [[unlikely]] { + if (lchr > rchr) { + return ::dux::sbytev(-0x1); + } + if (lchr < rchr) { + return ::dux::sbytev(0x1); + } + } + } + return ::dux::sbytev(0x0); +} diff --git a/include/dux/cstr.d/cstrcpy.hh b/include/dux/cstr.d/cstrcpy.hh new file mode 100644 index 0000000..a8e5f65 --- /dev/null +++ b/include/dux/cstr.d/cstrcpy.hh @@ -0,0 +1,27 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of dux. + + dux is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your + option) any later version. + + dux is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + License for more details. + + You should have received a copy of the GNU Affero General Public License + along with dux. If not, see <https://www.gnu.org/licenses/>. +*/ + +constexpr auto ::dux::cstrcpy(char * const dux_restr _dest,char const * const dux_restr _src) noexcept -> char * { + auto const sz = ::dux::cstrlen(_src); + if (sz == 0x0uz) [[unlikely]] { + return _dest; + } + ::dux::cpy(_src,_src + sz - 0x1uz,_dest); + return _dest; +} diff --git a/include/dux/cstr.d/cstrdup.hh b/include/dux/cstr.d/cstrdup.hh new file mode 100644 index 0000000..43ecc18 --- /dev/null +++ b/include/dux/cstr.d/cstrdup.hh @@ -0,0 +1,24 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of dux. + + dux is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your + option) any later version. + + dux is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + License for more details. + + You should have received a copy of the GNU Affero General Public License + along with dux. If not, see <https://www.gnu.org/licenses/>. +*/ + +constexpr auto ::dux::cstrdup(char const * const dux_restr _str1) -> char * { + auto const sz = ::dux::cstrlen(_str1); + auto * const dux_restr str = ::new char[sz]; + return ::dux::cstrcpy(str,_str1); +} diff --git a/include/dux/cstr.d/cstrlen.hh b/include/dux/cstr.d/cstrlen.hh new file mode 100644 index 0000000..b8c8e58 --- /dev/null +++ b/include/dux/cstr.d/cstrlen.hh @@ -0,0 +1,29 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of dux. + + dux is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your + option) any later version. + + dux is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + License for more details. + + You should have received a copy of the GNU Affero General Public License + along with dux. If not, see <https://www.gnu.org/licenses/>. +*/ + +constexpr auto ::dux::cstrlen(char const * const dux_restr _str) noexcept -> ::dux::usz { + auto sz = 0x0uz; + for (::dux::usz n = 0x0uz;;n += 0x1uz) { + if (_str[n] == '\u0000') [[unlikely]] { + break; + } + sz += 0x1uz; + } + return sz; +} diff --git a/include/dux/cstr.hh b/include/dux/cstr.hh new file mode 100644 index 0000000..7361f90 --- /dev/null +++ b/include/dux/cstr.hh @@ -0,0 +1,30 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of dux. + + dux is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your + option) any later version. + + dux is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + License for more details. + + You should have received a copy of the GNU Affero General Public License + along with dux. If not, see <https://www.gnu.org/licenses/>. +*/ + +namespace dux { + [[nodiscard]] constexpr auto cstrcmp(char const * lstr,char const * rstr) noexcept -> ::dux::sbyte; + [[nodiscard]] constexpr auto cstrcpy(char * dest,char const * src) noexcept -> char *; + [[nodiscard]] constexpr auto cstrdup(char const * str) -> char *; + [[nodiscard]] constexpr auto cstrlen(char const * str) noexcept -> ::dux::usz; +} + +#include <dux/cstr.d/cstrcmp.hh> +#include <dux/cstr.d/cstrcpy.hh> +#include <dux/cstr.d/cstrdup.hh> +#include <dux/cstr.d/cstrlen.hh> diff --git a/include/dux/io b/include/dux/io new file mode 100644 index 0000000..3c4413e --- /dev/null +++ b/include/dux/io @@ -0,0 +1,26 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of dux. + + dux is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your + option) any later version. + + dux is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + License for more details. + + You should have received a copy of the GNU Affero General Public License + along with dux. If not, see <https://www.gnu.org/licenses/>. +*/ + +#if !defined(dux_hdr_io) +#define dux_hdr_io + +#include <dux/sys> +#include <dux/io.hh> + +#endif diff --git a/include/dux/io.d/dbgprint.hh b/include/dux/io.d/dbgprint.hh new file mode 100644 index 0000000..3e9d0cd --- /dev/null +++ b/include/dux/io.d/dbgprint.hh @@ -0,0 +1,24 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of dux. + + dux is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your + option) any later version. + + dux is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + License for more details. + + You should have received a copy of the GNU Affero General Public License + along with dux. If not, see <https://www.gnu.org/licenses/>. +*/ + +template<typename... Ts> constexpr auto ::dux::dbgprint(::dux::str const & _str,Ts... _args) -> void { + if constexpr (::dux::dbg) { + ::dux::print(_str,_args...); + } +} diff --git a/include/dux/io.d/fmt.hh b/include/dux/io.d/fmt.hh new file mode 100644 index 0000000..bf907f7 --- /dev/null +++ b/include/dux/io.d/fmt.hh @@ -0,0 +1,45 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of dux. + + dux is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your + option) any later version. + + dux is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + License for more details. + + You should have received a copy of the GNU Affero General Public License + along with dux. If not, see <https://www.gnu.org/licenses/>. +*/ + +constexpr auto ::dux::fmt(::dux::str const & _str) -> ::dux::str { + if (auto const pos = _str.fnd(::dux::fmtchr);pos != ::dux::npos) { + throw ::dux::fmterr("Format-specifier '$' was found, but no object to be formatted was provided."); + } + return _str; +} +template<typename T> constexpr auto ::dux::fmt(::dux::str const & _str,T const _fmt) -> ::dux::str { + auto const pos = _str.fnd(::dux::fmtchr); + if (pos == ::dux::npos) { + throw ::dux::fmterr("Object to be formatted provided, but an equivalent format-specifier '$' was not found!"); + } + auto str = _str; + str.del(pos); + str.ins(pos,::dux::fmter(_fmt)); + return str; +} +template<typename T,typename... Ts> constexpr auto ::dux::fmt(::dux::str const & _str,T const _fmt,Ts... args) -> ::dux::str { + auto const pos = _str.fnd(::dux::fmtchr); + if (pos == ::dux::npos) { + throw ::dux::fmterr("Object to be formatted provided, but an equivalent format-specifier '$' was not found!"); + } + auto str = _str; + str.del(pos); + str.ins(pos,::dux::fmter(_fmt)); + return str + ::dux::fmt(_str.sub(pos + 0x1uz,0x0uz),args...); +} diff --git a/include/dux/io.d/fmter.hh b/include/dux/io.d/fmter.hh new file mode 100644 index 0000000..ef56ed1 --- /dev/null +++ b/include/dux/io.d/fmter.hh @@ -0,0 +1,98 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of dux. + + dux is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your + option) any later version. + + dux is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + License for more details. + + You should have received a copy of the GNU Affero General Public License + along with dux. If not, see <https://www.gnu.org/licenses/>. +*/ + +namespace dux::priv { + template<typename T> constexpr auto intfmter(T const _fmt) -> ::dux::str { + auto const fmt = [&]() { + if constexpr(::dux::isptr<T>) { + return (::dux::uint64)_fmt; + } + else { + return _fmt; + } + }(); + using T0 = decltype(fmt); + if constexpr (::dux::issint<T>) { + if (fmt < T0{0x0}) { + return ::dux::str(U'−') + ::dux::fmter(::dux::abs(fmt)); + } + } + if (fmt < ::dux::base) { + auto const nums = []() { + if (::dux::base == ::dux::ubytev(0xC)) { + return U"0123456789↊↋"; + } + return U"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + }(); + return nums[fmt]; + } + return ::dux::fmter(fmt / T0{::dux::base}) + ::dux::fmter(fmt % T0{::dux::base}); + } +} +template<> constexpr auto ::dux::fmter(bool const _fmt) -> ::dux::str { + if (_fmt) { + return U"true"; + } + return U"false"; +} +/*template<> constexpr auto ::dux::fmter(char16_t const * const dux_restr _fmt) -> ::dux::str { + return ::dux::str{_fmt}; +}*/ +template<> constexpr auto ::dux::fmter(char32_t const * const dux_restr _fmt) -> ::dux::str { + return ::dux::str{_fmt}; +} +template<> constexpr auto ::dux::fmter(char8_t const * const dux_restr _fmt) -> ::dux::str { + return ::dux::str{_fmt}; +} +template<> constexpr auto ::dux::fmter(int const _fmt) -> ::dux::str { + return ::dux::priv::intfmter(_fmt); +} +template<> constexpr auto ::dux::fmter(long const _fmt) -> ::dux::str { + return ::dux::priv::intfmter(_fmt); +} +template<> constexpr auto ::dux::fmter(long long const _fmt) -> ::dux::str { + return ::dux::priv::intfmter(_fmt); +} +template<> constexpr auto ::dux::fmter(short const _fmt) -> ::dux::str { + return ::dux::priv::intfmter(_fmt); +} +template<> constexpr auto ::dux::fmter(::dux::nullptrtyp) -> ::dux::str { + return U"nullptr"; +} +template<> constexpr auto ::dux::fmter(::dux::str const _fmt) -> ::dux::str { + return _fmt; +} +template<> constexpr auto ::dux::fmter(unsigned const _fmt) -> ::dux::str { + return ::dux::priv::intfmter(_fmt); +} +template<> constexpr auto ::dux::fmter(unsigned long const _fmt) -> ::dux::str { + return ::dux::priv::intfmter(_fmt); +} +template<> constexpr auto ::dux::fmter(unsigned long long const _fmt) -> ::dux::str { + return ::dux::priv::intfmter(_fmt); +} +template<> constexpr auto ::dux::fmter(unsigned short const _fmt) -> ::dux::str { + return ::dux::priv::intfmter(_fmt); +} +template<> constexpr auto ::dux::fmter(void const * const dux_restr _fmt) -> ::dux::str { + if (_fmt == nullptr) { + return ::dux::fmter(nullptr); + } + return ::dux::priv::intfmter(_fmt); +} diff --git a/include/dux/io.d/print.hh b/include/dux/io.d/print.hh new file mode 100644 index 0000000..3833583 --- /dev/null +++ b/include/dux/io.d/print.hh @@ -0,0 +1,30 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of dux. + + dux is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your + option) any later version. + + dux is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + License for more details. + + You should have received a copy of the GNU Affero General Public License + along with dux. If not, see <https://www.gnu.org/licenses/>. +*/ + +#include <cstdio> + +template<typename... Ts> constexpr auto ::dux::print(::dux::str const & _str,Ts... _args) -> void { + auto const str = ::dux::fmt(_str,_args...); + if (str.len() == 0x0uz) [[unlikely]] { + throw ::dux::invalarg("Too many format options!"); + } + if (::std::fwrite(str.u8().begin(),0x1uz,str.len(),stdout) < str.len()) { + throw ::dux::runerr("Unable to write to stout!"); + } +} diff --git a/include/dux/io.hh b/include/dux/io.hh new file mode 100644 index 0000000..b431cc6 --- /dev/null +++ b/include/dux/io.hh @@ -0,0 +1,44 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of dux. + + dux is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your + option) any later version. + + dux is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + License for more details. + + You should have received a copy of the GNU Affero General Public License + along with dux. If not, see <https://www.gnu.org/licenses/>. +*/ + +/* + to-do: + Implement a prettier (and larger) API for I/O operations! +*/ + +namespace dux { + class fmterr : public ::dux::except { + public: + using ::dux::except::except; + }; + + template<typename... Ts> constexpr auto dbgprint(::dux::str const & str,Ts... args) -> void; + constexpr auto fmt( ::dux::str const & str) -> ::dux::str; + template<typename T> constexpr auto fmt( ::dux::str const & str,T fmt) -> ::dux::str; + template<typename T,typename... Ts> constexpr auto fmt( ::dux::str const & str,T fmt, Ts... args) -> ::dux::str; + template<typename T> constexpr auto fmter( T fmt) -> ::dux::str; + template<typename... Ts> constexpr auto print( ::dux::str const & str,Ts... args) -> void; + inline auto base {::dux::ubytev(0xC)}; + constexpr auto fmtchr{U'\u0024'}; +} + +#include <dux/io.d/dbgprint.hh> +#include <dux/io.d/fmt.hh> +#include <dux/io.d/fmter.hh> +#include <dux/io.d/print.hh> diff --git a/include/dux/media b/include/dux/media new file mode 100644 index 0000000..bd00493 --- /dev/null +++ b/include/dux/media @@ -0,0 +1,27 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of dux. + + dux is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your + option) any later version. + + dux is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + License for more details. + + You should have received a copy of the GNU Affero General Public License + along with dux. If not, see <https://www.gnu.org/licenses/>. +*/ + +#if !defined(dux_hdr_media) +#define dux_hdr_media + +#include <dux/sys> + +#include <dux/media.hh> + +#endif diff --git a/include/dux/media.hh b/include/dux/media.hh new file mode 100644 index 0000000..70c748e --- /dev/null +++ b/include/dux/media.hh @@ -0,0 +1,54 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of dux. + + dux is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your + option) any later version. + + dux is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + License for more details. + + You should have received a copy of the GNU Affero General Public License + along with dux. If not, see <https://www.gnu.org/licenses/>. +*/ + +namespace dux { + enum class evttyp : ::dux::ubyte { + kbd, + mus, + quit, + resz, + unknwn, + }; + + class evt { + public: + ::dux::evttyp typ{::dux::evttyp::unknwn}; + }; + + class win { + public: + auto close() -> void; + auto mv( ::dux::uint16 x, ::dux::uint16 y) -> void; + [[nodiscard]] static auto crt( char const * nm,::dux::uint16 w,::dux::uint16 h) -> ::dux::win; + auto destr() noexcept -> void; + auto open() -> void; + auto renm( char const * nm) -> void; + auto resz( ::dux::uint16 w, ::dux::uint16 h) -> void; + auto pollevt() noexcept -> ::dux::opt<::dux::evt>; + [[nodiscard]] win(); + [[nodiscard]] win( ::dux::win const & oth); + ~win() noexcept; + private: + void * const dux_restr _dat; + bool _isopen{false}; + }; + + auto endgfx() -> void; + auto initgfx() -> void; +} diff --git a/include/dux/str b/include/dux/str new file mode 100644 index 0000000..57856e7 --- /dev/null +++ b/include/dux/str @@ -0,0 +1,28 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of dux. + + dux is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your + option) any later version. + + dux is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + License for more details. + + You should have received a copy of the GNU Affero General Public License + along with dux. If not, see <https://www.gnu.org/licenses/>. +*/ + +#if !defined(dux_hdr_str) +#define dux_hdr_str + +#include <dux/arr> +#include <dux/cstr> + +#include <dux/str.hh> + +#endif diff --git a/include/dux/str.d/cnv.hh b/include/dux/str.d/cnv.hh new file mode 100644 index 0000000..13c9d1a --- /dev/null +++ b/include/dux/str.d/cnv.hh @@ -0,0 +1,105 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of dux. + + dux is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your + option) any later version. + + dux is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + License for more details. + + You should have received a copy of the GNU Affero General Public License + along with dux. If not, see <https://www.gnu.org/licenses/>. +*/ + +template<::dux::utf T,::dux::utf T0> constexpr auto ::dux::cnv(T0 const * const dux_restr _begin,T0 const * const dux_restr _end) -> ::dux::arr<T> { + if (_begin == nullptr || _end == nullptr) [[unlikely]] { + throw ::dux::invalarg("Null pointer provided as parameter."); + } + ::dux::arr<T0> in(_begin,_end); + ::dux::arr<T> out; + if constexpr (::dux::issame<T0,T>) { + out.alloc(static_cast<::dux::usz>(_end - _begin)); + ::dux::cpy(_begin,_end,out.begin()); + return out; + } + else { + if constexpr (::dux::issame<T0,char16_t>) { + } + else if constexpr (::dux::issame<T0,char32_t>) { + for (auto const tmp : in) { + if constexpr (::dux::issame<T,char16_t>) { + if (tmp >= ::dux::uint32v(0x10000)) { /* Two hextets. */ + char16_t const tmp0 = tmp - ::dux::uint16v(0x10000); + out.app((tmp0 / ::dux::uint16v(0x400) + ::dux::uint16v(0xD800))); + out.app((tmp0 % ::dux::uint16v(0x400) + ::dux::uint16v(0xDC00))); + } + else [[likely]] { + /* One hextet. */ + out.app((static_cast<char16_t>(tmp))); + } + } + else { + if (tmp >= ::dux::uint32v(0x10000)) { /* Four octets. */ + out.app((::dux::ubytev(0b11110000) + static_cast<char8_t>(tmp >> ::dux::uint32v(0x12) & ::dux::uint32v(0b00000111)))); + out.app((::dux::ubytev(0b10000000) + static_cast<char8_t>(tmp >> ::dux::uint32v(0xC) & ::dux::uint32v(0b00111111)))); + out.app((::dux::ubytev(0b10000000) + static_cast<char8_t>(tmp >> ::dux::uint32v(0x6) & ::dux::uint32v(0b00111111)))); + out.app((::dux::ubytev(0b10000000) + static_cast<char8_t>(tmp & ::dux::uint32v(0b00111111)))); + } + else if (tmp >= U'\u0800') { /* Three octets. */ + out.app((::dux::ubytev(0xE0) + static_cast<char8_t>(tmp >> ::dux::uint32v(0xC) & ::dux::uint32v(0b00001111)))); + out.app((::dux::ubytev(0x80) + static_cast<char8_t>(tmp >> ::dux::uint32v(0x6) & ::dux::uint32v(0b00111111)))); + out.app((::dux::ubytev(0x80) + static_cast<char8_t>(tmp & ::dux::uint32v(0b00111111)))); + } + else if (tmp >= U'\u0080') { /* Two octets. */ + out.app((::dux::ubytev(0xC0) + static_cast<char8_t>(tmp >> ::dux::uint32v(0x6) & ::dux::uint32v(0b00111111)))); + out.app((::dux::ubytev(0x80) + static_cast<char8_t>(tmp & ::dux::uint32v(0b00111111)))); + } + else [[likely]] { + /* One octet. */ + out.app(static_cast<char8_t>(tmp)); + } + } + } + } + else { + if constexpr (::dux::issame<T,char16_t>) { + } + else { + for (::dux::usz n = 0x0uz;n < in.sz();n += 0x1uz) { + auto const tmp = in[n]; + auto chr = U'\u0000'; + if (tmp >= ::dux::ubytev(0b11110000)) { /* Four octets. */ + chr = (tmp ^ ::dux::uint32v(0b11110000)) << ::dux::uint32v(0x12); + chr += (in[n + 0x1uz] ^ ::dux::uint32v(0b10000000)) << ::dux::uint32v(0xC); + chr += (in[n + 0x2uz] ^ ::dux::uint32v(0b10000000)) << ::dux::uint32v(0x6); + chr += in[n + 0x3uz] ^ ::dux::uint32v(0b10000000); + n += 0x3uz; + } + else if (tmp >= ::dux::ubytev(0b11100000)) { /* Three octets. */ + chr = (tmp ^ ::dux::uint32v(0b11100000)) << ::dux::uint32v(0xC); + chr += (in[n + 0x1uz] ^ ::dux::uint32v(0b10000000)) << ::dux::uint32v(0x6); + chr += in[n + 0x2uz] ^ ::dux::uint32v(0b10000000); + n += 0x2uz; + } + else if (tmp >= ::dux::ubytev(0b11000000)) { /* Two octets. */ + chr = (tmp ^ ::dux::uint32v(0b11000000)) << ::dux::uint32v(0x6); + chr += in[n + 0x1uz] ^ ::dux::uint32v(0b10000000); + n += 0x1uz; + } + else [[likely]] { + /* One octet. */ + chr = tmp; + } + out.app(chr); + } + } + } + } + return out; +} diff --git a/include/dux/str.d/isalnum.hh b/include/dux/str.d/isalnum.hh new file mode 100644 index 0000000..e7cc7aa --- /dev/null +++ b/include/dux/str.d/isalnum.hh @@ -0,0 +1,183 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of dux. + + dux is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your + option) any later version. + + dux is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + License for more details. + + You should have received a copy of the GNU Affero General Public License + along with dux. If not, see <https://www.gnu.org/licenses/>. +*/ + +constexpr auto ::dux::isalpha(char32_t const _chr) -> bool { + if(_chr > ::dux::unimax) [[unlikely]] { + throw ::dux::outofdomain("Unicode codepoint too big!"); + } + if(::dux::islower(_chr) || ::dux::isupper(_chr)) [[unlikely]] { + return true; + } + switch(_chr) { + [[likely]] default: + return false; + case U'\u0297': /* LATIN LETTER GLOTTAL STOP */ + [[fallthrough]]; + case U'\u16A0': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16A1': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16A2': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16A3': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16A4': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16A5': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16A6': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16A7': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16A8': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16A9': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16AA': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16AB': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16AC': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16AD': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16AE': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16AF': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16B0': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16B1': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16B2': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16B3': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16B4': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16B5': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16B6': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16B7': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16B8': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16B9': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16BA': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16BB': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16BC': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16BD': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16BE': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16BF': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16C0': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16C1': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16C2': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16C3': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16C4': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16C5': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16C6': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16C7': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16C8': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16C9': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16CA': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16CB': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16CC': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16CD': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16CE': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16CF': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16D0': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16D1': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16D2': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16D3': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16D4': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16D5': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16D6': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16D7': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16D8': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16D9': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16DA': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16DB': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16DC': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16DD': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16DE': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16DF': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16E0': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16E1': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16E2': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16E3': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16E4': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16E5': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16E6': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16E7': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16E8': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16E9': /* RUNIC LETTER FEHU FEOH FE F */ + [[fallthrough]]; + case U'\u16EA': /* RUNIC LETTER FEHU FEOH FE F */ + return true; + } +} diff --git a/include/dux/str.d/isalpha.hh b/include/dux/str.d/isalpha.hh new file mode 100644 index 0000000..49b5de6 --- /dev/null +++ b/include/dux/str.d/isalpha.hh @@ -0,0 +1,22 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of dux. + + dux is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your + option) any later version. + + dux is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + License for more details. + + You should have received a copy of the GNU Affero General Public License + along with dux. If not, see <https://www.gnu.org/licenses/>. +*/ + +constexpr auto ::dux::isalnum(char32_t const _chr) -> bool { + return ::dux::isalpha(_chr) || ::dux::isdigit(_chr); +} diff --git a/include/dux/str.d/iscntrl.hh b/include/dux/str.d/iscntrl.hh new file mode 100644 index 0000000..f3e9cfb --- /dev/null +++ b/include/dux/str.d/iscntrl.hh @@ -0,0 +1,173 @@ +// --C++-- +/* + Copyright 2021 Gabriel Jensen + + This file is part of dux. + + dux is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your + option) any later version. + + dux is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + License for more details. + + You should have received a copy of the GNU Affero General Public License + along with dux. If not, see <https://www.gnu.org/licenses/>. +*/ + +constexpr auto ::dux::iscntrl(char32_t const _chr) -> bool { + if(_chr > ::dux::unimax) [[unlikely]] { + throw ::dux::outofdomain("Unicode codepoint too big!"); + } + switch(_chr) { + [[likely]] default: + return false; + case U'\u0000': /* NULL */ + [[fallthrough]]; + case U'\u0001': /* START OF HEADING */ + [[fallthrough]]; + case U'\u0002': /* START OF TEXT */ + [[fallthrough]]; + case U'\u0003': /* END OF TEXT */ + [[fallthrough]]; + case U'\u0004': /* END OF TRANSMISSION */ + [[fallthrough]]; + case U'\u0005': /* ENQUIRY */ + [[fallthrough]]; + case U'\u0006': /* ACKNOWLEDGE */ + [[fallthrough]]; + case U'\a': /* BELL */ + [[fallthrough]]; + case U'\b': /* BACKSPACE */ + [[fallthrough]]; + case U'\t': /* HORIZONTAL TABULATION */ + [[fallthrough]]; + case U'\n': /* NEW LINE */ + [[fallthrough]]; + case U'\v': /* VERTICAL TABULATION */ + [[fallthrough]]; + case U'\f': /* FORM FEED */ + [[fallthrough]]; + case U'\r': /* CARRIAGE RETURN */ + [[fallthrough]]; + case U'\u000E': /* SHIFT OUT */ + [[fallthrough]]; + case U'\u000F': /* SHIFT IN */ + [[fallthrough]]; + case U'\x10': /* DATA LINK ESCAPE */ + [[fallthrough]]; + case U'\x11': /* DEVICE CONTROL ONE */ + [[fallthrough]]; + case U'\x12': /* DEVICE CONTROL TWO */ + [[fallthrough]]; + case U'\x13': /* DEVICE CONTROL THREE */ + [[fallthrough]]; + case U'\x14': /* DEVICE CONTROL FOUR */ + [[fallthrough]]; + case U'\x15': /* NEGATIVE ACKNOWLEDGE */ + [[fallthrough]]; + case U'\x16': /* SYNCHRONOUS IDLE */ + [[fallthrough]]; + case U'\x17': /* END OF TRANSMISSION BLOCK */ + [[fallthrough]]; + case U'\x18': /* CANCEL */ + [[fallthrough]]; + case U'\x19': /* END OF MEDIUM */ + [[fallthrough]]; + case U'\x1A': /* SUBSTITUTE */ + [[fallthrough]]; + case U'\u001B': /* ESCAPE */ + [[fallthrough]]; + case U'\x1C': /* FILE SEPERATOR */ + [[fallthrough]]; + case U'\x1D': /* GROUP SEPERATOR */ + [[fallthrough]]; + case U'\x1E': /* RECORD SEPERATOR */ + [[fallthrough]]; + case U'\x1F': /* UNIT SEPERATOR */ + [[fallthrough]]; + case U'\x7F': /* DELETE */ + [[fallthrough]]; + case U'\x80': /* <CONTROL> */ + [[fallthrough]]; + case U'\x81': /* <CONTROL */ + [[fallthrough]]; + case U'\x82': /* BREAK PERMITTED HERE */ + [[fallthrough]]; + case U'\x83': /* NO BREAK HERE */ + [[fallthrough]]; + case U'\x84': /* INDEX */ + [[fallthrough]]; + case U'\x85': /* NEXT LINE */ + [[fallthrough]]; + case U'\x86': /* START OF SELECTED AREA */ + [[fallthrough]]; + case U'\x87': /* END OF SELECTED AREA */ + [[fallthrough]]; + case U'\x88': /* CHARACTER TABULATION SET */ + [[fallthrough]]; + case U'\x89': /* CHARACTER TABULATION SET WITH JUSTIFICATION */ + [[fallthrough]]; + case U'\x8A': /* LINE TABULATION SET */ + [[fallthrough]]; + case U'\x8B': /* PARTIAL LINE FORWARD */ + [[fallthrough]]; + case U'\x8C': /* PARTIAL LINE BACKWARD */ + [[fallthrough]]; + case U'\x8D': /* REVERSE LINE FEED */ + [[fallthrough]]; + case U'\x8E': /* SINGLE SHIFT TWO */ + [[fallthrough]]; + case U'\x8F': /* SINGLE SHIFT THREE */ + [[fallthrough]]; + case U'\x90': /* DEVICE CONTROL STRING */ + [[fallthrough]]; + case U'\x91': /* PRIVATE USE ONE */ + [[fallthrough]]; + case U'\x92': /* PRIVATE USE TWO */ + [[fallthrough]]; + case U'\x93': /* SET TRANSMIT STATE */ + [[fallthrough]]; + case U'\x94': /* CANCEL CHARACTER */ + [[fallthrough]]; + case U'\x95': /* MESSAGE WAITING */ + [[fallthrough]]; + case U'\x96': /* START OF GUARDED AREA */ + [[fallthrough]]; + case U'\x97': /* END OF GUARDED AREA */ + [[fallthrough]]; + case U'\x98': /* START OF STRING */ + [[fallthrough]]; + case U'\x99': /* <CONTROL> */ + [[fallthrough]]; + case U'\x9A': /* SINGLE CHARACTER INTRODUCER */ + [[fallthrough]]; + case U'\x9B': /* CONTROL SEQUENCE INTRODUCER */ + [[fallthrough]]; + case U'\x9C': /* STRING TERMINATOR */ + [[fallthrough]]; + case U'\x9D': /* OPERATING SYSTEM COMMAND */ + [[fallthrough]]; + case U'\x9E': /* PRIVACY MESSAGE */ + [[fallthrough]]; + case U'\x9F': /* APPLICATION PROGRAM COMMAND */ + [[fallthrough]]; + case U'\xA0': /* NO-BREAK SPACE */ + [[fallthrough]]; + case U'\u2028': /* LINE SEPERATOR */ + [[fallthrough]]; + case U'\u2029': /* PARAGRAPH SEPERATOR */ + [[fallthrough]]; + case U'\u202D': /* LEFT-TO-RIGHT OVERRIDE */ + [[fallthrough]]; + case U'\u202E': /* RIGHT-TO-LEFT OVERRIDE */ + [[fallthrough]]; + case U'\u2068': /* FIRST STRONG ISOLATE */ + [[fallthrough]]; + case U'\u2069': /* POP DIRECTIONAL ISOLATE */ + return true; + } +} diff --git a/include/dux/str.d/isdigit.hh b/include/dux/str.d/isdigit.hh new file mode 100644 index 0000000..52f5bd4 --- /dev/null +++ b/include/dux/str.d/isdigit.hh @@ -0,0 +1,52 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of dux. + + dux is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your + option) any later version. + + dux is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + License for more details. + + You should have received a copy of the GNU Affero General Public License + along with dux. If not, see <https://www.gnu.org/licenses/>. +*/ + +constexpr auto ::dux::isdigit(char32_t const _chr) -> bool { + if(_chr > ::dux::unimax) [[unlikely]] { + throw ::dux::outofdomain("Unicode codepoint too big!"); + } + switch(_chr) { + [[likely]] default: + return false; + case U'\u0030': /* DIGIT ZERO */ + [[fallthrough]]; + case U'\u0031': /* DIGIT ONE */ + [[fallthrough]]; + case U'\u0032': /* DIGIT TWO */ + [[fallthrough]]; + case U'\u0033': /* DIGIT THREE */ + [[fallthrough]]; + case U'\u0034': /* DIGIT FOUR */ + [[fallthrough]]; + case U'\u0035': /* DIGIT FIVE */ + [[fallthrough]]; + case U'\u0036': /* DIGIT SIX */ + [[fallthrough]]; + case U'\u0037': /* DIGIT SEVEN */ + [[fallthrough]]; + case U'\u0038': /* DIGIT EIGHT */ + [[fallthrough]]; + case U'\u0039': /* DIGIT NINE */ + [[fallthrough]]; + case U'\u218A': /* TURNED DIGIT TWO */ + [[fallthrough]]; + case U'\u218B': /* TURNED DIGIT THREE */ + return true; + } +} diff --git a/include/dux/str.d/islower.hh b/include/dux/str.d/islower.hh new file mode 100644 index 0000000..0800573 --- /dev/null +++ b/include/dux/str.d/islower.hh @@ -0,0 +1,338 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of dux. + + dux is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your + option) any later version. + + dux is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + License for more details. + + You should have received a copy of the GNU Affero General Public License + along with dux. If not, see <https://www.gnu.org/licenses/>. +*/ + +constexpr auto ::dux::islower(char32_t const _chr) -> bool { + if(_chr > ::dux::unimax) [[unlikely]] { + throw ::dux::outofdomain("Unicode codepoint too big!"); + } + switch(_chr) { + [[likely]] default: + return false; + case U'\u0061': /* LATIN SMALL LETTER A */ + [[fallthrough]]; + case U'\u0062': /* LATIN SMALL LETTER B */ + [[fallthrough]]; + case U'\u0063': /* LATIN SMALL LETTER C */ + [[fallthrough]]; + case U'\u0064': /* LATIN SMALL LETTER D */ + [[fallthrough]]; + case U'\u0065': /* LATIN SMALL LETTER E */ + [[fallthrough]]; + case U'\u0066': /* LATIN SMALL LETTER F */ + [[fallthrough]]; + case U'\u0067': /* LATIN SMALL LETTER G */ + [[fallthrough]]; + case U'\u0068': /* LATIN SMALL LETTER H */ + [[fallthrough]]; + case U'\u0069': /* LATIN SMALL LETTER I */ + [[fallthrough]]; + case U'\u006A': /* LATIN SMALL LETTER J */ + [[fallthrough]]; + case U'\u006B': /* LATIN SMALL LETTER K */ + [[fallthrough]]; + case U'\u006C': /* LATIN SMALL LETTER L */ + [[fallthrough]]; + case U'\u006D': /* LATIN SMALL LETTER M */ + [[fallthrough]]; + case U'\u006E': /* LATIN SMALL LETTER N */ + [[fallthrough]]; + case U'\u006F': /* LATIN SMALL LETTER O */ + [[fallthrough]]; + case U'\u0070': /* LATIN SMALL LETTER P */ + [[fallthrough]]; + case U'\u0071': /* LATIN SMALL LETTER Q */ + [[fallthrough]]; + case U'\u0072': /* LATIN SMALL LETTER R */ + [[fallthrough]]; + case U'\u0073': /* LATIN SMALL LETTER S */ + [[fallthrough]]; + case U'\u0074': /* LATIN SMALL LETTER T */ + [[fallthrough]]; + case U'\u0075': /* LATIN SMALL LETTER U */ + [[fallthrough]]; + case U'\u0076': /* LATIN SMALL LETTER V */ + [[fallthrough]]; + case U'\u0077': /* LATIN SMALL LETTER W */ + [[fallthrough]]; + case U'\u0078': /* LATIN SMALL LETTER X */ + [[fallthrough]]; + case U'\u0079': /* LATIN SMALL LETTER Y */ + [[fallthrough]]; + case U'\u007A': /* LATIN SMALL LETTER Z */ + [[fallthrough]]; + case U'\u00DF': /* LATIN SMALL LETTER SHARP S */ + [[fallthrough]]; + case U'\u00E0': /* LATIN SMALL LETTER A WITH GRAVE */ + [[fallthrough]]; + case U'\u00E1': /* LATIN SMALL LETTER A WITH ACUTE */ + [[fallthrough]]; + case U'\u00E2': /* LATIN SMALL LETTER A WITH CIRCUMFLEX */ + [[fallthrough]]; + case U'\u00E3': /* LATIN SMALL LETTER A WITH TILDE */ + [[fallthrough]]; + case U'\u00E4': /* LATIN SMALL LETTER A WITH DIAERESIS */ + [[fallthrough]]; + case U'\u00E5': /* LATIN SMALL LETTER A WITH RING ABOVE */ + [[fallthrough]]; + case U'\u00E6': /* LATIN SMALL LETTER AE */ + [[fallthrough]]; + case U'\u00E7': /* LATIN SMALL LETTER C WITH CEDILLA */ + [[fallthrough]]; + case U'\u00E8': /* LATIN SMALL LETTER E WITH GRAVE */ + [[fallthrough]]; + case U'\u00E9': /* LATIN SMALL LETTER E WITH ACUTE */ + [[fallthrough]]; + case U'\u00EA': /* LATIN SMALL LETTER E WITH CIRCUMFLEX */ + [[fallthrough]]; + case U'\u00EB': /* LATIN SMALL LETTER E WITH DIAERESIS */ + [[fallthrough]]; + case U'\u00EC': /* LATIN SMALL LETTER I WITH GRAVE */ + [[fallthrough]]; + case U'\u00ED': /* LATIN SMALL LETTER I WITH ACUTE */ + [[fallthrough]]; + case U'\u00EE': /* LATIN SMALL LETTER I WITH CIRCUMFLEX */ + [[fallthrough]]; + case U'\u00EF': /* LATIN SMALL LETTER I WITH DIAERESIS */ + [[fallthrough]]; + case U'\u00F0': /* LATIN SMALL LETTER ETH */ + [[fallthrough]]; + case U'\u00F1': /* LATIN SMALL LETTER N WITH TILDE */ + [[fallthrough]]; + case U'\u00F2': /* LATIN SMALL LETTER O WITH GRAVE */ + [[fallthrough]]; + case U'\u00F3': /* LATIN SMALL LETTER O WITH ACUTE */ + [[fallthrough]]; + case U'\u00F4': /* LATIN SMALL LETTER O WITH CIRCUMFLEX */ + [[fallthrough]]; + case U'\u00F5': /* LATIN SMALL LETTER O WITH TILDE */ + [[fallthrough]]; + case U'\u00F6': /* LATIN SMALL LETTER O WITH DIAERESIS */ + [[fallthrough]]; + case U'\u00F8': /* LATIN SMALL LETTER O WITH STROKE */ + [[fallthrough]]; + case U'\u00F9': /* LATIN SMALL LETTER U WITH GRAVE */ + [[fallthrough]]; + case U'\u00FA': /* LATIN SMALL LETTER U WITH ACUTE */ + [[fallthrough]]; + case U'\u00FB': /* LATIN SMALL LETTER U WITH CIRCUMFLEX */ + [[fallthrough]]; + case U'\u00FC': /* U WITH TWO DOTS */ + [[fallthrough]]; + case U'\u00FD': /* LATIN SMALL LETTER Y WITH ACUTE */ + [[fallthrough]]; + case U'\u00FE': /* LATIN SMALL LETTER THORN */ + [[fallthrough]]; + case U'\u00FF': /* LATIN SMALL LETTER Y WITH DIAERESIS */ + [[fallthrough]]; + case U'\u0105': /* LATIN SMALL LETTER A WITH OGONEK */ + [[fallthrough]]; + case U'\u0107': /* LATIN SMALL LETTER C WITH ACUTE */ + [[fallthrough]]; + case U'\u010D': /* LATIN SMALL LETTER C WITH CARON */ + [[fallthrough]]; + case U'\u010F': /* LATIN SMALL LETTER D WITH CARON */ + [[fallthrough]]; + case U'\u0119': /* LATIN SMALL LETTER E WITH OGONEK */ + [[fallthrough]]; + case U'\u011B': /* LATIN SMALL LETTER E WITH CARON */ + [[fallthrough]]; + case U'\u011F': /* LATIN SMALL LETTER G WITH BREVE */ + [[fallthrough]]; + case U'\u0131': /* LATIN SMALL LETTER DOTLESS I */ + [[fallthrough]]; + case U'\u0133': /* LATIN SMALL LIGATURE IJ */ + [[fallthrough]]; + case U'\u0138': /* LATIN SMALL LETTER KRA */ + [[fallthrough]]; + case U'\u0142': /* LATIN SMALL LETTER L WITH STROKE */ + [[fallthrough]]; + case U'\u0144': /* LATIN SMALL LETTER N WITH ACUTE */ + [[fallthrough]]; + case U'\u0148': /* LATIN SMALL LETTER N WITH CARON */ + [[fallthrough]]; + case U'\u014B': /* LATIN SMALL LETTER ENG */ + [[fallthrough]]; + case U'\u0153': /* LATIN SMALL LIGATURE OE */ + [[fallthrough]]; + case U'\u0159': /* LATIN SMALL LETTER R WITH CARON */ + [[fallthrough]]; + case U'\u015B': /* LATIN SMALL LETTER S WITH ACUTE */ + [[fallthrough]]; + case U'\u015F': /* LATIN SMALL LETTER S WITH CEDILLA */ + [[fallthrough]]; + case U'\u0161': /* LATIN SMALL LETTER S WITH CARON */ + [[fallthrough]]; + case U'\u0165': /* LATIN SMALL LETTER T WITH CARON */ + [[fallthrough]]; + case U'\u016F': /* LATIN SMALL LETTER U WITH RING ABOVE */ + [[fallthrough]]; + case U'\u017A': /* LATIN SMALL LETTER Z WITH ACUTE */ + [[fallthrough]]; + case U'\u017C': /* LATIN SMALL LETTER Z WITH DOT ABOVE */ + [[fallthrough]]; + case U'\u017E': /* LATIN SMALL LETTER Z WITH CARON */ + [[fallthrough]]; + case U'\u01BF': /* LATIN LETTER WYNN */ + [[fallthrough]]; + case U'\u01DD': /* LATIN SMALL LETTER TURNED E */ + [[fallthrough]]; + case U'\u021D': /* LATIN SMALL LETTER YOGH */ + [[fallthrough]]; + case U'\u0242': /* LATIN SMALL LETTER GLOTTAL STOP */ + [[fallthrough]]; + case U'\u0250': /* LATIN SMALL LETTER TURNED A */ + [[fallthrough]]; + case U'\u0251': /* LATIN SMALL LETTER ALPHA */ + [[fallthrough]]; + case U'\u0252': /* LATIN SMALL LETTER TURNED ALPHA */ + [[fallthrough]]; + case U'\u0253': /* LATIN SMALL LETTER B WITH HOOk */ + [[fallthrough]]; + case U'\u0254': /* LATIN SMALL LETTER OPEN O */ + [[fallthrough]]; + case U'\u0255': /* LATIN SMALL LETTER C WITH CURL */ + [[fallthrough]]; + case U'\u0256': /* LATIN SMALL LETTER D WITH TAIL */ + [[fallthrough]]; + case U'\u0257': /* LATIN SMALL LETTER D WITH HOOk */ + [[fallthrough]]; + case U'\u0258': /* LATIN SMALL LETTER REVERSED E */ + [[fallthrough]]; + case U'\u0259': /* LATIN SMALL LETTER SCHWA */ + [[fallthrough]]; + case U'\u025A': /* LATIN SMALL LETTER SCHWA WITH HOOK */ + [[fallthrough]]; + case U'\u025B': /* LATIN SMALL LETTER OPEN E */ + [[fallthrough]]; + case U'\u025C': /* LATIN SMALL LETTER REVERSED OPEN E */ + [[fallthrough]]; + case U'\u025D': /* LATIN SMALL LETTER REVERSED OPEN E WITH HOOK */ + [[fallthrough]]; + case U'\u025E': /* LATIN SMALL LETTER CLOSED REVERSED OPEN E */ + [[fallthrough]]; + case U'\u025F': /* LATIN SMALL LETTER DOTLESS J WITH STROKE */ + [[fallthrough]]; + case U'\u0260': /* LATIN SMALL LETTER G WITH HOOK */ + [[fallthrough]]; + case U'\u0261': /* LATIN SMALL LETTER SCRIPT G */ + [[fallthrough]]; + case U'\u0262': /* LATIN LETTER SMALL CAPITAL G */ + [[fallthrough]]; + case U'\u0263': /* LATIN SMALL LETTER GAMMA */ + [[fallthrough]]; + case U'\u0264': /* LATIN SMALL LETTER RAMS HORN */ + [[fallthrough]]; + case U'\u0265': /* LATIN SMALL LETTER TURNED H */ + [[fallthrough]]; + case U'\u0266': /* LATIN SMALL LETTER H WITH HOOK */ + [[fallthrough]]; + case U'\u0267': /* LATIN SMALL LETTER HENG WITH HOOK */ + [[fallthrough]]; + case U'\u0268': /* LATIN SMALL LETTER I WITH STROKE */ + [[fallthrough]]; + case U'\u0269': /* LATIN SMALL LETTER IOTA */ + [[fallthrough]]; + case U'\u026A': /* LATIN LETTER SMALL CAPITAL I */ + [[fallthrough]]; + case U'\u026B': /* LATIN SMALL LETTER L WITH MIDDLE TILDE */ + [[fallthrough]]; + case U'\u026C': /* LATIN SMALL LETTER L WITH BELT */ + [[fallthrough]]; + case U'\u026D': /* LATIN SMALL LETTER L WITH RETROFLEX HOOK */ + [[fallthrough]]; + case U'\u026E': /* LATIN SMALL LETTER LEZH */ + [[fallthrough]]; + case U'\u026F': /* LATIN SMALL LETTER TURNED M */ + [[fallthrough]]; + case U'\u0270': /* LATIN SMALL LETTER TURNED M WITH LONG LEG */ + [[fallthrough]]; + case U'\u0271': /* LATIN SMALL LETTER M WITH HOOK */ + [[fallthrough]]; + case U'\u0272': /* LATIN SMALL LETTER N WITH LEFT HOOK */ + [[fallthrough]]; + case U'\u0273': /* LATIN SMALL LETTER N WITH RETROFLEX HOOK */ + [[fallthrough]]; + case U'\u0283': /* LATIN SMALL LETTER ESH */ + [[fallthrough]]; + case U'\u028A': /* LATIN SMALL LETTER UPSILON */ + [[fallthrough]]; + case U'\u028B': /* LATIN SMALL LETTER V WITH HOOK */ + [[fallthrough]]; + case U'\u0292': /* LATIN SMALL LETTER EZH */ + [[fallthrough]]; + case U'\u0294': /* LATIN SMALL LETTER GLOTTAL STOP */ + [[fallthrough]]; + case U'\u03B1': /* GREEK SMALL LETTER ALPHA */ + [[fallthrough]]; + case U'\u03B2': /* GREEK SMALL LETTER BETA */ + [[fallthrough]]; + case U'\u03B3': /* GREEK SMALL LETTER GAMMA */ + [[fallthrough]]; + case U'\u03B4': /* GREEK SMALL LETTER DELTA */ + [[fallthrough]]; + case U'\u03B5': /* GREEK SMALL LETTER EPSILON */ + [[fallthrough]]; + case U'\u03B6': /* GREEK SMALL LETTER ZETA */ + [[fallthrough]]; + case U'\u03B7': /* GREEK SMALL LETTER ETA */ + [[fallthrough]]; + case U'\u03B8': /* GREEK SMALL LETTER THETA */ + [[fallthrough]]; + case U'\u03B9': /* GREEK SMALL LETTER IOTA */ + [[fallthrough]]; + case U'\u03BA': /* GREEK SMALL LETTER KAPPA */ + [[fallthrough]]; + case U'\u03BB': /* GREEK SMALL LETTER LAMBDA */ + [[fallthrough]]; + case U'\u03BC': /* GREEK SMALL LETTER MU */ + [[fallthrough]]; + case U'\u03BD': /* GREEK SMALL LETTER NU */ + [[fallthrough]]; + case U'\u03BE': /* GREEK SMALL LETTER XI */ + [[fallthrough]]; + case U'\u03BF': /* GREEK SMALL LETTER OMICRON */ + [[fallthrough]]; + case U'\u03C0': /* GREEK SMALL LETTER PI */ + [[fallthrough]]; + case U'\u03C1': /* GREEK SMALL LETTER RHO */ + [[fallthrough]]; + case U'\u03C2': /* GREEK SMALL LETTER FINAL SIGMA */ + [[fallthrough]]; + case U'\u03C3': /* GREEK SMALL LETTER SIGMA */ + [[fallthrough]]; + case U'\u03C4': /* GREEK SMALL LETTER TAU */ + [[fallthrough]]; + case U'\u03C5': /* GREEK SMALL LETTER UPSILON */ + [[fallthrough]]; + case U'\u03C6': /* GREEK SMALL LETTER PHI */ + [[fallthrough]]; + case U'\u03C7': /* GREEK SMALL LETTER CHI */ + [[fallthrough]]; + case U'\u03C8': /* GREEK SMALL LETTER PSI */ + [[fallthrough]]; + case U'\u03C9': /* GREEK SMALL LETTER OMEGA */ + [[fallthrough]]; + case U'\u1D79': /* LATIN SMALL LETTER INSULAR G */ + [[fallthrough]]; + case U'\uA7B7': /* LATIN SMALL LETTER OMEGA */ + [[fallthrough]]; + case U'\uFB00': /* LATIN SMALL LIGATURE FF */ + return true; + } +} diff --git a/include/dux/str.d/ispunct.hh b/include/dux/str.d/ispunct.hh new file mode 100644 index 0000000..bfa0ceb --- /dev/null +++ b/include/dux/str.d/ispunct.hh @@ -0,0 +1,322 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of dux. + + dux is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your + option) any later version. + + dux is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + License for more details. + + You should have received a copy of the GNU Affero General Public License + along with dux. If not, see <https://www.gnu.org/licenses/>. +*/ + +constexpr auto ::dux::ispunct(char32_t const _chr) -> bool { + if(_chr > ::dux::unimax) [[unlikely]] { + throw ::dux::outofdomain("Unicode codepoint too big!"); + } + switch(_chr) { + [[likely]] default: + return false; + case U'\u0021': /* EXCLAMATION MARK */ + [[fallthrough]]; + case U'\u0022': /* QUOTATION MARK */ + [[fallthrough]]; + case U'\u0023': /* NUMBER SIGN */ + [[fallthrough]]; + case U'\u0024': /* DOLLAR SIGN */ + [[fallthrough]]; + case U'\u0025': /* PERCENT SIGN */ + [[fallthrough]]; + case U'\u0026': /* AMPERSAND */ + [[fallthrough]]; + case U'\u0027': /* APOSTROPHE */ + [[fallthrough]]; + case U'\u0028': /* LEFT PARANTHESIS */ + [[fallthrough]]; + case U'\u0029': /* RIGHT PARANTHESIS */ + [[fallthrough]]; + case U'\u002A': /* ASTERISK */ + [[fallthrough]]; + case U'\u002B': /* PLUS SIGN */ + [[fallthrough]]; + case U'\u002C': /* COMMA */ + [[fallthrough]]; + case U'\u002D': /* HYPHEN-MINUS */ + [[fallthrough]]; + case U'\u002E': /* FULL STOP */ + [[fallthrough]]; + case U'\u002F': /* SOLIDUS */ + [[fallthrough]]; + case U'\u003A': /* COLON */ + [[fallthrough]]; + case U'\u003B': /* SEMICOLON */ + [[fallthrough]]; + case U'\u003C': /* LESS-THAN SIGN */ + [[fallthrough]]; + case U'\u003D': /* EQUALS SIGN */ + [[fallthrough]]; + case U'\u003E': /* GREATER-THAN SIGN */ + [[fallthrough]]; + case U'\u003F': /* QUESTION MARK */ + [[fallthrough]]; + case U'\u0040': /* COMMERCIAL AT */ + [[fallthrough]]; + case U'\u005B': /* LEFT SQUARE BRACKET */ + [[fallthrough]]; + case U'\u005C': /* REVERSE SOLIDUS */ + [[fallthrough]]; + case U'\u005D': /* RIGHT SQUARE BRACKET */ + [[fallthrough]]; + case U'\u005E': /* CIRCUMFLEX ACCENT */ + [[fallthrough]]; + case U'\u005F': /* LOW LINE */ + [[fallthrough]]; + case U'\u0060': /* GRAVE ACCENT */ + [[fallthrough]]; + case U'\u007B': /* LEFT CURLY BRACKET */ + [[fallthrough]]; + case U'\u007C': /* VERTICAL LINE */ + [[fallthrough]]; + case U'\u007D': /* RIGHT CURLY BRACKET */ + [[fallthrough]]; + case U'\u007E': /* TILDE */ + [[fallthrough]]; + case U'\u00A1': /* INVERT EXCLAMATION MARK */ + [[fallthrough]]; + case U'\u00A2': /* CENT SIGN */ + [[fallthrough]]; + case U'\u00A3': /* POUND SIGN */ + [[fallthrough]]; + case U'\u00A4': /* CURRENCY SIGN */ + [[fallthrough]]; + case U'\u00A5': /* YEN SIGN */ + [[fallthrough]]; + case U'\u00A6': /* BROKEN BAR */ + [[fallthrough]]; + case U'\u00A7': /* SECTION SIGN */ + [[fallthrough]]; + case U'\u00A8': /* DIAERESIS */ + [[fallthrough]]; + case U'\u00A9': /* COPYRIGHT SIGN */ + [[fallthrough]]; + case U'\u00AA': /* FEMININE ORDINAL INDICATOR */ + [[fallthrough]]; + case U'\u00AB': /* LEFT-POINTING DOUBLE ANGLE QUOTATION MARK */ + [[fallthrough]]; + case U'\u00AC': /* NOT SIGN */ + [[fallthrough]]; + case U'\u00AE': /* REGISTERED SIGN */ + [[fallthrough]]; + case U'\u00AF': /* MACRON */ + [[fallthrough]]; + case U'\u00B0': /* DEGREE SIGN */ + [[fallthrough]]; + case U'\u00B1': /* PLUS MINUS SYMBOL */ + [[fallthrough]]; + case U'\u00B2': /* SUPERSCRIPT TWO */ + [[fallthrough]]; + case U'\u00B3': /* SUPERSCRIPT THREE */ + [[fallthrough]]; + case U'\u00B4': /* ACUTE ACCENT */ + [[fallthrough]]; + case U'\u00B5': /* MICRO SIGN */ + [[fallthrough]]; + case U'\u00B6': /* PILCROW SIGN */ + [[fallthrough]]; + case U'\u00B7': /* MIDDLE DOT */ + [[fallthrough]]; + case U'\u00B8': /* CEDILLA */ + [[fallthrough]]; + case U'\u00B9': /* SUPERSCRIPT ONE */ + [[fallthrough]]; + case U'\u00BA': /* MASCULINE ORDINAL INDICATOR */ + [[fallthrough]]; + case U'\u00BB': /* RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK */ + [[fallthrough]]; + case U'\u00BC': /* VULGAR FRACTION ONE QUARTER */ + [[fallthrough]]; + case U'\u00BD': /* VULGAR FRACTION ONE HALF */ + [[fallthrough]]; + case U'\u00BE': /* VULGAR FRACTION THREE QUARTERS */ + [[fallthrough]]; + case U'\u00BF': /* INVERT QUESTION MARK */ + [[fallthrough]]; + case U'\u00D7': /* MULTIPLICATION SIGN */ + [[fallthrough]]; + case U'\u00F7': /* DIVISION SIGN */ + [[fallthrough]]; + case U'\u2010': /* HYPHEN */ + [[fallthrough]]; + case U'\u2013': /* EN DASH */ + [[fallthrough]]; + case U'\u2014': /* EM DASH */ + [[fallthrough]]; + case U'\u2018': /* LEFT SINGLE QUOTATION MARK */ + [[fallthrough]]; + case U'\u2019': /* RIGHT SINGLE QUOTATION MARK */ + [[fallthrough]]; + case U'\u201C': /* LEFT DOUBLE QUOTATION MARK */ + [[fallthrough]]; + case U'\u201D': /* RIGHT DOUBLE QUOTATION MARK */ + [[fallthrough]]; + case U'\u2026': /* HORIZONTAL ELLIPSIS */ + [[fallthrough]]; + case U'\u2030': /* PER MILLE SIGN */ + [[fallthrough]]; + case U'\u2031': /* PER TEN THOUSAND SIGN */ + [[fallthrough]]; + case U'\u2032': /* PRIME */ + [[fallthrough]]; + case U'\u2033': /* DOUBLE PRIME */ + [[fallthrough]]; + case U'\u2034': /* TRIPLE PRIME */ + [[fallthrough]]; + case U'\u2035': /* REVERSED PRIME */ + [[fallthrough]]; + case U'\u2036': /* REVERSED DOUBLE PRIME */ + [[fallthrough]]; + case U'\u2037': /* REVERSED TRIPLE PRIME */ + [[fallthrough]]; + case U'\u203C': /* DOUBLE EXCLAMATION MARK */ + [[fallthrough]]; + case U'\u203D': /* INTERROBANG */ + [[fallthrough]]; + case U'\u2047': /* DOUBLE QUOTATION MARK */ + [[fallthrough]]; + case U'\u2048': /* QUESTION EXCLAMATION MARK */ + [[fallthrough]]; + case U'\u2049': /* EXCLAMATION QUESTION MARK */ + [[fallthrough]]; + case U'\u20A3': /* FRENCH FRANC SIGN */ + [[fallthrough]]; + case U'\u20A4': /* LIRA SIGN */ + [[fallthrough]]; + case U'\u20A8': /* RUPEE SIGN */ + [[fallthrough]]; + case U'\u20A9': /* WON SIGN */ + [[fallthrough]]; + case U'\u20AC': /* EURO SIGN */ + [[fallthrough]]; + case U'\u20B9': /* INDIAN RUPEE SIGN */ + [[fallthrough]]; + case U'\u20BF': /* BITCOIN SIGN */ + [[fallthrough]]; + case U'\u2103': /* DEGREE CELSIUS */ + [[fallthrough]]; + case U'\u2107': /* EULER CONSTANT */ + [[fallthrough]]; + case U'\u2109': /* DEGREE FAHRENHEIT */ + [[fallthrough]]; + case U'\u210E': /* PLANCK CONSTANT */ + [[fallthrough]]; + case U'\u2117': /* SOUND RECORDING COPYRIGHT */ + [[fallthrough]]; + case U'\u2122': /* TRADE MARK SIGN */ + [[fallthrough]]; + case U'\u2125': /* OUNCE SIGN */ + [[fallthrough]]; + case U'\u2126': /* OHM SIGN */ + [[fallthrough]]; + case U'\u212A': /* KELVIN SIGN */ + [[fallthrough]]; + case U'\u214D': /* AKTIESELSKAB */ + [[fallthrough]]; + case U'\u2205': /* EMPTY SET */ + [[fallthrough]]; + case U'\u2212': /* MINUS SIGN */ + [[fallthrough]]; + case U'\u221A': /* SQUARE ROOT */ + [[fallthrough]]; + case U'\u221B': /* CUBE ROOT */ + [[fallthrough]]; + case U'\u221C': /* FOURTH ROOT */ + [[fallthrough]]; + case U'\u221E': /* INFINITY */ + [[fallthrough]]; + case U'\u2228': /* LOGICAL OR */ + [[fallthrough]]; + case U'\u2248': /* ALMOST EQUAL TO */ + [[fallthrough]]; + case U'\u2260': /* NOT EQUAL TO */ + [[fallthrough]]; + case U'\u2264': /* LESS-THAN OR EQUAL TO */ + [[fallthrough]]; + case U'\u2265': /* GREATER-THAN OR EQUAL TO */ + [[fallthrough]]; + case U'\u2609': /* SUN */ + [[fallthrough]]; + case U'\u263F': /* MERCURY */ + [[fallthrough]]; + case U'\u2640': /* FEMALE SIGN */ + [[fallthrough]]; + case U'\u2641': /* EARTH */ + [[fallthrough]]; + case U'\u2642': /* MALE SIGN */ + [[fallthrough]]; + case U'\u2643': /* JUPITER */ + [[fallthrough]]; + case U'\u2644': /* SATURN */ + [[fallthrough]]; + case U'\u2645': /* URANUS */ + [[fallthrough]]; + case U'\u2646': /* NEPTUNE */ + [[fallthrough]]; + case U'\u2647': /* PLUTO */ + [[fallthrough]]; + case U'\u26A2': /* DOUBLED FEMALE SIGN */ + [[fallthrough]]; + case U'\u26A3': /* DOUBLED MALE SIGN */ + [[fallthrough]]; + case U'\u26A4': /* INTERLOCKED FEMALE AND MALE SIGN */ + [[fallthrough]]; + case U'\u26A5': /* MALE AND FEMALE SIGN */ + [[fallthrough]]; + case U'\u26B3': /* CERES */ + [[fallthrough]]; + case U'\u26B4': /* PALLAS */ + [[fallthrough]]; + case U'\u26B5': /* JUNO */ + [[fallthrough]]; + case U'\u26B6': /* VESTA */ + [[fallthrough]]; + case U'\u26B7': /* CHIRON */ + [[fallthrough]]; + case U'\u2BD8': /* PROSERPINA */ + [[fallthrough]]; + case U'\u2BD9': /* ASTRAEA */ + [[fallthrough]]; + case U'\u2BDA': /* HYGIEA */ + [[fallthrough]]; + case U'\u2BDB': /* PHOLOS */ + [[fallthrough]]; + case U'\u2BDC': /* NESSUS */ + [[fallthrough]]; + case U'\u2E2E': /* INVERTED QUESTION MARK */ + [[fallthrough]]; + case U'\u33D7': /* SQUARE PH */ + [[fallthrough]]; + case U'\uFDFC': /* RIAL SIGN */ + [[fallthrough]]; + case U'\U0001F10D': /* CIRCLED ZERO WITH SLASH */ + [[fallthrough]]; + case U'\U0001F10E': /* CIRCLED ANTICKLOCKWISE ARROW */ + [[fallthrough]]; + case U'\U0001F10F': /* CIRCLED DOLLAR SIGN WITH OVERLAID BACKSLASH */ + [[fallthrough]]; + case U'\U0001F12F': /* COPYLEFT SYMBOL */ + [[fallthrough]]; + case U'\U0001F16D': /* CIRCLED CC */ + [[fallthrough]]; + case U'\U0001F16E': /* CIRCLED C WITH OVERLAID BACKSLASH */ + [[fallthrough]]; + case U'\U0001F16F': /* CIRCLED HUMAN FIGURE */ + return true; + } +} diff --git a/include/dux/str.d/isspace.hh b/include/dux/str.d/isspace.hh new file mode 100644 index 0000000..79f3487 --- /dev/null +++ b/include/dux/str.d/isspace.hh @@ -0,0 +1,40 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of dux. + + dux is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your + option) any later version. + + dux is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + License for more details. + + You should have received a copy of the GNU Affero General Public License + along with dux. If not, see <https://www.gnu.org/licenses/>. +*/ + +constexpr auto ::dux::isspace(char32_t const _chr) -> bool { + if(_chr > ::dux::unimax) [[unlikely]] { + throw ::dux::outofdomain("Unicode codepoint too big!"); + } + switch(_chr) { + [[likely]] default: + return false; + case U'\u0009': /* HORIZONTAL TABULATION */ + [[fallthrough]]; + case U'\u000A': /* NEW LINE */ + [[fallthrough]]; + case U'\u000B': /* VERTICAL TABULATION */ + [[fallthrough]]; + case U'\u000C': /* FORM FEED */ + [[fallthrough]]; + case U'\u000D': /* CARRIAGE RETURN */ + [[fallthrough]]; + case U'\u0020': /* SPACE */ + return true; + } +} diff --git a/include/dux/str.d/issurro.hh b/include/dux/str.d/issurro.hh new file mode 100644 index 0000000..115bc0f --- /dev/null +++ b/include/dux/str.d/issurro.hh @@ -0,0 +1,28 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of dux. + + dux is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your + option) any later version. + + dux is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + License for more details. + + You should have received a copy of the GNU Affero General Public License + along with dux. If not, see <https://www.gnu.org/licenses/>. +*/ + +constexpr auto ::dux::issurro(char32_t const _chr) -> bool { + if(_chr > ::dux::unimax) [[unlikely]] { + throw ::dux::outofdomain("Unicode codepoint too big!"); + } + if(_chr >= U'\xD800' && _chr <= U'\xDFFF') [[unlikely]] { + return true; + } + return false; +} diff --git a/include/dux/str.d/isupper.hh b/include/dux/str.d/isupper.hh new file mode 100644 index 0000000..7e96224 --- /dev/null +++ b/include/dux/str.d/isupper.hh @@ -0,0 +1,258 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of dux. + + dux is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your + option) any later version. + + dux is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + License for more details. + + You should have received a copy of the GNU Affero General Public License + along with dux. If not, see <https://www.gnu.org/licenses/>. +*/ + +constexpr auto ::dux::isupper(char32_t const _chr) -> bool { + if(_chr > ::dux::unimax) [[unlikely]] { + throw ::dux::outofdomain("Unicode codepoint too big!"); + } + switch(_chr) { + [[likely]] default: + return false; + case U'\u0041': /* LATIN CAPITAL LETTER A */ + [[fallthrough]]; + case U'\u0042': /* LATIN CAPITAL LETTER B */ + [[fallthrough]]; + case U'\u0043': /* LATIN CAPITAL LETTER C */ + [[fallthrough]]; + case U'\u0044': /* LATIN CAPITAL LETTER D */ + [[fallthrough]]; + case U'E': /* LATIN CAPITAL LETTER E */ + [[fallthrough]]; + case U'F': /* LATIN CAPITAL LETTER F */ + [[fallthrough]]; + case U'G': /* LATIN CAPITAL LETTER G */ + [[fallthrough]]; + case U'H': /* LATIN CAPITAL LETTER H */ + [[fallthrough]]; + case U'I': /* LATIN CAPITAL LETTER I */ + [[fallthrough]]; + case U'J': /* LATIN CAPITAL LETTER J */ + [[fallthrough]]; + case U'K': /* LATIN CAPITAL LETTER K */ + [[fallthrough]]; + case U'L': /* LATIN CAPITAL LETTER L */ + [[fallthrough]]; + case U'M': /* LATIN CAPITAL LETTER M */ + [[fallthrough]]; + case U'N': /* LATIN CAPITAL LETTER N */ + [[fallthrough]]; + case U'O': /* LATIN CAPITAL LETTER O */ + [[fallthrough]]; + case U'P': /* LATIN CAPITAL LETTER P */ + [[fallthrough]]; + case U'Q': /* LATIN CAPITAL LETTER Q */ + [[fallthrough]]; + case U'R': /* LATIN CAPITAL LETTER R */ + [[fallthrough]]; + case U'S': /* LATIN CAPITAL LETTER S */ + [[fallthrough]]; + case U'T': /* LATIN CAPITAL LETTER T */ + [[fallthrough]]; + case U'U': /* LATIN CAPITAL LETTER U */ + [[fallthrough]]; + case U'V': /* LATIN CAPITAL LETTER V */ + [[fallthrough]]; + case U'X': /* LATIN CAPITAL LETTER Y */ + [[fallthrough]]; + case U'W': /* LATIN CAPITAL LETTER X */ + [[fallthrough]]; + case U'Y': /* LATIN CAPITAL LETTER Y */ + [[fallthrough]]; + case U'Z': /* LATIN CAPITAL LETTER Z */ + [[fallthrough]]; + case U'\u00C0': /* LATIN CAPITAL LETTER A WITH GRAVE */ + [[fallthrough]]; + case U'\u00C1': /* LATIN CAPITAL LETTER A WITH ACUTE */ + [[fallthrough]]; + case U'\u00C2': /* LATIN CAPITAL LETTER A WITH CIRCUMFLEX */ + [[fallthrough]]; + case U'\u00C3': /* LATIN CAPITAL LETTER A WITH TILDE */ + [[fallthrough]]; + case U'\u00C4': /* LATIN CAPITAL LETTER A WITH DIAERESIS */ + [[fallthrough]]; + case U'\u00C5': /* LATIN CAPITAL LETTER A WITH RING ABOVE */ + [[fallthrough]]; + case U'\u00C6': /* LATIN CAPITAL LETTER AE */ + [[fallthrough]]; + case U'\u00C7': /* LATIN CAPITAL LETTER C WITH CEDILLA */ + [[fallthrough]]; + case U'\u00C8': /* LATIN CAPITAL LETTER E WITH GRAVE */ + [[fallthrough]]; + case U'\u00C9': /* LATIN CAPITAL LETTER E WITH ACUTE */ + [[fallthrough]]; + case U'\u00CA': /* LATIN CAPITAL LETTER E WITH CIRCUMFLEX */ + [[fallthrough]]; + case U'\u00CB': /* LATIN CAPITAL LETTER E WITH DIAERESIS */ + [[fallthrough]]; + case U'\u00CC': /* LATIN CAPITAL LETTER I WITH GRAVE */ + [[fallthrough]]; + case U'\u00CD': /* LATIN CAPITAL LETTER I WITH ACUTE */ + [[fallthrough]]; + case U'\u00CE': /* LATIN CAPITAL LETTER I WITH CIRCUMFLEX */ + [[fallthrough]]; + case U'\u00CF': /* LATIN CAPITAL LETTER I WITH DIAERESIS */ + [[fallthrough]]; + case U'\u00D0': /* LATIN CAPITAL LETTER ETH */ + [[fallthrough]]; + case U'\u00D1': /* LATIN CAPITAL LETTER N WITH TILDE */ + [[fallthrough]]; + case U'\u00D2': /* LATIN CAPITAL LETTER O WITH GRAVE */ + [[fallthrough]]; + case U'\u00D3': /* LATIN CAPITAL LETTER O WITH ACUTE */ + [[fallthrough]]; + case U'\u00D4': /* LATIN CAPITAL LETTER O WITH CIRCUMFLEX */ + [[fallthrough]]; + case U'\u00D5': /* LATIN CAPITAL LETTER O WITH TILDE */ + [[fallthrough]]; + case U'\u00D6': /* LATIN CAPITAL LETTER O WITH DIAERESIS */ + [[fallthrough]]; + case U'\u00D8': /* LATIN CAPITAL LETTER O WITH STROKE */ + [[fallthrough]]; + case U'\u00D9': /* LATIN CAPITAL LETTER U WITH GRAVE */ + [[fallthrough]]; + case U'\u00DA': /* LATIN CAPITAL LETTER U WITH STROKE */ + [[fallthrough]]; + case U'\u00DB': /* LATIN CAPITAL LETTER U WITH CIRCUMFLEX */ + [[fallthrough]]; + case U'\u00DC': /* LATIN CAPITAL LETTER U WITH DIAERESIS */ + [[fallthrough]]; + case U'\u00DD': /* LATIN CAPITAL LETTER Y WITH ACUTE */ + [[fallthrough]]; + case U'\u00DE': /* LATIN CAPITAL LETTER THORN */ + [[fallthrough]]; + case U'\u0100': /* LATIN CAPITAL LETTER A WITH MACRON */ + [[fallthrough]]; + case U'\u0102': /* LATIN CAPITAL LETTER A WITH BREVE */ + [[fallthrough]]; + case U'\u0104': /* LATIN CAPITAL LETTER A WITH OGONEK */ + [[fallthrough]]; + case U'\u0106': /* LATIN CAPITAL LETTER C WITH ACUTE */ + [[fallthrough]]; + case U'\u0108': /* LATIN CAPITAL LETTER C WITH CIRCUMFLEX */ + [[fallthrough]]; + case U'\u010A': /* LATIN CAPITAL LETTER C WITH DOT ABOVE */ + [[fallthrough]]; + case U'\u010C': /* LATIN CAPITAL LETTER C WITH CARON */ + [[fallthrough]]; + case U'\u010E': /* LATIN CAPITAL LETTER D WITH CARON */ + [[fallthrough]]; + case U'\u0110': /* LATIN CAPITAL LETTER D WITH STROKE */ + [[fallthrough]]; + case U'\u0112': /* LATIN CAPITAL LETTER E WITH MACRON */ + [[fallthrough]]; + case U'\u0114': /* LATIN CAPITAL LETTER E WITH BREVE */ + [[fallthrough]]; + case U'\u0116': /* LATIN CAPITAL LETTER E WITH DOT ABOVE */ + [[fallthrough]]; + case U'\u0118': /* LATIN CAPITAL LETTER E WITH OGONEK */ + [[fallthrough]]; + case U'\u011A': /* LATIN CAPITAL LETTER E WITH CARON */ + [[fallthrough]]; + case U'\u011C': /* LATIN CAPITAL LETTER G WITH CIRCUMFLEX */ + [[fallthrough]]; + case U'\u014A': /* LATIN CAPITAL LETTER ENG */ + [[fallthrough]]; + case U'\u0152': /* LATIN CAPITAL LIGATURE OE */ + [[fallthrough]]; + case U'\u0186': /* LATIN CAPITAL LETTER OPEN O */ + [[fallthrough]]; + case U'\u018E': /* LATIN CAPITAL LETTER REVERSED E */ + [[fallthrough]]; + case U'\u018F': /* LATIN CAPITAL LETTER SCHWA */ + [[fallthrough]]; + case U'\u0190': /* LATIN CAPITAL LETTER OPEN E */ + [[fallthrough]]; + case U'\u0194': /* LATIN CAPITAL LETTER GAMMA */ + [[fallthrough]]; + case U'\u0196': /* LATIN CAPITAL LETTER IOTA */ + [[fallthrough]]; + case U'\u01A9': /* LATIN CAPITAL LETTER ESH */ + [[fallthrough]]; + case U'\u01B1': /* LATIN CAPITAL LETTER UPSILON */ + [[fallthrough]]; + case U'\u01B2': /* LATIN CAPITAL LETTER V WITH HOOk */ + [[fallthrough]]; + case U'\u01B7': /* LATIN CAPITAL LETTER EZH */ + [[fallthrough]]; + case U'\u01F7': /* LATIN CAPITAL LETTER WYNN */ + [[fallthrough]]; + case U'\u021C': /* LATIN CAPITAL LETTER YOGH */ + [[fallthrough]]; + case U'\u0241': /* LATIN CAPITAL LETTER GLOTTAL STOP */ + [[fallthrough]]; + case U'\u0391': /* GREEK CAPITAL LETTER ALPHA */ + [[fallthrough]]; + case U'\u0392': /* GREEK CAPITAL LETTER BETA */ + [[fallthrough]]; + case U'\u0393': /* GREEK CAPITAL LETTER GAMMA */ + [[fallthrough]]; + case U'\u0394': /* GREEK CAPITAL LETTER DELTA */ + [[fallthrough]]; + case U'\u0395': /* GREEK CAPITAL LETTER EPSILON */ + [[fallthrough]]; + case U'\u0396': /* GREEK CAPITAL LETTER ZETA */ + [[fallthrough]]; + case U'\u0397': /* GREEK CAPITAL LETTER ETA */ + [[fallthrough]]; + case U'\u0398': /* GREEK CAPITAL LETTER THETA */ + [[fallthrough]]; + case U'\u0399': /* GREEK CAPITAL LETTER IOTA */ + [[fallthrough]]; + case U'\u039A': /* GREEK CAPITAL LETTER KAPPA */ + [[fallthrough]]; + case U'\u039B': /* GREEK CAPITAL LETTER LAMBDA */ + [[fallthrough]]; + case U'\u039C': /* GREEK CAPITAL LETTER MU */ + [[fallthrough]]; + case U'\u039D': /* GREEK CAPITAL LETTER NU */ + [[fallthrough]]; + case U'\u039E': /* GREEK CAPITAL LETTER XI */ + [[fallthrough]]; + case U'\u039F': /* GREEK CAPITAL LETTER OMICRON */ + [[fallthrough]]; + case U'\u03A0': /* GREEK CAPITAL LETTER PI */ + [[fallthrough]]; + case U'\u03A1': /* GREEK CAPITAL LETTER RHO */ + [[fallthrough]]; + case U'\u03A3': /* GREEK CAPITAL LETTER SIGMA */ + [[fallthrough]]; + case U'\u03A4': /* GREEK CAPITAL LETTER TAU */ + [[fallthrough]]; + case U'\u03A5': /* GREEK CAPITAL LETTER UPSILON */ + [[fallthrough]]; + case U'\u03A6': /* GREEK CAPITAL LETTER PHI */ + [[fallthrough]]; + case U'\u03A7': /* GREEK CAPITAL LETTER CHI */ + [[fallthrough]]; + case U'\u03A8': /* GREEK CAPITAL LETTER PSI */ + [[fallthrough]]; + case U'\u03A9': /* GREEK CAPITAL LETTER OMEGA */ + [[fallthrough]]; + case U'\u1E9E': /* LATIN CAPITAL LETTER SHARP S */ + [[fallthrough]]; + case U'\u2C6D': /* LATIN CAPITAL LETTER ALPHA */ + [[fallthrough]]; + case U'\uA77D': /* LATIN CAPITAL LETTER INSULAR G */ + [[fallthrough]]; + case U'\uA7B4': /* LATIN CAPITAL LETTER BETA */ + [[fallthrough]]; + case U'\uA7B6': /* LATIN CAPITAL LETTER OMEGA */ + return true; + } +} diff --git a/include/dux/str.d/isxdigit.hh b/include/dux/str.d/isxdigit.hh new file mode 100644 index 0000000..980ed5c --- /dev/null +++ b/include/dux/str.d/isxdigit.hh @@ -0,0 +1,61 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of dux. + + dux is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your + option) any later version. + + dux is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + License for more details. + + You should have received a copy of the GNU Affero General Public License + along with dux. If not, see <https://www.gnu.org/licenses/>. +*/ + +constexpr auto ::dux::isxdigit(char32_t const _chr) -> bool { + if(_chr > ::dux::unimax) [[unlikely]] { + throw ::dux::outofdomain("Unicode codepoint too big!"); + } + switch(_chr) { + [[likely]] default: + return false; + break; + case U'\u0030': /* DIGIT ZERO */ + [[fallthrough]]; + case U'\u0031': /* DIGIT ONE */ + [[fallthrough]]; + case U'\u0032': /* DIGIT TWO */ + [[fallthrough]]; + case U'\u0033': /* DIGIT THREE */ + [[fallthrough]]; + case U'\u0034': /* DIGIT FOUR */ + [[fallthrough]]; + case U'\u0035': /* DIGIT FIVE */ + [[fallthrough]]; + case U'\u0036': /* DIGIT SIX */ + [[fallthrough]]; + case U'\u0037': /* DIGIT SEVEN */ + [[fallthrough]]; + case U'\u0038': /* DIGIT EIGHT */ + [[fallthrough]]; + case U'\u0039': /* DIGIT NINE */ + [[fallthrough]]; + case U'\u0041': /* LATIN CAPITAL LETTER A */ + [[fallthrough]]; + case U'\u0042': /* LATIN CAPITAL LETTER B */ + [[fallthrough]]; + case U'\u0043': /* LATIN CAPITAL LETTER C */ + [[fallthrough]]; + case U'\u0044': /* LATIN CAPITAL LETTER D */ + [[fallthrough]]; + case U'\u0045': /* LATIN CAPITAL LETTER E */ + [[fallthrough]]; + case U'\u0046': /* LATIN CAPITAL LETTER F */ + return true; + } +} diff --git a/include/dux/str.d/str.hh b/include/dux/str.d/str.hh new file mode 100644 index 0000000..d5bdf20 --- /dev/null +++ b/include/dux/str.d/str.hh @@ -0,0 +1,118 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of dux. + + dux is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your + option) any later version. + + dux is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + License for more details. + + You should have received a copy of the GNU Affero General Public License + along with dux. If not, see <https://www.gnu.org/licenses/>. +*/ + +constexpr auto ::dux::str::begin() noexcept -> char32_t * { + return this->_arr.begin(); +} +constexpr auto ::dux::str::begin() const noexcept -> char32_t const * { + return this->_arr.begin(); +} +constexpr auto ::dux::str::cbegin() const noexcept -> char32_t const * { + return this->_arr.cbegin(); +} +constexpr auto ::dux::str::cend() const noexcept -> char32_t const * { + return this->_arr.cbegin(); +} +constexpr auto ::dux::str::del(::dux::usz const _pos) -> void { + this->_arr.del(_pos); +} +constexpr auto ::dux::str::end() noexcept -> char32_t * { + return this->_arr.end(); +} +constexpr auto ::dux::str::end() const noexcept -> char32_t const * { + return this->_arr.end(); +} +constexpr auto ::dux::str::fnd(char32_t const _chr) const noexcept -> ::dux::usz { + for (auto pos = 0x0uz;pos < this->len();pos += 0x1uz) { + if (this->operator [] (pos) == _chr) [[unlikely]] { + return pos; + } + } + return ::dux::npos; +} +constexpr auto ::dux::str::ins(::dux::usz const _pos,::dux::str const & _oth) -> ::dux::str const & { + this->_arr.ins(_oth._arr,_pos); + return *this; +} +constexpr auto ::dux::str::len() const noexcept -> ::dux::usz { + return this->_arr.sz(); +} +constexpr auto ::dux::str::operator + (::dux::str const & _oth) const -> ::dux::str { + auto str = *this; + str._arr.app(_oth._arr); + return str; +} +constexpr auto ::dux::str::operator = (::dux::str const & _oth) -> ::dux::str const & { + this->_arr = _oth._arr; + return *this; +} +constexpr auto ::dux::str::operator == (::dux::str const & _oth) const noexcept -> bool { + if (this->len() != _oth.len()) { + return false; + } + for (auto n = 0x0uz;n < this->len() && n < _oth.len();n += 0x1uz) { + if ((*this)[n] != _oth[n]) { + return false; + } + } + return true; +} +constexpr auto ::dux::str::operator [] (::dux::usz const _pos) noexcept -> char32_t & { + return this->_arr[_pos]; +} +constexpr auto ::dux::str::operator [] (::dux::usz const _pos) const noexcept -> char32_t const & { + return this->_arr[_pos]; +} +constexpr ::dux::str::str(char32_t const _chr) { + this->_arr.app(_chr); +} +constexpr ::dux::str::str(::dux::str const & _oth) { + *this = _oth; +} +constexpr ::dux::str::str(::dux::str && _oth) { + this->_arr.setraw(_oth._arr.begin(),_oth._arr.sz()); + _oth._arr.setraw(nullptr,0x0uz); +} +template<::dux::usz N> constexpr ::dux::str::str(char32_t const (& _strlit)[N]) noexcept { + this->_arr = _strlit; +} +template<::dux::utf T> constexpr ::dux::str::str(T const _chr) { + if constexpr (::dux::issame<T,char32_t>) { + this->_arr.alloc(0x1uz); + this->_arr[0x0uz] = _chr; + } +} +template<::dux::utf T> constexpr ::dux::str::str(T const * const dux_restr _utf) { + auto const sz = [&]() { + for (auto n = 0x0uz;;n += 0x1uz) { + if (_utf[n] == T{0x0}) { + return n; + } + } + }(); + this->_arr = ::dux::cnv<char32_t>(_utf,_utf + sz); +} +constexpr auto ::dux::str::sub(::dux::usz const _pos,::dux::usz const _len) const -> ::dux::str { + ::dux::str str; + str._arr = this->_arr.sub(_pos,_len); + return str; +} +constexpr auto ::dux::str::u8() const -> ::dux::arr<char8_t> { + return ::dux::cnv<char8_t>(this->begin(),this->end()); +} diff --git a/include/dux/str.d/uniblk.hh b/include/dux/str.d/uniblk.hh new file mode 100644 index 0000000..4a5d1be --- /dev/null +++ b/include/dux/str.d/uniblk.hh @@ -0,0 +1,490 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of dux. + + dux is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your + option) any later version. + + dux is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + License for more details. + + You should have received a copy of the GNU Affero General Public License + along with dux. If not, see <https://www.gnu.org/licenses/>. +*/ + +constexpr auto ::dux::uniblk(char32_t const _chr) -> ::dux::str { + if(_chr > ::dux::unimax) [[unlikely]] { + throw ::dux::invalutf("Unicode codepoint too big!"); + } + if(_chr <= U'\u007F') { + return U"BASIC LATIN"; + } + if(_chr >= U'\u0080' && _chr <= U'\u00FF') { + return U"LATIN-1 SUPPLEMENT"; + } + if(_chr >= U'\u0100' && _chr <= U'\u017F') { + return U"LATIN EXTENDED-A"; + } + if(_chr >= U'\u0180' && _chr <= U'\u024F') { + return U"LATIN EXTENDED-B"; + } + if(_chr >= U'\u0250' && _chr <= U'\u02AF') { + return U"IPA EXTENSIONS"; + } + if(_chr >= U'\u02B0' && _chr <= U'\u02FF') { + return U"SPACING MODIFIER LETTERS"; + } + if(_chr >= U'\u0300' && _chr <= U'\u036F') { + return U"COMBINING DIRACITICAL MARKS"; + } + if(_chr >= U'\u0370' && _chr <= U'\u03FF') { + return U"GREEK AND COPTIC"; + } + if(_chr >= U'\u0400' && _chr <= U'\u04FF') { + return U"CYRILLIC"; + } + if(_chr >= U'\u0500' && _chr <= U'\u052F') { + return U"CYRILLIC SUPPLEMENT"; + } + if(_chr >= U'\u0530' && _chr <= U'\u058F') { + return U"ARMENIAN"; + } + if(_chr >= U'\u0590' && _chr <= U'\u05FF') { + return U"HEBREW"; + } + if(_chr >= U'\u0600' && _chr <= U'\u06FF') { + return U"ARABIC"; + } + if(_chr >= U'\u0700' && _chr <= U'\u074F') { + return U"SYRIAC"; + } + if(_chr >= U'\u0750' && _chr <= U'\u077F') { + return U"ARABIC SUPPLEMENT"; + } + if(_chr >= U'\u0780' && _chr <= U'\u07BF') { + return U"THAANA"; + } + if(_chr >= U'\u07C0' && _chr <= U'\u07FF') { + return U"NKO"; + } + if(_chr >= U'\u0800' && _chr <= U'\u083F') { + return U"SAMARITAN"; + } + if(_chr >= U'\u0840' && _chr <= U'\u085F') { + return U"MANDAIC"; + } + if(_chr >= U'\u0860' && _chr <= U'\u086F') { + return U"SYRIAC SUPPLEMENT"; + } + if(_chr >= U'\u08A0' && _chr <= U'\u08FF') { + return U"ARABIC EXTENDED-A"; + } + if(_chr >= U'\u0900' && _chr <= U'\u097F') { + return U"DEVANAGARI"; + } + if(_chr >= U'\u0980' && _chr <= U'\u09FF') { + return U"BENGALI"; + } + if(_chr >= U'\u0A00' && _chr <= U'\u0A7F') { + return U"GURMUKHI"; + } + if(_chr >= U'\u0A80' && _chr <= U'\u0AFF') { + return U"GUJARATI"; + } + if(_chr >= U'\u0B00' && _chr <= U'\u0B7F') { + return U"ORIYAS"; + } + if(_chr >= U'\u0B80' && _chr <= U'\u0BFF') { + return U"TAMIL"; + } + if(_chr >= U'\u0C00' && _chr <= U'\u0C7F') { + return U"TELUGU"; + } + if(_chr >= U'\u0C80' && _chr <= U'\u0CFF') { + return U"KANNADA"; + } + if(_chr >= U'\u0D00' && _chr <= U'\u0D7F') { + return U"MALAYALAM"; + } + if(_chr >= U'\u0D80' && _chr <= U'\u0DFF') { + return U"SINHALA"; + } + if(_chr >= U'\u0E00' && _chr <= U'\u0E7F') { + return U"THAI"; + } + if(_chr >= U'\u0E80' && _chr <= U'\u0EFF') { + return U"LAO"; + } + if(_chr >= U'\u0F00' && _chr <= U'\u0FFF') { + return U"TIBETAN"; + } + if(_chr >= U'\u1000' && _chr <= U'\u109F') { + return U"MYANMAR"; + } + if(_chr >= U'\u10A0' && _chr <= U'\u10FF') { + return U"GEORGIAN"; + } + if(_chr >= U'\u1100' && _chr <= U'\u11FF') { + return U"HANGUL JAMO"; + } + if(_chr >= U'\u1200' && _chr <= U'\u137F') { + return U"ETHIOPIC"; + } + if(_chr >= U'\u1380' && _chr <= U'\u139F') { + return U"ETHIOPIC SUPPLEMENT"; + } + if(_chr >= U'\u13A0' && _chr <= U'\u13FF') { + return U"CHEROKEE"; + } + if(_chr >= U'\u1400' && _chr <= U'\u167F') { + return U"UNIFIED CANADIAN ABORIGINAL SYLLABICS"; + } + if(_chr >= U'\u1680' && _chr <= U'\u169F') { + return U"OGHAM"; + } + if(_chr >= U'\u16A0' && _chr <= U'\u16FF') { + return U"RUNIC"; + } + if(_chr >= U'\u1700' && _chr <= U'\u171F') { + return U"TAGALOG"; + } + if(_chr >= U'\u1720' && _chr <= U'\u173F') { + return U"HANUNOO"; + } + if(_chr >= U'\u1740' && _chr <= U'\u175F') { + return U"BUHID"; + } + if(_chr >= U'\u1760' && _chr <= U'\u177F') { + return U"TAGBANWA"; + } + if(_chr >= U'\u1700' && _chr <= U'\u17FF') { + return U"TAGALOG"; + } + if(_chr >= U'\u1780' && _chr <= U'\u171F') { + return U"KHMER"; + } + if(_chr >= U'\u1800' && _chr <= U'\u18AF') { + return U"MONGOLIAN"; + } + if(_chr >= U'\u18B0' && _chr <= U'\u18FF') { + return U"UNIFIED CANADIAN ABORIGINAL SYLLABICS EXTENDED"; + } + if(_chr >= U'\u1900' && _chr <= U'\u194F') { + return U"LIMBU"; + } + if(_chr >= U'\u1950' && _chr <= U'\u197F') { + return U"TAI LE"; + } + if(_chr >= U'\u1980' && _chr <= U'\u19DF') { + return U"NEW TAI LUE"; + } + if(_chr >= U'\u19E0' && _chr <= U'\u19FF') { + return U"KHMER SYMBOLS"; + } + if(_chr >= U'\u1A00' && _chr <= U'\u1A1F') { + return U"BUGINESE"; + } + if(_chr >= U'\u1A20' && _chr <= U'\u1AAF') { + return U"TAI THAM"; + } + if(_chr >= U'\u1AB0' && _chr <= U'\u1AFF') { + return U"COMBINING DIACRITICAL MARKS EXTENDED"; + } + if(_chr >= U'\u1B00' && _chr <= U'\u1B7F') { + return U"BALINESE"; + } + if(_chr >= U'\u1B80' && _chr <= U'\u1BBF') { + return U"SUNDANESE"; + } + if(_chr >= U'\u1BC0' && _chr <= U'\u1BFF') { + return U"BATAK"; + } + if(_chr >= U'\u1C00' && _chr <= U'\u1C4F') { + return U"LEPCHA"; + } + if(_chr >= U'\u1C50' && _chr <= U'\u1C7F') { + return U"OL CHIKI"; + } + if(_chr >= U'\u1C80' && _chr <= U'\u1C8F') { + return U"CYRILLIC EXTENDED C"; + } + if(_chr >= U'\u1C90' && _chr <= U'\u1CBF') { + return U"GEORGIAN EXTENDED"; + } + if(_chr >= U'\u1CC0' && _chr <= U'\u1CCF') { + return U"SUNDANESE SUPPLEMENT"; + } + if(_chr >= U'\u1CD0' && _chr <= U'\u1CFF') { + return U"VEDIC EXTENSIONS"; + } + if(_chr >= U'\u1D00' && _chr <= U'\u1D7F') { + return U"PHONETIC EXTENSIONS"; + } + if(_chr >= U'\u1D80' && _chr <= U'\u1DBF') { + return U"PHONETIC EXTENSIONS SUPPLEMENT"; + } + if(_chr >= U'\u1DC0' && _chr <= U'\u1DFF') { + return U"COMBINING DIACRITICAL MARKS SUPPLEMENT"; + } + if(_chr >= U'\u1E00' && _chr <= U'\u1EFF') { + return U"LATIN EXTENDED ADDITIONAL"; + } + if(_chr >= U'\u1F00' && _chr <= U'\u1FFF') { + return U"GREEK EXTENDED"; + } + if(_chr >= U'\u2000' && _chr <= U'\u206F') { + return U"GENERAL PUNCTUATION"; + } + if(_chr >= U'\u2070' && _chr <= U'\u209F') { + return U"SUPERSCRIPTS AND SUBSCRIPTS"; + } + if(_chr >= U'\u20A0' && _chr <= U'\u20CF') { + return U"CURRENCY SYMBOLS"; + } + if(_chr >= U'\u20D0' && _chr <= U'\u20FF') { + return U"COMBINING DIACRITICAL MARKS FOR SYMBOLS"; + } + if(_chr >= U'\u2100' && _chr <= U'\u214F') { + return U"LETTERLIKE SYMBOLS"; + } + if(_chr >= U'\u2150' && _chr <= U'\u218F') { + return U"NUMBER FORMS"; + } + if(_chr >= U'\u2190' && _chr <= U'\u21FF') { + return U"ARROWS"; + } + if(_chr >= U'\U00011A00' && _chr <= U'\U00011A4F') { + return U"ZANABAZAR SQUARE"; + } + if(_chr >= U'\U00011A50' && _chr <= U'\U00011AAF') { + return U"SOYOMBO"; + } + if(_chr >= U'\U00011AC0' && _chr <= U'\U00011AFF') { + return U"PAU CIN HAU"; + } + if(_chr >= U'\U00011C00' && _chr <= U'\U00011C6F') { + return U"BHAIKSUKI"; + } + if(_chr >= U'\U00011C70' && _chr <= U'\U00011CBF') { + return U"MARCHEN"; + } + if(_chr >= U'\U00011D00' && _chr <= U'\U00011D5F') { + return U"MASARAM GONDI"; + } + if(_chr >= U'\U00011D60' && _chr <= U'\U00011DAF') { + return U"GUNJALA GONDI"; + } + if(_chr >= U'\U00011EE0' && _chr <= U'\U00011EFF') { + return U"MAKASAR"; + } + if(_chr >= U'\U00011FB0' && _chr <= U'\U00011FBF') { + return U"LISU SUPPLEMENT"; + } + if(_chr >= U'\U00011FC0' && _chr <= U'\U00011FFF') { + return U"TAMIL SUPPLEMENT"; + } + if(_chr >= U'\U00012000' && _chr <= U'\U000123FF') { + return U"CUNEIFORM"; + } + if(_chr >= U'\U00012400' && _chr <= U'\U0001247F') { + return U"CUNEIFORM NUMBERS AND PUNCTUATION"; + } + if(_chr >= U'\U00012480' && _chr <= U'\U0001254F') { + return U"EARLY DYNASTIC CUNEIFORM"; + } + if(_chr >= U'\U00013000' && _chr <= U'\U0001342F') { + return U"EGYPTIAN HIEROGLYPHS"; + } + if(_chr >= U'\U00013430' && _chr <= U'\U0001343F') { + return U"EGYPTIAN HIEROGLYPH FORMAT CONTROLS"; + } + if(_chr >= U'\U00014400' && _chr <= U'\U0001467F') { + return U"ANATOLIAN HIEROGLYPHS"; + } + if(_chr >= U'\U00016800' && _chr <= U'\U00016A3F') { + return U"BAMUM SUPPLEMENT"; + } + if(_chr >= U'\U00016A40' && _chr <= U'\U00016A6F') { + return U"MRO"; + } + if(_chr >= U'\U00016AD0' && _chr <= U'\U00016AFF') { + return U"BASSA VAH"; + } + if(_chr >= U'\U00016B00' && _chr <= U'\U00016B8F') { + return U"PAHAWH HMONG"; + } + if(_chr >= U'\U00016E40' && _chr <= U'\U00016E9F') { + return U"MEDEFAIDRIN"; + } + if(_chr >= U'\U00016F00' && _chr <= U'\U00016F9F') { + return U"MIAO"; + } + if(_chr >= U'\U00016FE0' && _chr <= U'\U00016FFF') { + return U"IDEOGRAPHIC SYMBOLS AND PUNCTUATION"; + } + if(_chr >= U'\U00017000' && _chr <= U'\U000187FF') { + return U"TANGUT"; + } + if(_chr >= U'\U00018800' && _chr <= U'\U00018AFF') { + return U"TANGUT COMPONENTS"; + } + if(_chr >= U'\U00018B00' && _chr <= U'\U00018CFF') { + return U"KHITAN SMALL SCRIPT"; + } + if(_chr >= U'\U00018D00' && _chr <= U'\U00018D8F') { + return U"TANGUT SUPPLEMENT"; + } + if(_chr >= U'\U0001B000' && _chr <= U'\U0001B0FF') { + return U"KANA SUPPLEMENT"; + } + if(_chr >= U'\U0001B100' && _chr <= U'\U0001B12F') { + return U"KANA EXTENDED-A"; + } + if(_chr >= U'\U0001B130' && _chr <= U'\U0001B16F') { + return U"SMALL KANA EXTENSION"; + } + if(_chr >= U'\U0001B170' && _chr <= U'\U0001B2FF') { + return U"NUSHU"; + } + if(_chr >= U'\U0001BC00' && _chr <= U'\U0001BC9F') { + return U"DUPLOYAN"; + } + if(_chr >= U'\U0001BCA0' && _chr <= U'\U0001BCAF') { + return U"SHORTHAND FORMAT CONTROLS"; + } + if(_chr >= U'\U0001D000' && _chr <= U'\U0001D0FF') { + return U"BYZANTINE MUSICAL SYMBOLS"; + } + if(_chr >= U'\U0001D100' && _chr <= U'\U0001D1FF') { + return U"MUSICAL SYMBOLS"; + } + if(_chr >= U'\U0001D200' && _chr <= U'\U0001D24F') { + return U"ANCIENT GREEK MUSICAL NOTATION"; + } + if(_chr >= U'\U0001D2E0' && _chr <= U'\U0001D2FF') { + return U"MAYAN NUMERALS"; + } + if(_chr >= U'\U0001D300' && _chr <= U'\U0001D35F') { + return U"TAI XUAN JING SYMBOLS"; + } + if(_chr >= U'\U0001D360' && _chr <= U'\U0001D37F') { + return U"COUNTING ROD NUMERALS"; + } + if(_chr >= U'\U0001D400' && _chr <= U'\U0001D7FF') { + return U"MATHEMATICAL ALPHANUMERIC SYMBOLS"; + } + if(_chr >= U'\U0001D800' && _chr <= U'\U0001DAAF') { + return U"SUTTON SIGNWRITING"; + } + if(_chr >= U'\U0001E000' && _chr <= U'\U0001E02F') { + return U"GLAGOLITIC SUPPLEMENT"; + } + if(_chr >= U'\U0001E100' && _chr <= U'\U0001E14F') { + return U"NYIAKENG PUACHUE HMONG"; + } + if(_chr >= U'\U0001E2C0' && _chr <= U'\U0001E2FF') { + return U"WANCHO"; + } + if(_chr >= U'\U0001E800' && _chr <= U'\U0001E8DF') { + return U"MENDE KIKAKUI"; + } + if(_chr >= U'\U0001E900' && _chr <= U'\U0001E95F') { + return U"ADLAM"; + } + if(_chr >= U'\U0001EC70' && _chr <= U'\U0001ECBF') { + return U"INDIC SIYAQ NUMBERS"; + } + if(_chr >= U'\U0001ED00' && _chr <= U'\U0001ED4F') { + return U"OTTOMAN SIYAQ NUMBERS"; + } + if(_chr >= U'\U0001EE00' && _chr <= U'\U0001EEFF') { + return U"ARABIC MATHEMATICAL ALPHABETIC SYMBOLS"; + } + if(_chr >= U'\U0001F000' && _chr <= U'\U0001F02F') { + return U"MAHJONG TILES"; + } + if(_chr >= U'\U0001F030' && _chr <= U'\U0001F09F') { + return U"DOMINO TILES"; + } + if(_chr >= U'\U0001F0A0' && _chr <= U'\U0001F0FF') { + return U"PLAYING CARDS"; + } + if(_chr >= U'\U0001F100' && _chr <= U'\U0001F1FF') { + return U"ENCLOSED ALPHANUMERIC SUPPLEMENT"; + } + if(_chr >= U'\U0001F200' && _chr <= U'\U0001F2FF') { + return U"ENCLOSED IDEOGRAPHIC SUPPLEMENT"; + } + if(_chr >= U'\U0001F300' && _chr <= U'\U0001F5FF') { + return U"MISCELLANEOUS SYMBOLS AND PICTOGRAPHS"; + } + if(_chr >= U'\U0001F600' && _chr <= U'\U0001F64F') { + return U"EMOTICONS"; + } + if(_chr >= U'\U0001F650' && _chr <= U'\U0001F67F') { + return U"ORNAMENTAL DINGBATS"; + } + if(_chr >= U'\U0001F680' && _chr <= U'\U0001F6FF') { + return U"TRANSPORT AND MAP SYMBOLS"; + } + if(_chr >= U'\U0001F700' && _chr <= U'\U0001F77F') { + return U"ALCHEMICAL SYMBOLS"; + } + if(_chr >= U'\U0001F780' && _chr <= U'\U0001F7FF') { + return U"GEOMETRIC SHAPES EXTENDED"; + } + if(_chr >= U'\U0001F800' && _chr <= U'\U0001F8FF') { + return U"SUPPLEMENTAL ARROWS-C"; + } + if(_chr >= U'\U0001F900' && _chr <= U'\U0001F9FF') { + return U"SUPPLEMENTAL SYMBOLS AND PICTOGRAPHS"; + } + if(_chr >= U'\U0001FA00' && _chr <= U'\U0001FA6F') { + return U"CHESS SYMBOLS"; + } + if(_chr >= U'\U0001FA70' && _chr <= U'\U0001FAFF') { + return U"SYMBOLS AND PICTOGRAPHS EXTENDED-A"; + } + if(_chr >= U'\U0001FB00' && _chr <= U'\U0001FBFF') { + return U"SYMBOLS FOR LEGACY COMPUTING"; + } + if(_chr >= U'\U00020000' && _chr <= U'\U0002A6DF') { + return U"CJK UNIFIED IDEOGRAPHS EXTENSION B"; + } + if(_chr >= U'\U0002A700' && _chr <= U'\U0002B73F') { + return U"CJK UNIFIED IDEOGRAPHS EXTENSION C"; + } + if(_chr >= U'\U0002B740' && _chr <= U'\U0002B81F') { + return U"CJK UNIFIED IDEOGRAPHS EXTENSION D"; + } + if(_chr >= U'\U0002B820' && _chr <= U'\U0002CEAF') { + return U"CJK UNIFIED IDEOGRAPHS EXTENSION E"; + } + if(_chr >= U'\U0002CEB0' && _chr <= U'\U0002EBEF') { + return U"CJK UNIFIED IDEOGRAPHS EXTENSION F"; + } + if(_chr >= U'\U0002F800' && _chr <= U'\U0002FA1F') { + return U"CJK COMPATIBILITY IDEOGRAPHS SUPPLEMENT"; + } + if(_chr >= U'\U00030000' && _chr <= U'\U0003134F') { + return U"CJK UNIFIED IDEOGRAPHS EXTENSION G"; + } + if(_chr >= U'\U000E0000' && _chr <= U'\U000E007F') { + return U"TAGS"; + } + if(_chr >= U'\U000E0100' && _chr <= U'\U000E1EFF') { + return U"VARIATION SELECTORS SUPPLEMENT"; + } + if(_chr >= U'\U000F0000' && _chr <= U'\U000FFFFF') { + return U"SUPPLEMENTARY PRIVATE USE AREA-A"; + } + if(_chr >= U'\U00100000' && _chr <= U'\U0010FFFF') { + return U"SUPPLEMENTARY PRIVATE USE AREA-B"; + } + return U"UNDEFINED IN UNICODE"; +} diff --git a/include/dux/str.d/uninm.hh b/include/dux/str.d/uninm.hh new file mode 100644 index 0000000..7c40d2c --- /dev/null +++ b/include/dux/str.d/uninm.hh @@ -0,0 +1,2720 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of dux. + + dux is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your + option) any later version. + + dux is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + License for more details. + + You should have received a copy of the GNU Affero General Public License + along with dux. If not, see <https://www.gnu.org/licenses/>. +*/ + +constexpr auto ::dux::uninm(char32_t const _chr) -> ::dux::str{ + switch(_chr) { + [[unlikely]] default: + if(_chr > ::dux::unimax) [[unlikely]] { + throw ::dux::invalutf("Character out of range."); + } + return U"UNDEFINED IN UNICODE"; + /* BASIC LATIN: */ + case U'\u0000': + return U"NULL"; + case U'\u0001': + return U"START OF HEADING"; + case U'\u0002': + return U"START OF TEXT"; + case U'\u0003': + return U"END OF TEXT"; + case U'\u0004': + return U"END OF TRANSMISSION"; + case U'\u0005': + return U"ENQUIRY"; + case U'\u0006': + return U"ACKNOWLEDGE"; + case U'\u0007': + return U"BELL"; + case U'\u0008': + return U"BACKSPACE"; + case U'\u0009': + return U"HORIZONTAL TABULATION"; + case U'\u000A': + return U"NEW LINE"; + case U'\u000B': + return U"VERTICAL TABULATION"; + case U'\u000C': + return U"FORM FEED"; + case U'\u000D': + return U"CARRIAGE RETURN"; + case U'\u000E': + return U"SHIFT OUT"; + case U'\u000F': + return U"SHIFT IN"; + case U'\u0010': + return U"DATA LINK ESCAPE"; + case U'\u0011': + return U"DEVICE CONTROL ONE"; + case U'\u0012': + return U"DEVICE CONTROL TWO"; + case U'\u0013': + return U"DEVICE CONTROL THREE"; + case U'\u0014': + return U"DEVICE CONTROL FOUR"; + case U'\u0015': + return U"NEGATIVE ACKNOWLEDGE"; + case U'\u0016': + return U"SYNCHRONOUS IDLE"; + case U'\u0017': + return U"END OF TRANSMISSION BLOCk"; + case U'\u0018': + return U"CANCEL"; + case U'\u0019': + return U"END OF MEDIUM"; + case U'\u001A': + return U"SUBSTITUTE"; + case U'\u001B': + return U"ESCAPE"; + case U'\u001C': + return U"FILE SEPERATOR"; + case U'\u001D': + return U"GROUP SEPERATOR"; + case U'\u001E': + return U"RECORD SEPERATOR"; + case U'\u001F': + return U"UNIT SEPERATOR"; + case U'\u0020': + return U"SPACE"; + case U'\u0021': + return U"EXCLAMATION MARK"; + case U'\u0022': + return U"QUOTATION MARK"; + case U'\u0023': + return U"NUMBER SIGN"; + case U'\u0024': + return U"DOLLAR SIGN"; + case U'\u0025': + return U"PERCENT SIGN"; + case U'\u0026': + return U"AMPERSAND"; + case U'\u0027': + return U"APOSTROPHE"; + case U'\u0028': + return U"LEFT PARANTHESIS"; + case U'\u0029': + return U"RIGHT PARANTHESIS"; + case U'\u002A': + return U"ASTERISK"; + case U'\u002B': + return U"PLUS SIGN"; + case U'\u002C': + return U"COMMA"; + case U'\u002D': + return U"HYPHEN-MINUS"; + case U'\u002E': + return U"FULL STOP"; + case U'\u002F': + return U"SOLIDUS"; + case U'\u0030': + return U"DIGIT ZERO"; + case U'\u0031': + return U"DIGIT ONE"; + case U'\u0032': + return U"DIGIT TWO"; + case U'\u0033': + return U"DIGIT THREE"; + case U'\u0034': + return U"DIGIT FOUR"; + case U'\u0035': + return U"DIGIT FIVE"; + case U'\u0036': + return U"DIGIT SIX"; + case U'\u0037': + return U"DIGIT SEVEN"; + case U'\u0038': + return U"DIGIT EIGHT"; + case U'\u0039': + return U"DIGIT NINE"; + case U'\u003A': + return U"COLON"; + case U'\u003B': + return U"SEMICOLON"; + case U'\u003C': + return U"LESS-THAN SIGN"; + case U'\u003D': + return U"EQUALS SIGN"; + case U'\u003E': + return U"GREATER-THAN SIGN"; + case U'\u003F': + return U"QUESTION MARK"; + case U'\u0040': + return U"COMMERCIAL AT"; + case U'\u0041': + return U"LATIN CAPITAL LETTER A"; + case U'\u0042': + return U"LATIN CAPITAL LETTER B"; + case U'\u0043': + return U"LATIN CAPITAL LETTER C"; + case U'\u0044': + return U"LATIN CAPITAL LETTER D"; + case U'\u0045': + return U"LATIN CAPITAL LETTER E"; + case U'\u0046': + return U"LATIN CAPITAL LETTER F"; + case U'\u0047': + return U"LATIN CAPITAL LETTER G"; + case U'\u0048': + return U"LATIN CAPITAL LETTER H"; + case U'\u0049': + return U"LATIN CAPITAL LETTER I"; + case U'\u004A': + return U"LATIN CAPITAL LETTER J"; + case U'\u004B': + return U"LATIN CAPITAL LETTER K"; + case U'\u004C': + return U"LATIN CAPITAL LETTER L"; + case U'\u004D': + return U"LATIN CAPITAL LETTER M"; + case U'\u004E': + return U"LATIN CAPITAL LETTER N"; + case U'\u004F': + return U"LATIN CAPITAL LETTER O"; + case U'\u0050': + return U"LATIN CAPITAL LETTER P"; + case U'\u0051': + return U"LATIN CAPITAL LETTER Q"; + case U'\u0052': + return U"LATIN CAPITAL LETTER R"; + case U'\u0053': + return U"LATIN CAPITAL LETTER S"; + case U'\u0054': + return U"LATIN CAPITAL LETTER T"; + case U'\u0055': + return U"LATIN CAPITAL LETTER U"; + case U'\u0056': + return U"LATIN CAPITAL LETTER V"; + case U'\u0057': + return U"LATIN CAPITAL LETTER W"; + case U'\u0058': + return U"LATIN CAPITAL LETTER X"; + case U'\u0059': + return U"LATIN CAPITAL LETTER Y"; + case U'\u005A': + return U"LATIN CAPITAL LETTER Z"; + case U'\u005B': + return U"LEFT SQUARE BRACKET"; + case U'\u005C': + return U"REVERSE SOLIDUS"; + case U'\u005D': + return U"RIGHT SQUARE BRACKET"; + case U'\u005E': + return U"CIRCUMFLEX ACCENT"; + case U'\u005F': + return U"LOW LINE"; + case U'\u0060': + return U"GRAVE ACCENT"; + case U'\u0061': + return U"LATIN SMALL LETTER A"; + case U'\u0062': + return U"LATIN SMALL LETTER B"; + case U'\u0063': + return U"LATIN SMALL LETTER C"; + case U'\u0064': + return U"LATIN SMALL LETTER D"; + case U'\u0065': + return U"LATIN SMALL LETTER E"; + case U'\u0066': + return U"LATIN SMALL LETTER F"; + case U'\u0067': + return U"LATIN SMALL LETTER G"; + case U'\u0068': + return U"LATIN SMALL LETTER H"; + case U'\u0069': + return U"LATIN SMALL LETTER I"; + case U'\u006A': + return U"LATIN SMALL LETTER J"; + case U'\u006B': + return U"LATIN SMALL LETTER K"; + case U'\u006C': + return U"LATIN SMALL LETTER L"; + case U'\u006D': + return U"LATIN SMALL LETTER M"; + case U'\u006E': + return U"LATIN SMALL LETTER N"; + case U'\u006F': + return U"LATIN SMALL LETTER O"; + case U'\u0070': + return U"LATIN SMALL LETTER P"; + case U'\u0071': + return U"LATIN SMALL LETTER Q"; + case U'\u0072': + return U"LATIN SMALL LETTER R"; + case U'\u0073': + return U"LATIN SMALL LETTER S"; + case U'\u0074': + return U"LATIN SMALL LETTER T"; + case U'\u0075': + return U"LATIN SMALL LETTER U"; + case U'\u0076': + return U"LATIN SMALL LETTER V"; + case U'\u0077': + return U"LATIN SMALL LETTER W"; + case U'\u0078': + return U"LATIN SMALL LETTER X"; + case U'\u0079': + return U"LATIN SMALL LETTER Y"; + case U'\u007A': + return U"LATIN SMALL LETTER Z"; + case U'\u007B': + return U"LEFT CURLY BRACKET"; + case U'\u007C': + return U"VERTICAL LINE"; + case U'\u007D': + return U"RIGHT CURLY BRACKET"; + case U'\u007E': + return U"TILDE"; + case U'\u007F': + return U"DELETE"; + /* LATIN-1 SUPPLEMENT: */ + case U'\u0080': + return U"PADDING CHARACTER"; + case U'\u0081': + return U"HIGH OCTET PRESET"; + case U'\u0082': + return U"BREAK PERMITTED HERE"; + case U'\u0083': + return U"NO BREAK HERE"; + case U'\u0084': + return U"INDEX"; + case U'\u0085': + return U"NEXT LINE"; + case U'\u0086': + return U"START OF SELECTED AREA"; + case U'\u0087': + return U"END OF SELECTED AREA"; + case U'\u0088': + return U"CHARACTER TABULATION SET"; + case U'\u0089': + return U"CHARACTER TABULATION WITH JUSTIFICATION"; + case U'\u008A': + return U"LINE TABULATION SET"; + case U'\u008B': + return U"PARTIAL LINE FORWARD"; + case U'\u008C': + return U"PARTIAL LINE BACKWARD"; + case U'\u008D': + return U"REVERSE LINE FEED"; + case U'\u008E': + return U"SINGLE SHIFT TWO"; + case U'\u008F': + return U"SINGLE SHIFT THREE"; + case U'\u0090': + return U"DEVICE CONTROL STRING"; + case U'\u0091': + return U"PRIVATE USE ONE"; + case U'\u0092': + return U"PRIVATE USE TWO"; + case U'\u0093': + return U"SET TRANSMIT STATE"; + case U'\u0094': + return U"CANCEL CHARACTER"; + case U'\u0095': + return U"MESSAGE WAITING"; + case U'\u0096': + return U"START OF GUARDED AREA"; + case U'\u0097': + return U"END OF GUARDED AREA"; + case U'\u0098': + return U"START OF STRING"; + case U'\u0099': + return U"SINGLE GRAPHIC CHARACTER INTRODUCER"; + case U'\u009A': + return U"SINGLE CHARACTER INTRODUCER"; + case U'\u009B': + return U"CONTROL SEQUENCE INTRODUCER"; + case U'\u009C': + return U"STRING TERMINATOR"; + case U'\u009D': + return U"OPERATING SYSTEM COMMAND"; + case U'\u009E': + return U"PRIVACY MESSAGE"; + case U'\u009F': + return U"APPLICATION PROGRAM COMMAND"; + case U'\u00A0': + return U"NO-BREAK SPACE"; + case U'\u00A1': + return U"INVERTED EXCLAMATION MARK"; + case U'\u00A2': + return U"CENT SIGN"; + case U'\u00A3': + return U"POUND SIGN"; + case U'\u00A4': + return U"CURRENCY SIGN"; + case U'\u00A5': + return U"YEN SIGN"; + case U'\u00A6': + return U"BROKEN BAR"; + case U'\u00A7': + return U"SECTION SIGN"; + case U'\u00A8': + return U"DIAERESIS"; + case U'\u00A9': + return U"COPYRIGHT SIGN"; + case U'\u00AA': + return U"FEMININE ORDINAL INDICATOR"; + case U'\u00AB': + return U"LEFT-POINTING DOUBLE ANGLE QUOTATION MARK"; + case U'\u00AC': + return U"NOT SIGN"; + case U'\u00AD': + return U"SOFT HYPHEN"; + case U'\u00AE': + return U"REGISTERED SIGN"; + case U'\u00AF': + return U"MACRON"; + case U'\u00B0': + return U"DEGREE SIGN"; + case U'\u00B1': + return U"PLUS MINUS SYMBOL"; + case U'\u00B2': + return U"SUPERSCRIPT TWO"; + case U'\u00B3': + return U"SUPERSCRIPT THREE"; + case U'\u00B4': + return U"ACUTE ACCENT"; + case U'\u00B5': + return U"MICRO SIGN"; + case U'\u00B6': + return U"PILCROW SIGN"; + case U'\u00B7': + return U"MIDDLE DOT"; + case U'\u00B8': + return U"CEDILLA"; + case U'\u00B9': + return U"SUPERSCRIPT ONE"; + case U'\u00BA': + return U"MASCULINE ORDINAL INDICATOR"; + case U'\u00BB': + return U"RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK"; + case U'\u00BC': + return U"VULGAR FRACTION ONE QUARTER"; + case U'\u00BD': + return U"VULGAR FRACTION ONE HALF"; + case U'\u00BE': + return U"VULGAR FRACTION THREE QUARTERS"; + case U'\u00BF': + return U"INVERTED QUESTION MARK"; + case U'\u00C0': + return U"LATIN CAPITAL LETTER A WITH GRAVE"; + case U'\u00C1': + return U"LATIN CAPITAL LETTER A WITH ACUTE"; + case U'\u00C2': + return U"LATIN CAPITAL LETTER A WITH CIRCUMFLEX"; + case U'\u00C3': + return U"LATIN CAPITAL LETTER A WITH TILDE"; + case U'\u00C4': + return U"LATIN CAPITAL LETTER A WITH DIAERESIS"; + case U'\u00C5': + return U"LATIN CAPITAL LETTER A WITH RING ABOVE"; + case U'\u00C6': + return U"LATIN CAPITAL LETTER AE"; + case U'\u00C7': + return U"LATIN CAPITAL LETTER C WITH CEDILLA"; + case U'\u00C8': + return U"LATIN CAPITAL LETTER E WITH GRAVE"; + case U'\u00C9': + return U"LATIN CAPITAL LETTER E WITH ACUTE"; + case U'\u00CA': + return U"LATIN CAPITAL LETTER E WITH CIRCUMFLEX"; + case U'\u00CB': + return U"LATIN CAPITAL LETTER E WITH DIAERESIS"; + case U'\u00CC': + return U"LATIN CAPITAL LETTER I WITH GRAVE"; + case U'\u00CD': + return U"LATIN CAPITAL LETTER I WITH ACUTE"; + case U'\u00CE': + return U"LATIN CAPITAL LETTER I WITH CIRCUMFLEX"; + case U'\u00CF': + return U"LATIN CAPITAL LETTER I WITH DIAERESIS"; + case U'\u00D0': + return U"LATIN CAPITAL LETTER ETH"; + case U'\u00D1': + return U"LATIN CAPITAL LETTER N WITH TILDE"; + case U'\u00D2': + return U"LATIN CAPITAL LETTER O WITH GRAVE"; + case U'\u00D3': + return U"LATIN CAPITAL LETTER O WITH ACUTE"; + case U'\u00D4': + return U"LATIN CAPITAL LETTER O WITH CIRCUMFLEX"; + case U'\u00D5': + return U"LATIN CAPITAL LETTER O WITH TILDE"; + case U'\u00D6': + return U"LATIN CAPITAL LETTER O WITH DIAERESIS"; + case U'\u00D7': + return U"MULTIPLICATION SIGN"; + case U'\u00D8': + return U"LATIN CAPITAL LETTER O WITH STROKE"; + case U'\u00D9': + return U"LATIN CAPITAL LETTER U WITH GRAVE"; + case U'\u00DA': + return U"LATIN CAPITAL LETTER U WITH ACUTE"; + case U'\u00DB': + return U"LATIN CAPITAL LETTER U WITH CIRCUMFLEX"; + case U'\u00DC': + return U"LATIN CAPITAL LETTER U WITH DIAERESIS"; + case U'\u00DD': + return U"LATIN CAPITAL LETTER Y WITH ACUTE"; + case U'\u00DE': + return U"LATIN CAPITAL LETTER THORN"; + case U'\u00DF': + return U"LATIN SMALL LETTER SHARP S"; + case U'\u00E0': + return U"LATIN SMALL LETTER A WITH GRAVE"; + case U'\u00E1': + return U"LATIN SMALL LETTER A WITH ACUTE"; + case U'\u00E2': + return U"LATIN SMALL LETTER A WITH CIRCUMFLEX"; + case U'\u00E3': + return U"LATIN SMALL LETTER A WITH TILDE"; + case U'\u00E4': + return U"LATIN SMALL LETTER A WITH DIAERESIS"; + case U'\u00E5': + return U"LATIN SMALL LETTER A WITH RING ABOVE"; + case U'\u00E6': + return U"LATIN SMALL LETTER AE"; + case U'\u00E7': + return U"LATIN SMALL LETTER C WITH CEDILLA"; + case U'\u00E8': + return U"LATIN SMALL LETTER E WITH GRAVE"; + case U'\u00E9': + return U"LATIN SMALL LETTER E WITH ACUTE"; + case U'\u00EA': + return U"LATIN SMALL LETTER E WITH CIRCUMFLEX"; + case U'\u00EB': + return U"LATIN SMALL LETTER E WITH DIAERESIS"; + case U'\u00EC': + return U"LATIN SMALL LETTER I WITH GRAVE"; + case U'\u00ED': + return U"LATIN SMALL LETTER I WITH ACUTE"; + case U'\u00EE': + return U"LATIN SMALL LETTER I WITH CIRCUMFLEX"; + case U'\u00EF': + return U"LATIN SMALL LETTER I WITH DIAERESIS"; + case U'\u00F0': + return U"LATIN SMALL LETTER ETH"; + case U'\u00F1': + return U"LATIN SMALL LETTER N WITH TILDE"; + case U'\u00F2': + return U"LATIN SMALL LETTER O WITH GRAVE"; + case U'\u00F3': + return U"LATIN SMALL LETTER O WITH ACUTE"; + case U'\u00F4': + return U"LATIN SMALL LETTER O WITH CIRCUMFLEX"; + case U'\u00F5': + return U"LATIN SMALL LETTER O WITH TILDE"; + case U'\u00F6': + return U"LATIN SMALL LETTER O WITH DIAERESIS"; + case U'\u00F7': + return U"DIVISION SIGN"; + case U'\u00F8': + return U"LATIN SMALL LETTER O WITH STROKE"; + case U'\u00F9': + return U"LATIN SMALL LETTER U WITH GRAVE"; + case U'\u00FA': + return U"LATIN SMALL LETTER U WITH ACUTE"; + case U'\u00FB': + return U"LATIN SMALL LETTER U WITH CIRCUMFLEX"; + case U'\u00FC': + return U"U WITH TWO DOTS"; + case U'\u00FD': + return U"LATIN SMALL LETTER Y WITH ACUTE"; + case U'\u00FE': + return U"LATIN SMALL LETTER THORN"; + case U'\u00FF': + return U"LATIN SMALL LETTER Y WITH DIAERESIS"; + /* LATIN EXTENDED-A: */ + case U'\u0100': + return U"LATIN CAPITAL LETTER A WITH MACRON"; + case U'\u0101': + return U"LATIN SMALL LETTER A WITH MACRON"; + case U'\u0102': + return U"LATIN CAPITAL LETTER A WITH BREVE"; + case U'\u0103': + return U"LATIN SMALL LETTER A WITH BREVE"; + case U'\u0104': + return U"LATIN CAPITAL LETTER A WITH OGONEK"; + case U'\u0105': + return U"LATIN SMALL LETTER A WITH OGONEK"; + case U'\u0106': + return U"LATIN CAPITAL LETTER C WITH ACUTE"; + case U'\u0107': + return U"LATIN SMALL LETTER C WITH ACUTE"; + case U'\u0108': + return U"LATIN CAPITAL LETTER C WITH CIRCUMFLEX"; + case U'\u0109': + return U"LATIN SMALL LETTER C WITH CIRCUMFLEX"; + case U'\u010A': + return U"LATIN CAPITAL LETTER C WITH DOT ABOVE"; + case U'\u010B': + return U"LATIN SMALL LETTER C WITH DOT ABOVE"; + case U'\u010C': + return U"LATIN CAPITAL LETTER C WITH CARON"; + case U'\u010D': + return U"LATIN SMALL LETTER C WITH CARON"; + case U'\u010E': + return U"LATIN CAPITAL LETTER D WITH CARON"; + case U'\u010F': + return U"LATIN SMALL LETTER D WITH CARON"; + case U'\u0110': + return U"LATIN CAPITAL LETTER D WITH STROKE"; + case U'\u0111': + return U"LATIN SMALL LETTER D WITH STROKE"; + case U'\u0112': + return U"LATIN CAPITAL LETTER E WITH MACRON"; + case U'\u0113': + return U"LATIN SMALL LETTER E WITH MACRON"; + case U'\u0114': + return U"LATIN CAPITAL LETTER E WITH BREVE"; + case U'\u0115': + return U"LATIN SMALL LETTER E WITH BREVE"; + case U'\u0116': + return U"LATIN CAPITAL LETTER E WITH DOT ABOVE"; + case U'\u0117': + return U"LATIN SMALL LETTER E WITH DOT ABOVE"; + case U'\u0118': + return U"LATIN CAPITAL LETTER E WITH OGONEK"; + case U'\u0119': + return U"LATIN SMALL LETTER E WITH OGONEK"; + case U'\u011A': + return U"LATIN CAPITAL LETTER E WITH CARON"; + case U'\u011B': + return U"LATIN SMALL LETTER E WITH CARON"; + case U'\u011C': + return U"LATIN CAPITAL LETTER G WITH CIRCUMFLEX"; + case U'\u011D': + return U"LATIN SMALL LETTER G WITH CIRCUMFLEX"; + case U'\u011E': + return U"LATIN CAPITAL LETTER G WITH BREVE"; + case U'\u011F': + return U"LATIN SMALL LETTER G WITH BREVE"; + case U'\u0120': + return U"LATIN CAPITAL LETTER G WITH DOT ABOVE"; + case U'\u0121': + return U"LATIN SMALL LETTER G WITH DOT ABOVE"; + case U'\u0122': + return U"LATIN CAPITAL LETTER G WITH CEDILLA"; + case U'\u0123': + return U"LATIN SMALL LETTER G WITH CEDILLA"; + case U'\u0124': + return U"LATIN CAPITAL LETTER H WITH CIRCUMFLEX"; + case U'\u0125': + return U"LATIN SMALL LETTER H WITH CIRCUMFLEX"; + case U'\u0126': + return U"LATIN CAPITAL LETTER H WITH STROKE"; + case U'\u0127': + return U"LATIN SMALL LETTER H WITH STROKE"; + case U'\u0128': + return U"LATIN CAPITAL LETTER I WITH TILDE"; + case U'\u0129': + return U"LATIN SMALL LETTER I WITH TILDE"; + case U'\u012A': + return U"LATIN CAPITAL LETTER I WITH MACRON"; + case U'\u012B': + return U"LATIN SMALL LETTER I WITH MACRON"; + case U'\u012C': + return U"LATIN CAPITAL LETTER I WITH BREVE"; + case U'\u012D': + return U"LATIN SMALL LETTER I WITH BREVE"; + case U'\u012E': + return U"LATIN CAPITAL LETTER I WITH OGONEK"; + case U'\u012F': + return U"LATIN SMALL LETTER I WITH OGONEK"; + case U'\u0130': + return U"LATIN CAPITAL LETTER I WITH DOT ABOVE"; + case U'\u0131': + return U"LATIN SMALL LETTER DOTLESS I"; + case U'\u0132': + return U"LATIN CAPITAL LIGATURE IJ"; + case U'\u0133': + return U"LATIN SMALL LIGATURE IJ"; + case U'\u0134': + return U"LATIN CAPITAL LETTER J WITH CIRCUMFLEX"; + case U'\u0135': + return U"LATIN SMALL LETTER J WITH CIRCUMFLEX"; + case U'\u0136': + return U"LATIN CAPITAL LETTER K WITH CEDILLA"; + case U'\u0137': + return U"LATIN SMALL LETTER K WITH CEDILLA"; + case U'\u0138': + return U"LATIN SMALL LETTER KRA"; + case U'\u0139': + return U"LATIN CAPITAL LETTER L WITH ACUTE"; + case U'\u013A': + return U"LATIN SMALL LETTER L WITH ACUTE"; + case U'\u013B': + return U"LATIN CAPITAL LETTER L WITH CEDILLA"; + case U'\u013C': + return U"LATIN SMALL LETTER L WITH CEDILLA"; + case U'\u013D': + return U"LATIN CAPITAL LETTER L WITH CARON"; + case U'\u013E': + return U"LATIN SMALL LETTER L WITH CARON"; + case U'\u013F': + return U"LATIN CAPITAL LETTER L WITH MDDLE DOT"; + case U'\u0140': + return U"LATIN SMALL LETTER L WITH MIDDLE DOT"; + case U'\u0141': + return U"LATIN CAPITAL LETTER L WITH STROKE"; + case U'\u0142': + return U"LATIN SMALL LETTER L WITH STROKE"; + case U'\u0143': + return U"LATIN CAPITAL LETTER N WITH ACUTE"; + case U'\u0144': + return U"LATIN SMALL LETTER N WITH ACUTE"; + case U'\u0145': + return U"LATIN CAPITAL LETTER N WITH CEDILLA"; + case U'\u0146': + return U"LATIN SMALL LETTER N WITH CEDILLA"; + case U'\u0147': + return U"LATIN CAPITAL LETTER N WITH CARON"; + case U'\u0148': + return U"LATIN SMALL LETTER N WITH CARON"; + case U'\u0149': + return U"LATIN SMALL LETTER N PRECEDED BY APOSTROPHE"; + case U'\u014A': + return U"LATIN CAPITAL LETTER ENG"; + case U'\u014B': + return U"LATIN SMALL LETTER ENG"; + case U'\u014C': + return U"LATIN CAPITAL LETTER O WITH MACRON"; + case U'\u014D': + return U"LATIN SMALL LETTER O WITH MACRON"; + case U'\u014E': + return U"LATIN CAPITAL LETTER O WITH BREVE"; + case U'\u014F': + return U"LATIN SMALL LETTER O WITH BREVE"; + case U'\u0150': + return U"LATIN CAPITAL LETTER O WITH DOUBLE ACUTE"; + case U'\u0160': + return U"LATIN CAPITAL LETTER S WITH CARON"; + case U'\u0170': + return U"LATIN CAPITAL LETTER U WITH DOUBLE ACUTE"; + /* LATIN EXTENDED-B: */ + case U'\u0180': + return U"LATIN SMALL LETTER B WITH STROKE"; + case U'\u0190': + return U"LATIN CAPITAL LETTER OPEN E"; + case U'\u01A0': + return U"LATIN CAPITAL LETTER O WITH HORN"; + case U'\u01B0': + return U"LATIN SMALL LETTER U WITH HORN"; + case U'\u01C0': + return U"LATIN LETTER DENTAL CLICK"; + case U'\u01D0': + return U"LATIN SMALL LETTER I WITH CARON"; + case U'\u01E0': + return U"LATIN CAPITAL LETTER A WITH DOT ABOVE AND MACRON"; + case U'\u01F0': + return U"LATIN SMALL LETTER J WITH CARON"; + case U'\u0200': + return U"LATIN CAPITAL LETTER A WITH DOUBLE GRAVE"; + case U'\u0210': + return U"LATIN CAPITAL LETTER R WITH DOUBLE GRAVE"; + case U'\u0220': + return U"LATIN CAPITAL LETTER N WITH LONG RIGHT LEG"; + case U'\u0230': + return U"LATIN CAPITAL LETTER O WITH DOT ABOVE AND MACRON"; + case U'\u0240': + return U"LATIN SMALL LETTER Z WITH SWASH TAIL"; + /* IPA EXTENSIONS: */ + case U'\u0250': + return U"LATIN SMALL LETTER TURNED A"; + case U'\u0251': + return U"LATIN SMALL LETTER ALPHA"; + case U'\u0252': + return U"LATIN SMALL LETTER TURNED ALPHA"; + case U'\u0253': + return U"LATIN SMALL LETTER B WITH HOOK"; + case U'\u0254': + return U"LATIN SMALL LETTER OPEN O"; + case U'\u0255': + return U"LATIN SMALL LETTER C WITH CURL"; + case U'\u0256': + return U"LATIN SMALL LETTER D WITH TAIL"; + case U'\u0257': + return U"LATIN SMALL LETTER D WITH HOOK"; + case U'\u0258': + return U"LATIN SMALL LETTER REVERSED E"; + case U'\u0259': + return U"LATIN SMALL LETTER SCHWA"; + case U'\u025A': + return U"LATIN SMALL LETTER SCHWA WITH HOOK"; + case U'\u025B': + return U"LATIN SMALL LETTER OPEN E"; + case U'\u025C': + return U"LATIN SMALL LETTER REVERSED OPEN E"; + case U'\u025D': + return U"LATIN SMALL LETTER REVERSED OPEN E WITH HOOK"; + case U'\u025E': + return U"LATIN SMALL LETTER CLOSED REVERSED OPEN E"; + case U'\u025F': + return U"LATIN SMALL LETTER DOTLESS J WITH STROKE"; + case U'\u0260': + return U"LATIN SMALL LETTER G WITH HOOK"; + case U'\u0261': + return U"LATIN SMALL LETTER SCRIPT G"; + case U'\u0262': + return U"LATIN LETTER SMALL CAPITAL G"; + case U'\u0263': + return U"LATIN SMALL LETTER GAMMA"; + case U'\u0264': + return U"LATIN SMALL LETTER RAMS HORN"; + case U'\u0265': + return U"LATIN SMALL LETTER TURNED H"; + case U'\u0266': + return U"LATIN SMALL LETTER H WITH HOOK"; + case U'\u0267': + return U"LATIN SMALL LETTER HENG WITH HOOK"; + case U'\u0268': + return U"LATIN SMALL LETTER I WITH STROKE"; + case U'\u0269': + return U"LATIN SMALL LETTER IOTA"; + case U'\u026A': + return U"LATIN LETTER SMALL CAPITAL I"; + case U'\u026B': + return U"LATIN SMALL LETTER L WITH MIDDLE TILDE"; + case U'\u026C': + return U"LATIN SMALL LETTER L WITH BELT"; + case U'\u026D': + return U"LATIN SMALL LETTER L WITH RETROFLEX HOOK"; + case U'\u026E': + return U"LATIN SMALL LETTER LEZH"; + case U'\u026F': + return U"LATIN SMALL LETTER TURNED M"; + case U'\u0270': + return U"LATIN SMALL LETTER TURNED M WITH LONG LEG"; + case U'\u0271': + return U"LATIN SMALL LETTER M WITH HOOK"; + case U'\u0272': + return U"LATIN SMALL LETTER N WITH LEFT HOOK"; + case U'\u0273': + return U"LATIN SMALL LETTER N WITH RETROFLEX HOOK"; + case U'\u0274': + return U"LATIN LETTER SMALL CAPITAL N"; + case U'\u0275': + return U"LATIN SMALL LETTER BARRED O"; + case U'\u0276': + return U"LATIN LETTER SMALL CAPITAL OE"; + case U'\u0277': + return U"LATIN SMALL LETTER CLOSED OMEGA"; + case U'\u0278': + return U"LATIN SMALL LETTER PHI"; + case U'\u0279': + return U"LATIN SMALL LETTER TURNED R"; + case U'\u027A': + return U"LATIN SMALL LETTER TURNED R WITH LONG LEG"; + case U'\u027B': + return U"LATIN SMALL LETTER TURNED R WITH HOOK"; + case U'\u027C': + return U"LATIN SMALL LETTER R WITH LONG LEG"; + case U'\u027D': + return U"LATIN SMALL LETTER R WITH TAIL"; + case U'\u027E': + return U"LATIN SMALL LETTER R WITH FISHHOOK"; + case U'\u027F': + return U"LATIN SMALL LETTER REVERSED R WITH FISHHOOK"; + case U'\u0280': + return U"LATIN LETTER SMALL CAPITAL R"; + case U'\u0281': + return U"LATIN LETTER SMALL CAPITAL INVERTED R"; + case U'\u0282': + return U"LATIN SMALL LETTER S WITH HOOK"; + case U'\u0283': + return U"LATIN SMALL LETTER ESH"; + case U'\u0284': + return U"LATIN SMALL LETTER DOTLESS J WITH STROKE AND HOOK"; + case U'\u0285': + return U"LATIN SMALL LETTER SQUAT REVERSED ESH"; + case U'\u0286': + return U"LATIN SMALL LETTER SH WITH CURL"; + case U'\u0287': + return U"LATIN SMALL LETTER TURNED T"; + case U'\u0288': + return U"LATIN SMALL LETTER T WITH RETROFLEX HOOK"; + case U'\u0289': + return U"LATIN SMALL LETTER U BAR"; + case U'\u028A': + return U"LATIN SMALL LETTER UPSILON"; + case U'\u028B': + return U"LATIN SMALL LETTER V WTIH HOOK"; + case U'\u028C': + return U"LATIN SMALL LETTER TURNED V"; + case U'\u028D': + return U"LATIN SMALL LETTER TURNED W"; + case U'\u028E': + return U"LATIN SMALL LETTER TURNED Y"; + case U'\u028F': + return U"LATIN LETTER SMALL CAPITAL Y"; + case U'\u0290': + return U"LATIN SMALL LETTER Z WITH RETROFLEX HOOK"; + case U'\u0291': + return U"LATIN SMALL LETTER Z WITH RETROFLEX"; + case U'\u0292': + return U"LATIN SMALL LETTER EZH"; + case U'\u0293': + return U"LATIN SMALL LETTER EZH WITH CURL"; + case U'\u0294': + return U"LATIN LETTER GLOTTAL STOP"; + case U'\u0295': + return U"LATIN LETTER PHARYNGEAL VOICED FRICATIVE"; + case U'\u0296': + return U"LATIN LETTER INVERTED GLOTTAL STOP"; + case U'\u0297': + return U"LATIN LETTER STRETCHED C"; + case U'\u0298': + return U"LATIN LETTER BILABIAL CLICK"; + case U'\u0299': + return U"LATIN LETTER SMALL CAPITAL B"; + case U'\u029A': + return U"LATIN SMALL LETTER CLOSED OPEN E"; + case U'\u029B': + return U"LATIN LETTER SMALL CAPITAL G WITH HOOK"; + case U'\u029C': + return U"LATIN LETTER SMALL CAPITAL H"; + case U'\u029D': + return U"LATIN SMALL LETTER J WITH CROSSED-TAIL"; + case U'\u029E': + return U"LATIN SMALL LETTER TURNED K"; + case U'\u029F': + return U"LATIN LETTER SMALL CAPITAL L"; + case U'\u02A0': + return U"LATIN SMALL LETTER Q WITH HOOK"; + case U'\u02A1': + return U"LATIN LETTER GLOTTAL STOP WITH STROKE"; + case U'\u02A2': + return U"LATIN LETTER REVERSED GLOTTAL STOP WITH STROKE"; + case U'\u02A3': + return U"LATIN SMALL LETTER DZ DIGRAPH"; + case U'\u02A4': + return U"LATIN SMALL LETTER DEZH DIGRAPH"; + case U'\u02A5': + return U"LATIN SMALL LETTER DZ DIGRAPH WITH CURL"; + case U'\u02A6': + return U"LATIN SMALL LETTER TS DIGRAPH"; + case U'\u02A7': + return U"LATIN SMALL LETTER TESH DIGRAPH"; + case U'\u02A8': + return U"LATIN SMALL LETTER TC DIGRAPH WITH CURL"; + case U'\u02A9': + return U"LATIN SMALL LETTER FENG DIGRAPH"; + case U'\u02AA': + return U"LATIN SMALL LETTER LS DIGRAPH"; + case U'\u02AB': + return U"LATIN SMALL LETTER LZ DIGRAPH"; + case U'\u02AC': + return U"LATIN LETTER BILABIAL PERCUSSIVE"; + case U'\u02AD': + return U"LATIN LETTER BIDENTAL PERCUSSIVE"; + case U'\u02AE': + return U"LATIN SMALL LETTER TURNED H WITH FISHHOOK"; + case U'\u02AF': + return U"LATIN SMALL LETTER TURNED H WITH FISHHOOK AND TAIL"; + /* SPACING MODIFIER LETTERS: */ + case U'\u02B0': + return U"MODIFIER LETTER SMALL H"; + case U'\u02B1': + return U"MODIFIER LETTER SMALL H WITH HOOK"; + case U'\u02B2': + return U"MODIFIER LETTER SMALL J"; + case U'\u02B3': + return U"MODIFIER LETTER SMALL R"; + case U'\u02B4': + return U"MODIFIER LETTER SMALL TURNED R"; + case U'\u02B5': + return U"MODIFIER LETTER SMALL TURNED R WITH HOOK"; + case U'\u02B6': + return U"MODIFIER LETTER SMALL CAPITAL INVERTED R"; + case U'\u02B7': + return U"MODIFIER LETTER SMALL W"; + case U'\u02B8': + return U"MODIFIER LETTER SMALL Y"; + case U'\u02B9': + return U"MODIFIER LETTER PRIME"; + case U'\u02BA': + return U"MODIFIER LETTER DOUBLE PRIME"; + case U'\u02BB': + return U"MODIFIER LETTER TURNED COMMA"; + case U'\u02BC': + return U"MODIFIER LETTER APOSTROPHE"; + case U'\u02BD': + return U"MODIFIER LETTER REVERSED COMMA"; + case U'\u02BE': + return U"MODIFIER LETTER RIGHT HALF RING"; + case U'\u02BF': + return U"MODIFIER LETTER LEFT HALF RING"; + case U'\u02C0': + return U"MODIFIER LETTER GLOTTAL STOP"; + case U'\u02C1': + return U"MODIFIER LETTER REVERSED GLOTTAL STOP"; + case U'\u02C2': + return U"MODIFIER LETTER LEFT ARROWHEAD"; + case U'\u02C3': + return U"MODIFIER LETTER RIGHT ARROWHEAD"; + case U'\u02C4': + return U"MODIFIER LETTER UP ARROWHEAD"; + case U'\u02C5': + return U"MODIFIER LETTER DOWN ARROWHEAD"; + case U'\u02C6': + return U"MODIFIER LETTER CIRCUMFLEX"; + case U'\u02C7': + return U"CARON"; + case U'\u02C8': + return U"MODIFIER LETTER VERTICAL LINE"; + case U'\u02C9': + return U"MODIFIER LETTER MACRON"; + case U'\u02CA': + return U"MODIFIER LETTER ACUTE ACCENT"; + case U'\u02CB': + return U"MODIFIER LETTER GRAVE ACCENT"; + case U'\u02CC': + return U"MODIFIER LETTER LOW VERTICAL LINE"; + case U'\u02CD': + return U"MODIFIER LETTER LOW MACRON"; + case U'\u02CE': + return U"MODIFIER LETTER LOW GRAVE ACCENT"; + case U'\u02CF': + return U"MODIFIER LETTER LOW ACUTE ACCENT"; + case U'\u02D0': + return U"MODIFIER LETTER TRIANGULAR COLON"; + case U'\u02D1': + return U"MODIFIER LETTER HALF TRIANGULAR COLON"; + case U'\u02D2': + return U"MODIFIER LETTER CENTRED RIGHT HALF RING"; + case U'\u02D3': + return U"MODIFIER LETTER CENTRED LEFT HALF RING"; + case U'\u02D4': + return U"MODIFIER LETTER UP TACK"; + case U'\u02D5': + return U"MODIFIER LETTER DOWN TACK"; + case U'\u02D6': + return U"MODIFIER LETTER PLUS SIGN"; + case U'\u02D7': + return U"MODIFIER LETTER MINUS SIGN"; + case U'\u02D8': + return U"BREVE"; + case U'\u02D9': + return U"DOT ABOVE"; + case U'\u02DA': + return U"RING ABOVE"; + case U'\u02DB': + return U"OGONEK"; + case U'\u02DC': + return U"SMALL TILDE"; + case U'\u02DD': + return U"DOUBLE ACUTE ACCENT"; + case U'\u02DE': + return U"MODIFIER LETTER RHOTIC HOOK"; + case U'\u02DF': + return U"MODIFIER LETTER CROSS ACCENT"; + case U'\u02E0': + return U"MODIFIER LETTER SMALL GAMMA"; + case U'\u02E1': + return U"MODIFIER LETTER SMALL L"; + case U'\u02E2': + return U"MODIFIER LETTER SMALL S"; + case U'\u02E3': + return U"MODIFIER LETTER SMALL X"; + case U'\u02E4': + return U"MODIFIER LETTER SMALL REVERSED GLOTTAL STOP"; + case U'\u02E5': + return U"MODIFIER LETTER EXTRA-HIGH TONE BAR"; + case U'\u02E6': + return U"MODIFIER LETTER HIGH TONE BAR"; + case U'\u02E7': + return U"MODIFIER LETTER MID TONE BAR"; + case U'\u02E8': + return U"MODIFIER LETTER LOW TONE BAR"; + case U'\u02E9': + return U"MODIFIER LETTER EXTRA-LOW TONE BAR"; + case U'\u02EA': + return U"MODIFIER LETTER YIN DEPARTING TONE MARK"; + case U'\u02EB': + return U"MODIFIER LETTER YANG DEPARTING TONE MARK"; + case U'\u02EC': + return U"MODIFIER LETTER VOICING"; + case U'\u02ED': + return U"MODIFIER LETTER UNASPIRATED"; + case U'\u02EE': + return U"MODIFIER LETTER DOUBLE APOSTROPHE"; + case U'\u02EF': + return U"MODIFIER LETTER LOW DOWN ARROWHEAD"; + case U'\u02F0': + return U"MODIFIER LETTER LOW UP ARROWHEAD"; + case U'\u02F1': + return U"MODIFIER LETTER LOW LEFT ARROWHEAD"; + case U'\u02F2': + return U"MODIFIER LETTER LOW RIGHT ARROWHEAD"; + case U'\u02F3': + return U"MODIFIER LETTER LOW RING"; + case U'\u02F4': + return U"MODIFIER LETTER MIDDLE GRAVE ACCENT"; + case U'\u02F5': + return U"MODIFIER LETTER MIDDLE DOUBLE GRAVE ACCENT"; + case U'\u02F6': + return U"MODIFIER LETTER MIDDLE DOUBLE ACUTE ACCENT"; + case U'\u02F7': + return U"MODIFIER LETTER LOW TILDE"; + case U'\u02F8': + return U"MODIFIER LETTER RAISED COLON"; + case U'\u02F9': + return U"MODIFIER LETTER BEGIN HIGH TONE"; + case U'\u02FA': + return U"MODIFIER LETTER END HIGH TONE"; + case U'\u02FB': + return U"MODIFIER LETTER BEGIN LOW TONE"; + case U'\u02FC': + return U"MODIFIER LETTER END LOW TONE"; + case U'\u02FD': + return U"MODIFIER LETTER SHELF"; + case U'\u02FE': + return U"MODIFIER LETTER OPEN SHELF"; + case U'\u02FF': + return U"MODIFIER LETTER LOW LEFT ARROWHEAD"; + /* COMBINING DIACRITICAL MARKS: */ + case U'\u0300': + return U"COMBINING GRAVE ACCENT"; + case U'\u0301': + return U"COMBINING ACUTE ACCENT"; + case U'\u0302': + return U"COMBINING CIRCUMFLEX ACCENT"; + case U'\u0303': + return U"COMBINING TILDE"; + case U'\u0304': + return U"COMBINING MACRON"; + case U'\u0305': + return U"COMBINING OVERLINE"; + case U'\u0306': + return U"COMBINING BREVE"; + case U'\u0307': + return U"COMBINING DOT ABOVE"; + case U'\u0308': + return U"COMBINING DIAERESIS"; + case U'\u0309': + return U"COMBINING HOOK ABOVE"; + case U'\u030A': + return U"COMBINING RING ABOVE"; + case U'\u030B': + return U"COMBINING DOUBLE ACUTE ACCENT"; + case U'\u030C': + return U"COMBINING CARON"; + case U'\u030D': + return U"COMBINING VERTICAL LINE ABOVE"; + case U'\u030E': + return U"COMBINING DOUBLE VERTICAL LINE ABOVE"; + case U'\u030F': + return U"COMBINING DOUBLE GRAVE ACCENT"; + case U'\u0310': + return U"COMBINING CANDRABINDU"; + case U'\u0311': + return U"COMBINING INVERTED BREVE"; + case U'\u0312': + return U"COMBINING TURNED COMMA ABOVE"; + case U'\u0313': + return U"COMBINING COMMA ABOVE"; + case U'\u0314': + return U"COMBINING REVERSED COMMA ABOVE"; + case U'\u0315': + return U"COMBINING COMMA ABOVE RIGHT"; + case U'\u0316': + return U"COMBINING GRAVE ACCENT BELOW"; + case U'\u0317': + return U"COMBINING ACUTE ACCENT BELOW"; + case U'\u0318': + return U"COMBINING LEFT TACK BELOW"; + case U'\u0319': + return U"COMBINING RIGHT TACK BELOW"; + case U'\u031A': + return U"COMBINING LEFT ANGLE ABOVE"; + case U'\u031B': + return U"COMBINING HORN"; + case U'\u031C': + return U"COMBINING LEFT HALF RING BELOW"; + case U'\u031D': + return U"COMBINING UP TACK BELOW"; + case U'\u031E': + return U"COMBINING DOWN TACK BELOW"; + case U'\u031F': + return U"COMBINING PLUS SIGN BELOW"; + case U'\u0320': + return U"COMBINING MINUS SIGN BELOW"; + case U'\u0321': + return U"COMBINING PALATALIZED HOOK BELOW"; + case U'\u0322': + return U"COMBINING RETROFLEX HOOK BELOW"; + case U'\u0323': + return U"COMBINING DOT BELOW"; + case U'\u0324': + return U"COMBINING DIAERESIS BELOW"; + case U'\u0325': + return U"COMBINING RING BELOW"; + case U'\u0326': + return U"COMBINING COMMA BELOW"; + case U'\u0327': + return U"COMBINING CEDILLA"; + case U'\u0328': + return U"COMBINING OGONEK"; + case U'\u0329': + return U"COMBINING VERTICAL LINE BELOW"; + case U'\u032A': + return U"COMBINING BRDIGE BELOW"; + case U'\u032B': + return U"COMBINING INVERTED DOUBLE ARCH BELOW"; + case U'\u032C': + return U"COMBINING CARON BELOW"; + case U'\u032D': + return U"COMBINING CIRCUMFLEX ACCENT BELOW"; + case U'\u032E': + return U"COMBINING BREVE BELOW"; + case U'\u032F': + return U"COMBINING INVERTED BREVE BELOW"; + case U'\u0330': + return U"COMBINING TILDE BELOW"; + case U'\u0331': + return U"COMBINING MACRON BELOW"; + case U'\u0332': + return U"COMBINING LOW LINE"; + case U'\u0333': + return U"COMBINING DOUBLE LOW LINE"; + case U'\u0334': + return U"COMBINING TILDE OVERLAY"; + case U'\u0335': + return U"COMBINING SHORT STROKE OVERLAY"; + case U'\u0336': + return U"COMBINING LONG STROKE OVERLAY"; + case U'\u0337': + return U"COMBINING SHORT SOLIDUS OVERLAY"; + case U'\u0338': + return U"COMBINING LONG SOLIDUS OVERLAY"; + case U'\u0339': + return U"COMBINING RIGHT HALF RING BELOW"; + case U'\u033A': + return U"COMBINING INVERTED BRIDGE BELOW"; + case U'\u033B': + return U"COMBINING SQUARE BELOW"; + case U'\u033C': + return U"COMBINING SEAGULL BELOW"; + case U'\u033D': + return U"COMBINING X ABOVE"; + case U'\u033E': + return U"COMBINING VERTICAL TILDE"; + case U'\u033F': + return U"COMBINING DOUBLE OVERLINE"; + case U'\u0340': + return U"COMBINING GRAVE TONE MARK"; + case U'\u0341': + return U"COMBINING ACUTE TONE MARK"; + case U'\u0342': + return U"COMBINING GREEK PERISPOMENI"; + case U'\u0343': + return U"COMBINING GREEK KORONIS"; + case U'\u0344': + return U"COMBINING GREEK DIALYTIKA TONOS"; + case U'\u0345': + return U"COMBINING GREEK YPOGEGRAMMENI"; + case U'\u0346': + return U"COMBINING BRIDGE ABOVE"; + case U'\u0347': + return U"COMBINING EQUALS SIGN BELOW"; + case U'\u0348': + return U"COMBINING DOUBLE VERTICAL LINE BELOW"; + case U'\u0349': + return U"COMBINING LEFT ANGLE BELOW"; + case U'\u034A': + return U"COMBINING NOT TILDE ABOVE"; + case U'\u034B': + return U"COMBINING HOMOTHETIC ABOVE"; + case U'\u034C': + return U"COMBINING ALMOST EQUAL TO ABOVE"; + case U'\u034D': + return U"COMBINING LEFT RIGHT ARROW BELOW"; + case U'\u034E': + return U"COMBINING UPWARDS ARROW BELOW"; + case U'\u034F': + return U"COMBINING GRAPHEME JOINER"; + case U'\u0350': + return U"COMBINING RIGHT ARROWHEAD ABOVE"; + case U'\u0351': + return U"COMBINING LEFT HALF RING ABOVE"; + case U'\u0352': + return U"COMBINING FERMATA"; + case U'\u0353': + return U"COMBINING X BELOW"; + case U'\u0354': + return U"COMBINING LEFT ARROWHEAD BELOW"; + case U'\u0355': + return U"COMBINING RIGHT ARROWHEAD BELOW"; + case U'\u0356': + return U"COMBINING RIGHT ARROWHEAD AND UP ARROWHEAD BELOW"; + case U'\u0357': + return U"COMBINING RIGHT HALF RING ABOVE"; + case U'\u0358': + return U"COMBINING DOT ABOVE RIGHT"; + case U'\u0359': + return U"COMBINING ASTERISK BELOW"; + case U'\u035A': + return U"COMBINING DOUBLE RING BELOW"; + case U'\u035B': + return U"COMBINING ZIGZAG ABOVE"; + case U'\u035C': + return U"COMBINING DOUBLE BREVE BELOW"; + case U'\u035D': + return U"COMBINING DOUBLE BREVE"; + case U'\u035E': + return U"COMBINING DOUBLE MACRON"; + case U'\u035F': + return U"COMBINING DOUBLE MACRON BELOW"; + case U'\u0360': + return U"COMBINING DOUBLE TILDE"; + case U'\u0361': + return U"COMBINING DOUBLE INVERTED BREVE"; + case U'\u0362': + return U"COMBINING DOUBLE RIGHTWARDS ARROW BELOW"; + case U'\u0363': + return U"COMBINING LATIN SMALL LETTER A"; + case U'\u0364': + return U"COMBINING LATIN SMALL LETTER E"; + case U'\u0365': + return U"COMBINING LATIN SMALL LETTER I"; + case U'\u0366': + return U"COMBINING LATIN SMALL LETTER O"; + case U'\u0367': + return U"COMBINING LATIN SMALL LETTER U"; + case U'\u0368': + return U"COMBINING LATIN SMALL LETTER C"; + case U'\u0369': + return U"COMBINING LATIN SMALL LETTER D"; + case U'\u036A': + return U"COMBINING LATIN SMALL LETTER H"; + case U'\u036B': + return U"COMBINING LATIN SMALL LETTER M"; + case U'\u036C': + return U"COMBINING LATIN SMALL LETTER R"; + case U'\u036D': + return U"COMBINING LATIN SMALL LETTER T"; + case U'\u036E': + return U"COMBINING LATIN SMALL LETTER V"; + case U'\u036F': + return U"COMBINING LATIN SMALL LETTER X"; + /* GREEK AND COPTIC: */ + case U'\u0370': + return U"GREEK CAPITAL LETTER HETA"; + case U'\u0371': + return U"GREEK SMALL LETTER HETA"; + case U'\u0372': + return U"GREEK CAPITAL LETTER ARCHAIC SAMPI"; + case U'\u0373': + return U"GREEK SMALL LETTER ARCHAIC SAMPI"; + case U'\u0374': + return U"GREEK NUMERAL SIGN"; + case U'\u0375': + return U"GREEK LOWER NUMERAL SIGN"; + case U'\u0376': + return U"GREEK CAPITAL LETTER PAMPHYLIAN DIGAMMA"; + case U'\u0377': + return U"GREEK SMALL LETTER PAMPHYLIAN DIGAMMA"; + case U'\u037A': + return U"GREEK YPOGEGRAMMENI"; + case U'\u037B': + return U"GREEK SMALL REVERSED LUNATE SIGMA SYMBOL"; + case U'\u037C': + return U"GREEK SMALL DOTTED LUNATE SIGMA SYMBOL"; + case U'\u037D': + return U"GREEK SMALL REVERSED DOTTED LUNATE SIGMAL SYMBOL"; + case U'\u037E': + return U"GREEK QUESTION MARK"; + case U'\u037F': + return U"GREEK CAPITAL LETTER YOT"; + case U'\u0384': + return U"GREEK TONOS"; + case U'\u0385': + return U"GREEK DIALYTIKA TONOS"; + case U'\u0386': + return U"GREEK CAPITAL LETTER ALPHA WITH TONOS"; + case U'\u0387': + return U"GREEK ANO TELEIA"; + case U'\u0388': + return U"GREEK CAPITAL LETTER EPSILON WITH TONOS"; + case U'\u0389': + return U"GREEK CAPITAL LETTER ETA WITH TONOS"; + case U'\u038A': + return U"GREEK CAPITAL LETTER IOTA WITH TONOS"; + case U'\u038C': + return U"GREEK CAPITAL LETTER OMICRON WITH TONOS"; + case U'\u038E': + return U"GREEK CAPITAL LETTER USPILON WITH TONOS"; + case U'\u038F': + return U"GREEK CAPITAL LETTER OMEGA WITH TONOS"; + case U'\u0390': + return U"GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS"; + case U'\u0391': + return U"GREEK CAPITAL LETTER ALPHA"; + case U'\u0392': + return U"GREEK CAPITAL LETTER BETA"; + case U'\u0393': + return U"GREEK CAPITAL LETTER GAMMA"; + case U'\u0394': + return U"GREEK CAPITAL LETTER DELTA"; + case U'\u0395': + return U"GREEK CAPITAL LETTER EPSILON"; + case U'\u0396': + return U"GREEK CAPITAL LETTER ZETA"; + case U'\u0397': + return U"GREEK CAPITAL LETTER ETA"; + case U'\u0398': + return U"GREEK CAPITAL LETTER THETA"; + case U'\u0399': + return U"GREEK CAPITAL LETTER IOTA"; + case U'\u039A': + return U"GREEK CAPITAL LETTER KAPPA"; + case U'\u039B': + return U"GREEK CAPITAL LETTER LAMBDA"; + case U'\u039C': + return U"GREEK CAPITAL LETTER MU"; + case U'\u039D': + return U"GREEK CAPITAL LETTER NU"; + case U'\u039E': + return U"GREEK CAPITAL LETTER XI"; + case U'\u039F': + return U"GREEK CAPITAL LETTER OMICRON"; + case U'\u03A0': + return U"GREEK CAPITAL LETTER PI"; + case U'\u03A1': + return U"GREEK CAPITAL LETTER RHO"; + case U'\u03A3': + return U"GREEK CAPITAL LETTER SIGMA"; + case U'\u03A4': + return U"GREEK CAPITAL LETTER TAU"; + case U'\u03A5': + return U"GREEK CAPITAL LETTER UPSILON"; + case U'\u03A6': + return U"GREEK CAPITAL LETTER PHI"; + case U'\u03A7': + return U"GREEK CAPITAL LETTER CHI"; + case U'\u03A8': + return U"GREEK CAPITAL LETTER PSI"; + case U'\u03A9': + return U"GREEK CAPITAL LETTER OMEGA"; + case U'\u03AA': + return U"GREEK CAPITAL LETTER IOTA WITH DIALYTIKA"; + case U'\u03AB': + return U"GREEK CAPITAL LETTER UPSILON WITH DIALYTIKA"; + case U'\u03AC': + return U"GREEK SMALL LETTER ALPHA WITH TONOS"; + case U'\u03AD': + return U"GREEK SMALL LETTER EPSILON WITH TONOS"; + case U'\u03AE': + return U"GREEK SMALL LETTER ETA WITH TONOS"; + case U'\u03AF': + return U"GREEK SMALL LETTER IOTA WITH TONOS"; + case U'\u03B0': + return U"GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS"; + case U'\u03B1': + return U"GREEK SMALL LETTER ALPHA"; + case U'\u03B2': + return U"GREEK SMALL LETTER BETA"; + case U'\u03B3': + return U"GREEK SMALL LETTER GAMMA"; + case U'\u03B4': + return U"GREEK SMALL LETTER DELTA"; + case U'\u03B5': + return U"GREEK SMALL LETTER EPSILON"; + case U'\u03B6': + return U"GREEK SMALL LETTER ZETA"; + case U'\u03B7': + return U"GREEK SMALL LETTER ETA"; + case U'\u03B8': + return U"GREEK SMALL LETTER THETA"; + case U'\u03B9': + return U"GREEK SMALL LETTER IOTA"; + case U'\u03BA': + return U"GREEK SMALL LETTER KAPPA"; + case U'\u03BB': + return U"GREEK SMALL LETTER LAMBDA"; + case U'\u03BC': + return U"GREEK SMALL LETTER MU"; + case U'\u03BD': + return U"GREEK SMALL LETTER NU"; + case U'\u03BE': + return U"GREEK SMALL LETTER XI"; + case U'\u03BF': + return U"GREEK SMALL LETTER OMICRON"; + case U'\u03C0': + return U"GREEK SMALL LETTER PI"; + case U'\u03C1': + return U"GREEK SMALL LETTER RHO"; + case U'\u03C2': + return U"GREEK SMALL LETTER FINAL SIGMA"; + case U'\u03C3': + return U"GREEK SMALL LETTER SIGMA"; + case U'\u03C4': + return U"GREEK SMALL LETTER TAU"; + case U'\u03C5': + return U"GREEK SMALL LETTER UPSILON"; + case U'\u03C6': + return U"GREEK SMALL LETTER PHI"; + case U'\u03C7': + return U"GREEK SMALL LETTER CHI"; + case U'\u03C8': + return U"GREEK SMALL LETTER PSI"; + case U'\u03C9': + return U"GREEK SMALL LETTER OMEGA"; + case U'\u03CA': + return U"GREEK SMALL LETTER IOTA WITH DIALYTIKA"; + case U'\u03CB': + return U"GREEK SMALL LETTER UPSILON WITH DIALYTIKA"; + case U'\u03CC': + return U"GREEK SMALL LETTER OMICRON WITH TONOS"; + case U'\u03CD': + return U"GREEK SMALL LETTER UPSILON WITH TONOS"; + case U'\u03CE': + return U"GREEK SMALL LETTER OMEGA WITH TONOS"; + case U'\u03CF': + return U"GREEK CAPITAL KAI SYMBOL"; + case U'\u03D0': + return U"GREEK BETA SYMBOL"; + case U'\u03D1': + return U"GREEK THETA SYMBOL"; + case U'\u03D2': + return U"GREEK UPSILON WITH HOOK SYMBOL"; + case U'\u03D3': + return U"GREEK UPSILON WITH ACUTE AND HOOK SYMBOL"; + case U'\u03D4': + return U"GREEK UPSILON WITH DIAERESIS AND HOOK SYMBOL"; + case U'\u03D5': + return U"GREEK PHI SYMBOL"; + case U'\u03D6': + return U"GREEK PI SYMBOL"; + case U'\u03D7': + return U"GREEK KAI SYMBOL"; + case U'\u03D8': + return U"GREEK LETTER ARCHAIC KOPPA"; + case U'\u03D9': + return U"GREEK SMALL LETTER ARCHAIC KOPPA"; + case U'\u03DA': + return U"GREEK LETTER STIGMA"; + case U'\u03DB': + return U"GREEK SMALL LETTER STIGMA"; + case U'\u03DC': + return U"GREEK LETTER DIGAMMA"; + case U'\u03DD': + return U"GREEK SMALL LETTER DIGAMMA"; + case U'\u03DE': + return U"GREEK LETTER KOPPA"; + case U'\u03DF': + return U"GREEK SMALL LETTER KOPPA"; + case U'\u03E0': + return U"GREEK LETTER SAMPI"; + case U'\u03F0': + return U"GREEK KAPPA SYMBOL"; + /* HEBREW: */ + case U'\u05D0': + return U"HEBREW LETTER ALEF"; + case U'\u05D1': + return U"HEBREW LETTER BET"; + case U'\u05D2': + return U"HEBREW LETTER GIMEL"; + case U'\u05D3': + return U"HEBREW LETTER DALET"; + case U'\u05D4': + return U"HEBREW LETTER HE"; + case U'\u05D5': + return U"HEBREW LETTER VAV"; + case U'\u05D6': + return U"HEBREW LETTER ZAYIN"; + case U'\u05D7': + return U"HEBREW LETTER HET"; + case U'\u05D8': + return U"HEBREW LETTER TET"; + case U'\u05D9': + return U"HEBREW LETTER YOD"; + case U'\u05DA': + return U"HEBREW LETTER FINAL KAF"; + case U'\u05DB': + return U"HEBREW LETTER KAF"; + case U'\u05DC': + return U"HEBREW LETTER LAMED"; + case U'\u05DD': + return U"HEBREW LETTER FINAL MEM"; + case U'\u05DE': + return U"HEBREW LETTER MEM"; + case U'\u05DF': + return U"HEBREW LETTER FINAL NUN"; + case U'\u05E0': + return U"HEBREW LETTER NUN"; + case U'\u05E1': + return U"HEBREW LETTER SAMEKH"; + case U'\u05E2': + return U"HEBREW LETTER AYIN"; + case U'\u05E3': + return U"HEBREW LETTER FINAL PE"; + case U'\u05E4': + return U"HEBREW LETTER PE"; + case U'\u05E5': + return U"HEBREW LETTER FINAL TSADI"; + case U'\u05E6': + return U"HEBREW LETTER TSADI"; + case U'\u05E7': + return U"HEBREW LETTER QOF"; + case U'\u05E8': + return U"HEBREW LETTER RESH"; + case U'\u05E9': + return U"HEBREW LETTER SHIN"; + case U'\u05EA': + return U"HEBREW LETTER TAV"; + case U'\u05EF': + return U"HEBREW YOD TRIANGLE"; + /* CYRILLIC: */ + case U'\u0400': + return U"CYRILLIC CAPITAL LETTER LE WITH GRAVE"; + case U'\u0401': + return U"CYRILLIC CAPITAL LETTER LO"; + case U'\u0402': + return U"CYRILLIC CAPITAL LETTER DJE"; + case U'\u0403': + return U"CYRILLIC CAPITAL LETTER GJE"; + case U'\u0404': + return U"CYRILLIC CAPITAL LETTER UKRAINIAN LE"; + case U'\u0405': + return U"CYRILLIC CAPITAL LETTER DZE"; + case U'\u0406': + return U"CYRILLIC CAPITAL LETTER BYELORUSSIAN-UKRAINIAN I"; + case U'\u0407': + return U"CYRILLIC CAPITAL LETTER YI"; + case U'\u0408': + return U"CYRILLIC CAPITAL LETTER JE"; + case U'\u0409': + return U"CYRILLIC CAPITAL LETTER LJE"; + case U'\u040A': + return U"CYRILLIC CAPITAL LETTER NJE"; + case U'\u040B': + return U"CYRILLIC CAPITAL LETTER TSHE"; + case U'\u040C': + return U"CYRILLIC CAPITAL LETTER KJE"; + case U'\u040D': + return U"CYRILLIC CAPITAL LETTER I WITH GRAVE"; + case U'\u040E': + return U"CYRILLIC CAPITAL LETTER SHORT U"; + case U'\u040F': + return U"CYRILLIC CAPITAL LETTER DZHE"; + case U'\u0410': + return U"CYRILLIC CAPITAL LETTER A"; + case U'\u0420': + return U"CYRILLIC CAPITAL LETTER ER"; + case U'\u0430': + return U"CYRILLIC SMALL LETTER A"; + case U'\u0440': + return U"CYRILLIC SMALL LETTER ER"; + case U'\u0450': + return U"CYRILLIC SMALL LETTER LE WITH GRAVE"; + case U'\u0460': + return U"CYRILLIC CAPITAL LETTER OMEGA"; + case U'\u0470': + return U"CYRILLIC CAPITAL LETTER PSI"; + case U'\u0480': + return U"CYRILLIC CAPITAL LETTER KOPPA"; + case U'\u0490': + return U"CYRILLIC CAPITAL LETTER GHE WITH UPTURN"; + case U'\u04A0': + return U"CYRILLIC CAPITAL LETTER BASHKIR KA"; + case U'\u04B0': + return U"CYRILLIC CAPITAL LETTER STRAIGHT U WITH STROKE"; + case U'\u04C0': + return U"CYRILLIC LETTER PALOCHKA"; + case U'\u04D0': + return U"CYRILLIC CAPITAL LETTER A WITH BREVE"; + case U'\u04E0': + return U"CYRILLIC CAPITAL LETTER ABKHASIAN DZE"; + case U'\u04F0': + return U"CYRILLIC CAPITAL LETTER U WITH DIAERESIS"; + /* SYRIAC SUPPLEMENT: */ + case U'\u0860': + return U"SYRIAC LETTER MALAYALAM NGA"; + case U'\u0861': + return U"SYRIAC LETTER MALAYALAM JA"; + case U'\u0862': + return U"SYRIAC LETTER MALAYALAM NYA"; + case U'\u0863': + return U"SYRIAC LETTER MALAYALAM TTA"; + case U'\u0864': + return U"SYRIAC LETTER MALAYALAM NNA"; + case U'\u0865': + return U"SYRIAC LETTER MALAYALAM NNNA"; + case U'\u0866': + return U"SYRIAC LETTER MALAYALAM BHA"; + case U'\u0867': + return U"SYRIAC LETTER MALAYALAM RA"; + case U'\u0868': + return U"SYRIAC LETTER MALAYALAM LLA"; + case U'\u0869': + return U"SYRIAC LETTER MALAYALAM LLLA"; + case U'\u086A': + return U"SYRIAC LETTER MALAYALAM SSA"; + /* RUNIC: */ + case U'\u16A0': + return U"RUNIC LETTER FEHU FEOH FE F"; + case U'\u16A1': + return U"RUNIC LETTER V"; + case U'\u16A2': + return U"RUNIC LETTER URUZ UR U"; + case U'\u16A3': + return U"RUNIC LETTER YR"; + case U'\u16A4': + return U"RUNIC LETTER Y"; + case U'\u16A5': + return U"RUNIC LETTER W"; + case U'\u16A6': + return U"RUNIC LETTER THURISAZ THURS THORN"; + case U'\u16A7': + return U"RUNIC LETTER ETH"; + case U'\u16A8': + return U"RUNIC LETTER ANSUZ A"; + case U'\u16A9': + return U"RUNIC LETTER OS O"; + case U'\u16AA': + return U"RUNIC LETTER AC A"; + case U'\u16AB': + return U"RUNIC LETTER AESC"; + case U'\u16AC': + return U"RUNIC LETTER LONG-BRANCHED-OSS O"; + case U'\u16AD': + return U"RUNIC LETTER SHORT-TWIG-OSS O"; + case U'\u16AE': + return U"RUNIC LETTER O"; + case U'\u16AF': + return U"RUNIC LETTER OE"; + case U'\u16B0': + return U"RUNIC LETTER ON"; + case U'\u16C0': + return U"RUNIC LETTER DOTTED-N"; + case U'\u16D0': + return U"RUNIC LETTER SHORT-TWIG-TYR T"; + case U'\u16E0': + return U"RUNIC LETTER EAR"; + case U'\u16F0': + return U"RUNIC BELGTHOR SYMBOL"; + /* CYRILLIC EXTENDED C: */ + case U'\u1C80': + return U"CYRILLIC SMALL LETTER ROUNDED VE"; + case U'\u1C81': + return U"CYRILLIC SMALL LETTER LONG-LEGGED DE"; + case U'\u1C82': + return U"CYRILLIC SMALL LETTER NARROW O"; + case U'\u1C83': + return U"CYRILLIC SMALL LETTER WIDE ES"; + case U'\u1C84': + return U"CYRILLIC SMALL LETTER TALL TE"; + case U'\u1C85': + return U"CYRILLIC SMALL LETTER THREE-LEGGED TE"; + case U'\u1C86': + return U"CYRILLIC SMALL LETTER TALL HARD SIGN"; + case U'\u1C87': + return U"CYRILLIC SMALL LETTER TALL YAT"; + case U'\u1C88': + return U"CYRILLIC SMALL LETTER UNBLENDED UK"; + /* GENERAL PUNCTUATION: */ + case U'\u2000': + return U"EN QUAD"; + case U'\u2001': + return U"EM QUAD"; + case U'\u2002': + return U"EN SPACE"; + case U'\u2003': + return U"EM SPACE"; + case U'\u2004': + return U"THREE-PER-EM SPACE"; + case U'\u2005': + return U"FOUR-PER-EM SPACE"; + case U'\u2006': + return U"SIX-PER-EM SPACE"; + case U'\u2007': + return U"FIGURE SPACE"; + case U'\u2008': + return U"PUNCTUATION SPACE"; + case U'\u2009': + return U"THIN SPACE"; + case U'\u200A': + return U"HAIR SPACE"; + case U'\u203C': + return U"DOUBLE EXCLAMATION MARK"; + case U'\u2047': + return U"DOUBLE QUOTATION MARK"; + case U'\u2048': + return U"QUESTION EXCLAMATION MARK"; + case U'\u2049': + return U"EXCLAMATION QUESTION MARK"; + /* CURRENCY SYMBOLS: */ + case U'\u20A0': + return U"EURO-CURRENCY SIGN"; + case U'\u20A1': + return U"COLON SIGN"; + case U'\u20A2': + return U"CRUZEIRO SIGN"; + case U'\u20A3': + return U"FRENCH FRANC SIGN"; + case U'\u20A4': + return U"LIRA SIGN"; + case U'\u20A5': + return U"MILL SIGN"; + case U'\u20A6': + return U"NAIRA SIGN"; + case U'\u20A7': + return U"PESETA SIGN"; + case U'\u20A8': + return U"RUPEE SIGN"; + case U'\u20A9': + return U"WON SIGN"; + case U'\u20AA': + return U"NEW SHEQEL SIGN"; + case U'\u20AB': + return U"DONG SIGN"; + case U'\u20AC': + return U"EURO SIGN"; + case U'\u20AD': + return U"KIP SIGN"; + case U'\u20AE': + return U"TUGRIK SIGN"; + case U'\u20AF': + return U"DRACHMA SIGN"; + case U'\u20B0': + return U"GERMAN PENNY SIGN"; + case U'\u20B1': + return U"PESO SIGN"; + case U'\u20B2': + return U"GUARANI SIGN"; + case U'\u20B3': + return U"AUSTRAL SIGN"; + case U'\u20B4': + return U"HRYVNIA SIGN"; + case U'\u20B5': + return U"CEDI SIGN"; + case U'\u20B6': + return U"LIVRE TOURNOIS SIGN"; + case U'\u20B7': + return U"SPESMILO SIGN"; + case U'\u20B8': + return U"TENGE SIGN"; + case U'\u20BA': + return U"TURKISH LIRA SIGN"; + case U'\u20BB': + return U"NORDIC MARK SIGN"; + case U'\u20BC': + return U"MANAT SIGN"; + case U'\u20BD': + return U"RUBLE SYMBOL"; + case U'\u20BE': + return U"LARI SIGN"; + case U'\u20BF': + return U"BITCOIN SIGN"; + /* LETTERLIKE SYMBOLS: */ + case U'\u2100': + return U"ACCOUNT OF"; + case U'\u2101': + return U"ADRESSED TO THE SUBJECT"; + case U'\u2102': + return U"DOUBLE-STRUCK CAPITAL C"; + case U'\u2103': + return U"DEGREE CELSIUS"; + case U'\u2104': + return U"CENTRE LINE SYMBOL"; + case U'\u2105': + return U"CARE OF"; + case U'\u2106': + return U"CADA UNA"; + case U'\u2107': + return U"EULER CONSTANT"; + case U'\u2108': + return U"SCRUPLE"; + case U'\u2109': + return U"DEGREE FAHRENHEIT"; + case U'\u210A': + return U"SCRIPT SMALL G"; + case U'\u210B': + return U"SCRIPT CAPITAL H"; + case U'\u210C': + return U"BLACK-LETTER CAPITAL H"; + case U'\u210D': + return U"DOUBLE-STRUCK CAPITAL H"; + case U'\u210E': + return U"PLANCK CONSTANT"; + case U'\u210F': + return U"PLANCK CONSTANT OVER TWO PI"; + case U'\u2110': + return U"SCRIPT CAPITAL I"; + case U'\u2111': + return U"BLACK-LETTER CAPITAL I"; + case U'\u2112': + return U"SCRIPT CAPITAL L"; + case U'\u2113': + return U"SCRIPT SMALL L"; + case U'\u2114': + return U"L B BAR SYMBOL"; + case U'\u2115': + return U"DOUBLE-STRUCK CAPITAL N"; + case U'\u2116': + return U"NUMERO SIGN"; + case U'\u2117': + return U"SOUND RECORDING COPYRIGHT"; + case U'\u2118': + return U"SCRIPT CAPITAL P"; + case U'\u2119': + return U"DOUBLE-STRUCK CAPITAL P"; + case U'\u211A': + return U"DOUBLE-STRUCK CAPITAL Q"; + case U'\u211B': + return U"SCRIPT CAPITAL R"; + case U'\u211C': + return U"BLACK-LETTER CAPITAL R"; + case U'\u211D': + return U"DOUBLE-STRUCK CAPITAL R"; + case U'\u211E': + return U"PRESCRIPTION TAKE"; + case U'\u211F': + return U"RESPONSE"; + case U'\u2120': + return U"SERVICE MARK"; + case U'\u2121': + return U"TELEPHONE SIGN"; + case U'\u2122': + return U"TRADE MARK SIGN"; + case U'\u2123': + return U"VERSICLE"; + case U'\u2124': + return U"DOUBLE-STRUCK CAPITAL Z"; + case U'\u2125': + return U"OUNCE SIGN"; + case U'\u2126': + return U"OHM SIGN"; + case U'\u2127': + return U"INVERTED OHM SIGN"; + case U'\u2128': + return U"BLACK-LETTER CAPITAL Z"; + case U'\u2129': + return U"TURNED GREEK SMALL LETTER IOTA"; + case U'\u212A': + return U"KELVIN SIGN"; + case U'\u212B': + return U"ANGSTROM SIGN"; + case U'\u212C': + return U"SCRIPT CAPITAL B"; + case U'\u212D': + return U"BLACK-LETTER CAPITAL C"; + case U'\u212E': + return U"ESTIMATED SYMBOL"; + case U'\u212F': + return U"SCRIPT SMALL E"; + case U'\u2130': + return U"SCRIPT CAPITAL E"; + case U'\u2131': + return U"SCRIPT CAPITAL F"; + case U'\u2132': + return U"TURNED CAPITAL F"; + case U'\u2133': + return U"SCRIPT CAPITAL M"; + case U'\u2134': + return U"SCRIPT SMALL O"; + case U'\u2135': + return U"ALEF SYMBOL"; + case U'\u2136': + return U"BET SYMBOL"; + case U'\u2137': + return U"GIMEL SYMBOL"; + case U'\u2138': + return U"DALET SYMBOL"; + case U'\u2139': + return U"INFORMATION SOURCE"; + case U'\u213A': + return U"ROTATED CAPITAL Q"; + case U'\u213B': + return U"FACSIMILE SIGN"; + case U'\u213C': + return U"DOUBLE-STRUCK SMALL PI"; + case U'\u213D': + return U"DOUBLE-STRUCK SMALL GAMMA"; + case U'\u213E': + return U"DOUBLE-STRUCK CAPITAL GAMMA"; + case U'\u213F': + return U"DOUBLE-STRUCK CAPITAL PI"; + case U'\u2140': + return U"DOUBLE-STRUCK N-ARY SUMMATION"; + case U'\u2141': + return U"TURNED SANS-SERIF CAPITAL G"; + case U'\u2142': + return U"TURNED SANS-SERIF CAPITAL L"; + case U'\u2143': + return U"REVERSED SANS-SERIF CAPITAL L"; + case U'\u2144': + return U"TURNED SANS-SERIF CAPITAL Y"; + case U'\u2145': + return U"DOUBLE-STRUCK ITALIC CAPITAL D"; + case U'\u2146': + return U"DOUBLE-STRUCK ITALIC SMALL D"; + case U'\u2147': + return U"DOUBLE-STRUCK ITALIC SMALL E"; + case U'\u2148': + return U"DOUBLE-STRUCK ITALIC SMALL I"; + case U'\u2149': + return U"DOUBLE-STRUCK ITALIC SMALL J"; + case U'\u214A': + return U"PROPERTY LINE"; + case U'\u214B': + return U"TURNED AMPERSAND"; + case U'\u214C': + return U"PER SIGN"; + case U'\u214D': + return U"AKTIESELSKAB"; + case U'\u214E': + return U"TURNED SMALL F"; + case U'\u214F': + return U"SYMBOL FOR SAMARITAN SOURCE"; + /* NUMBER FORMS: */ + case U'\u2150': + return U"VULGAR FRACTION ONE SEVENTH"; + case U'\u2151': + return U"VULGAR FRACTION ONE NINTH"; + case U'\u2152': + return U"VULGAR FRACTION ONE TENTH"; + case U'\u2153': + return U"VULGAR FRACTION ONE THIRD"; + case U'\u2154': + return U"VULGAR FRACTION TWO THIRDS"; + case U'\u2155': + return U"VULGAR FRACTION ONE FIFTH"; + case U'\u2156': + return U"VULGAR FRACTION TWO FIFTHS"; + case U'\u2157': + return U"VULGAR FRACTION THREE FIFTHS"; + case U'\u2158': + return U"VULGAR FRACTION FOUR FIFTHS"; + case U'\u2159': + return U"VULGAR FRACTION ONE SIXTH"; + case U'\u215A': + return U"VULGAR FRACTION FIVE SIXTHS"; + case U'\u215B': + return U"VULGAR FRACTION ONE EIGTH"; + case U'\u215C': + return U"VULGAR FRACTION THREE EIGTHS"; + case U'\u215D': + return U"VULGAR FRACTION FIVE EIGHTS"; + case U'\u215E': + return U"VULGAR FRACTION SEVEN EIGTHS"; + case U'\u215F': + return U"FRACTION NUMERATOR ONE"; + case U'\u2160': + return U"ROMAN NUMERAL ONE"; + case U'\u2161': + return U"ROMAN NUMERAL TWO"; + case U'\u2162': + return U"ROMAN NUMERAL THREE"; + case U'\u2163': + return U"ROMAN NUMERAL FOUR"; + case U'\u2164': + return U"ROMAN NUMERAL FIVE"; + case U'\u2165': + return U"ROMAN NUMERAL SIX"; + case U'\u2166': + return U"ROMAN NUMERAL SEVEN"; + case U'\u2167': + return U"ROMAN NUMERAL EIGHT"; + case U'\u2168': + return U"ROMAN NUMERAL NINE"; + case U'\u2169': + return U"ROMAN NUMERAL TEN"; + case U'\u216A': + return U"ROMAN NUMERAL ELEVEN"; + case U'\u216B': + return U"ROMAN NUMERAL TWELVE"; + case U'\u216C': + return U"ROMAN NUMERAL FIFTY"; + case U'\u216D': + return U"ROMAN NUMERAL ONE HUNDRED"; + case U'\u216E': + return U"ROMAN NUMERAL FIVE HUNDRED"; + case U'\u216F': + return U"ROMAN NUMERAL ONE THOUSAND"; + case U'\u2170': + return U"SMALL ROMAN NUMERAL ONE"; + case U'\u2171': + return U"SMALL ROMAN NUMERAL TWO"; + case U'\u2172': + return U"SMALL ROMAN NUMERAL THREE"; + case U'\u2173': + return U"SMALL ROMAN NUMERAL FOUR"; + case U'\u2174': + return U"SMALL ROMAN NUMERAL FIVE"; + case U'\u2175': + return U"SMALL ROMAN NUMERAL SIX"; + case U'\u2176': + return U"SMALL ROMAN NUMERAL SEVEN"; + case U'\u2177': + return U"SMALL ROMAN NUMERAL EIGHT"; + case U'\u2178': + return U"SMALL ROMAN NUMERAL NINE"; + case U'\u2179': + return U"SMALL ROMAN NUMERAL TEN"; + case U'\u217A': + return U"SMALL ROMAN NUMERAL ELEVEN"; + case U'\u217B': + return U"SMALL ROMAN NUMERAL TWELVE"; + case U'\u217C': + return U"SMALL ROMAN NUMERAL FIFTY"; + case U'\u217D': + return U"SMALL ROMAN NUMERAL ONE HUNDRED"; + case U'\u217E': + return U"SMALL ROMAN NUMERAL FIVE HUNDRED"; + case U'\u217F': + return U"SMALL ROMAN NUMERAL ONE THOUSAND"; + case U'\u2180': + return U"ROMAN NUMERAL ONE THOUSAND C D"; + case U'\u2181': + return U"ROMAN NUMERAL FIVE THOUSAND"; + case U'\u2182': + return U"ROMAN NUMERAL TEN THOUSAND"; + case U'\u2183': + return U"ROMAN NUMERAL REVERSED ONE HUNDRED"; + case U'\u2184': + return U"LATIN SMALL LETTER REVERSED C"; + case U'\u2185': + return U"ROMAN NUMERAL SIX LATE FORM"; + case U'\u2186': + return U"ROMAN NUMERAL FIFTY EARLY FORM"; + case U'\u2187': + return U"ROMAN NUMERAL FIFTY THOUSAND"; + case U'\u2188': + return U"ROMAN NUMERAL ONE HUNDRED THOUSAND"; + case U'\u2189': + return U"VULGAR FRACTION ZERO THIRDS"; + case U'\u218A': + return U"TURNED DIGIT TWO"; + case U'\u218B': + return U"TURNED DIGIT THREE"; + /* MISCELLANEOUS SYMBOLS: */ + case U'\u2630': + return U"TRIGRAM FOR HEAVEN"; + case U'\u2631': + return U"TRIGRAM FOR LAKE"; + case U'\u2632': + return U"TRIGRAM FOR FIRE"; + case U'\u2633': + return U"TRIGRAM FOR THUNDER"; + case U'\u2634': + return U"TRIGRAM FOR WIND"; + case U'\u2635': + return U"TRIGRAM FOR WATER"; + case U'\u2636': + return U"TRIGRAM FOR MOUNTAIN"; + case U'\u2637': + return U"TRIGRAM FOR EARTH"; + case U'\u2638': + return U"WHEEL OF DHARMA"; + case U'\u2639': + return U"WHITE FROWNING FACE"; + case U'\u263A': + return U"WHITE SMILING FACE"; + case U'\u263B': + return U"BLACK SMILING FACE"; + case U'\u263C': + return U"WHITE SUN WITH RAYS"; + case U'\u263D': + return U"FIRST QUARTER MOON"; + case U'\u263E': + return U"LAST QUARTER MOON"; + case U'\u263F': + return U"MERCURY"; + case U'\u2640': + return U"FEMALE SIGN"; + case U'\u2641': + return U"EARTH"; + case U'\u2642': + return U"MALE SIGN"; + case U'\u2643': + return U"JUPITER"; + case U'\u2644': + return U"SATURN"; + case U'\u2645': + return U"URANUS"; + case U'\u2646': + return U"NEPTUNE"; + case U'\u2647': + return U"PLUTO"; + case U'\u2648': + return U"ARIES"; + case U'\u2649': + return U"TAURUS"; + case U'\u264A': + return U"GEMNINI"; + case U'\u264B': + return U"CANCER"; + case U'\u264C': + return U"LEO"; + case U'\u264D': + return U"VIRGO"; + case U'\u264E': + return U"LIBRA"; + case U'\u264F': + return U"SCORPIUS"; + case U'\u2650': + return U"SAGITTARIUS"; + case U'\u2651': + return U"CAPRICORN"; + case U'\u2652': + return U"AQUARIUS"; + case U'\u2653': + return U"PISCES"; + case U'\u2654': + return U"WHITE CHESS KING"; + case U'\u2655': + return U"WHITE CHESS QUEEN"; + case U'\u2656': + return U"WHITE CHESS ROOK"; + case U'\u2657': + return U"WHITE CHESS BISHOP"; + case U'\u2658': + return U"WHITE CHESS KNIGHT"; + case U'\u2659': + return U"WHITE CHESS PAWN"; + case U'\u265A': + return U"BLACK CHESS KING"; + case U'\u265B': + return U"BLACK CHESS QUEEN"; + case U'\u265C': + return U"BLACK CHESS ROOK"; + case U'\u265D': + return U"BLACK CHESS BISHOP"; + case U'\u265E': + return U"BLACK CHESS KNIGHT"; + case U'\u265F': + return U"BLACK CHESS PAWN"; + case U'\u2660': + return U"BLACK SPADE SUIT"; + case U'\u2661': + return U"WHITE HEART SUIT"; + case U'\u2662': + return U"WHITE DIAMOND SUIT"; + case U'\u2663': + return U"BLACK CLUB SUIT"; + case U'\u2664': + return U"WHITE SPADE SUIT"; + case U'\u2665': + return U"BLACK HEART SUIT"; + case U'\u2666': + return U"BLACK DIAMOND SUIT"; + case U'\u2667': + return U"WHITE CLUB SUIT"; + case U'\u2668': + return U"HOT SPRINGS"; + case U'\u2669': + return U"QUARTER NOTE"; + case U'\u266A': + return U"EIGHT NOTE"; + case U'\u266B': + return U"BEAMED EIGTH NOTES"; + case U'\u266C': + return U"BEAMED SIXTEENTH NOTES"; + case U'\u266D': + return U"MUSIC FLAT SIGN"; + case U'\u266E': + return U"MUSIC NEUTRAL SIGN"; + case U'\u266F': + return U"MUSIC SHARP SIGN"; + case U'\u2670': + return U"WEST SYRIAC CROSS"; + case U'\u2671': + return U"EAST SYRIAC CROSS"; + case U'\u2672': + return U"UNIVERSAL RECYCLING SYMBOL"; + case U'\u2673': + return U"RECYCLING SYMBOL FOR TYPE-1 PLASTICS"; + case U'\u2674': + return U"RECYCLING SYMBOL FOR TYPE-2 PLASTICS"; + case U'\u2675': + return U"RECYCLING SYMBOL FOR TYPE-3 PLASTICS"; + case U'\u2676': + return U"RECYCLING SYMBOL FOR TYPE-4 PLASTICS"; + case U'\u2677': + return U"RECYCLING SYMBOL FOR TYPE-5 PLASTICS"; + case U'\u2678': + return U"RECYCLING SYMBOL FOR TYPE-6 PLASTICS"; + case U'\u2679': + return U"RECYCLING SYMBOL FOR TYPE-7 PLASTICS"; + case U'\u267A': + return U"RECYCLING SYMBOL FOR GENERIC MATERIALS"; + case U'\u267B': + return U"BLACK UNIVERSAL RECYCLING SYMBOL"; + case U'\u267C': + return U"RECYCLED PAPER SYMBOL"; + case U'\u267D': + return U"PARTIALLY-RECYCLED PAPER SYMBOL"; + case U'\u267E': + return U"PERMANENT PAPER SIGN"; + case U'\u267F': + return U"WHEELCHAIR SYMBOL"; + case U'\u26B9': + return U"SEXTILE"; + /* DINGBATS: */ + case U'\u271D': + return U"LATIN CROSS"; + case U'\u2721': + return U"STAR OF DAVID"; + /* SUPPLEMENTAL PUNCTUATION: */ + case U'\u2E3B': + return U"THREE-EM DASH"; + /* ARABIC PRESENTATION FORMS-A: */ + case U'\uFDFD': + return U"ARABIC LIGATURE BISMILLAH AL-RAHMAN AR-RAHEEM"; + /* ANCIENT SYMBOLS: */ + case U'\U00010190': + return U"ROMAN SEXTANS SIGN"; + case U'\U00010191': + return U"ROMAN UNCIA SIGN"; + case U'\U00010192': + return U"ROMAN SEMUNCIA SIGN"; + case U'\U00010193': + return U"ROMAN SEXTULA SIGN"; + case U'\U00010194': + return U"ROMAN DIMIDIA SEXTULA SIGN"; + case U'\U00010195': + return U"ROMAN SILIQUA SIGN"; + case U'\U00010196': + return U"ROMAN DENARIUS SIGN"; + case U'\U00010197': + return U"ROMAN QUINARIUS SIGN"; + case U'\U00010198': + return U"ROMAN SESTERTIUS SIGN"; + case U'\U00010199': + return U"ROMAN DUPONDIUS SIGN"; + case U'\U0001019A': + return U"ROMAN AS SIGN"; + case U'\U0001019B': + return U"ROMAN CENTURIAL SIGN"; + case U'\U0001019C': + return U"ASCIA SIGN"; + /* BRAHMI: */ + case U'\U00011066': + return U"BRAHMI DIGIT ZERO"; + case U'\U00011067': + return U"BRAHMI DIGIT ONE"; + case U'\U00011068': + return U"BRAHMI DIGIT TWO"; + case U'\U00011069': + return U"BRAHMI DIGIT THREE"; + case U'\U0001106A': + return U"BRAHMI DIGIT FOUR"; + case U'\U0001106B': + return U"BRAHMI DIGIT FIVE"; + case U'\U0001106C': + return U"BRAHMI DIGIT SIX"; + case U'\U0001106D': + return U"BRAHMI DIGIT SEVEN"; + case U'\U0001106E': + return U"BRAHMI DIGIT EIGHT"; + case U'\U0001106F': + return U"BRAHMI DIGIT NINE"; + /* CUNEIFORM: */ + case U'\U00012031': + return U"CUNEIFORM SIGN AN PLUS NAGA SQUARED"; + /* CUNEIFORM NUMBERS AND PUNCTUATION: */ + case U'\U0001242B': + return U"CUNEIFORM NUMERIC SIGN NINE SHAR2"; + /* EGYPTIAN HIEROGLYPHS: */ + case U'\U000130B8': + return U"EGYPTIAN HIEROGLYPH D052"; + /* COUNTING ROD NUMERALS: */ + case U'\U0001D372': + return U"IDEOGRAPHIC TALLY MARK ONE"; + case U'\U0001D373': + return U"IDEOGRAPHIC TALLY MARK TWO"; + case U'\U0001D374': + return U"IDEOGRAPHIC TALLY MARK THREE"; + case U'\U0001D375': + return U"IDEOGRAPHIC TALLY MARK FOUR"; + case U'\U0001D376': + return U"IDEOGRAPHIC TALLY MARK FIVE"; + case U'\U0001D377': + return U"TALLY MARK ONE"; + case U'\U0001D378': + return U"TALLY MARK FIVE"; + /* ENCLOSED ALPHANUMERIC SUPPLEMENT: */ + case U'\U0001F10D': + return U"CIRCLED ZERO WITH SLASH"; + case U'\U0001F10E': + return U"CIRCLED ANTICKLOCKWISE ARROW"; + case U'\U0001F10F': + return U"CIRCLED DOLLAR SIGN WITH OVERLAID BACKSLASH"; + case U'\U0001F12F': + return U"COPYLEFT SYMBOL"; + case U'\U0001F16D': + return U"CIRCLED CC"; + case U'\U0001F16E': + return U"CIRCLED C WITH OVERLAID BACKSLASH"; + case U'\U0001F16F': + return U"CIRCLED HUMAN FIGURE"; + /* EMOTICONS: */ + case U'\U0001F600': + return U"GRINNING FACE"; + case U'\U0001F601': + return U"GRINNING FACE WITH SMIRKING EYES"; + case U'\U0001F602': + return U"FACE WITH TEARS OF JOY"; + case U'\U0001F603': + return U"SMILING FACE WITH OPEN MOUTH"; + case U'\U0001F604': + return U"SMILING FACE WITH OPEN MOUTH AND SMILING EYES"; + case U'\U0001F605': + return U"SMILING FACE WITH OPEN MOUTH AND COULD SWEAT"; + case U'\U0001F606': + return U"SMILING FACE WITH OPEN MOUTH AND TIGHTLY-CLOSED EYES"; + case U'\U0001F607': + return U"SMILING FACE WITH HALO"; + case U'\U0001F608': + return U"SMILING FACE WITH HORNS"; + case U'\U0001F609': + return U"WINKING FACE"; + case U'\U0001F60A': + return U"SMILING FACE WITH SMILING EYES"; + case U'\U0001F60B': + return U"FACE SAVOURING DELICIOUS FOOD"; + case U'\U0001F60C': + return U"RELIEVED FACE"; + case U'\U0001F60D': + return U"SMILLING FACE HEART-SHAPED EYES"; + case U'\U0001F60E': + return U"SMILLING FACE WITH SUNGLASSES"; + case U'\U0001F60F': + return U"SMIRKING FACE"; + case U'\U0001F610': + return U"NEUTRAL FACE"; + case U'\U0001F611': + return U"EXPRESSIONLESS FACE"; + case U'\U0001F612': + return U"UNAMUSED FACE"; + case U'\U0001F613': + return U"FACE WITH COLD SWEAT"; + case U'\U0001F614': + return U"PENSIVE FACE"; + case U'\U0001F615': + return U"CONFUSED FACE"; + case U'\U0001F616': + return U"CONFOUNDED FACE"; + case U'\U0001F617': + return U"KISSING FACE"; + case U'\U0001F618': + return U"FACE THROWING A KISS"; + case U'\U0001F619': + return U"KISSING FACE WITH SMILLING EYES"; + case U'\U0001F61A': + return U"KISSING FACE WITH CLOSED EYES"; + case U'\U0001F61B': + return U"FACE WITH STUCK-OUT TONGUE"; + case U'\U0001F61C': + return U"FACE WITH STUCK-OUT TONGUE AND WINKING EYE"; + case U'\U0001F61D': + return U"FACE WITH STUCK-OUT TONGUE AND TIGHTLY-CLOSED EYES"; + case U'\U0001F61E': + return U"DISSAPOINTED FACE"; + case U'\U0001F61F': + return U"WORRIED FACE"; + case U'\U0001F620': + return U"ANGRY FACE"; + case U'\U0001F621': + return U"POUTING FACE"; + case U'\U0001F622': + return U"CRYING FACE"; + case U'\U0001F623': + return U"PERSEVERING FACE"; + case U'\U0001F624': + return U"FACE WITH LOOK OF TRIUMPH"; + case U'\U0001F625': + return U"DISSAPOINTED BUT RELIEVED FACE"; + case U'\U0001F626': + return U"FROWNING FACE WITH OPEN MOUTH"; + case U'\U0001F627': + return U"ANGUISHED FACE"; + case U'\U0001F628': + return U"FEARFUL FACE"; + case U'\U0001F629': + return U"WEARY FACE"; + case U'\U0001F62A': + return U"SLEEPY FACE"; + case U'\U0001F62B': + return U"TIRED FACE"; + case U'\U0001F62C': + return U"GRIMACING FACE"; + case U'\U0001F62D': + return U"LOUDLY CRYING FACE"; + case U'\U0001F62E': + return U"FACE WITH OPEN MOUTH"; + case U'\U0001F62F': + return U"HUSHED FACE"; + case U'\U0001F630': + return U"FACE WITH OPEN MOUTH AND COLD SWEAT"; + case U'\U0001F631': + return U"FACE SCREAMING IN FEAR"; + case U'\U0001F632': + return U"ASTONISHED FACE"; + case U'\U0001F633': + return U"FLUSHED FACE"; + case U'\U0001F634': + return U"SLEEPING FACE"; + case U'\U0001F635': + return U"DIZZY FACE"; + case U'\U0001F636': + return U"FACE WITHOUT MOUTH"; + case U'\U0001F637': + return U"FACE WITH MEDICAL MASK"; + case U'\U0001F641': + return U"SLIGHTLY FROWNING FACE"; + case U'\U0001F642': + return U"SLIGHTLY SMILING FACE"; + case U'\U0001F643': + return U"UPSIDE-DOWN FACE"; + case U'\U0001F644': + return U"FACE WITH ROLLING EYES"; + /* ORNAMENTAL DINGBATS: */ + case U'\U0001F670': + return U"SCRIPT LIGATURE ET ORNAMENT"; + case U'\U0001F671': + return U"HEAVY SCRIPT LIGATURE ET ORNAMENT"; + case U'\U0001F672': + return U"LIGATURE OPEN ET ORNAMENT"; + case U'\U0001F673': + return U"HEAVY LIGATURE OPEN ET ORNAMENT"; + case U'\U0001F674': + return U"HEAVY AMPERSAND ORNAMENT"; + case U'\U0001F675': + return U"SWASH AMPERSAND ORNAMENT"; + case U'\U0001F676': + return U"SANS-SERIF HEAVY DOUBLE TURNED COMMA QUOTATION MARK ORNAMENT"; + case U'\U0001F677': + return U"SANS-SERIF HEAVY DOUBLE COMMA QUOTATION MARK ORNAMENT"; + case U'\U0001F678': + return U"SANS-SERIF HEAVY LOW DOUBLE QUOTATION MARK ORNAMENT"; + case U'\U0001F679': + return U"HEAVY INTERROBANG ORNAMENT"; + case U'\U0001F67A': + return U"SANS-SERIF INTERROBANG ORNAMENT"; + case U'\U0001F67B': + return U"HEAVY SANS-SERIF INTERROBANG ORNAMENT"; + case U'\U0001F67C': + return U"VERY HEAVY SOLIDUS"; + case U'\U0001F67D': + return U"VERY HEAVY REVERSE SOLIDUS"; + case U'\U0001F67E': + return U"CHECKER BOARD"; + case U'\U0001F67F': + return U"REVERSE CHECKER BOARD"; + /* CJK UNIFIED IDEOGRAPHS EXTENSION G: */ + case U'\U0003106C': + return U"CJK UNIFIED IDEOGRAPH-3106C"; + /* TAGS: */ + case U'\U000E0001': + return U"LANGUAGE TAG"; + case U'\U000E0020': + return U"TAG SPACE"; + case U'\U000E0021': + return U"TAG EXCLAMATION MARK"; + case U'\U000E0022': + return U"TAG QUOTATION MARK"; + case U'\U000E0023': + return U"TAG NUMBER SIGN"; + case U'\U000E0024': + return U"TAG DOLLAR SIGN"; + case U'\U000E0025': + return U"TAG PERCENT SIGN"; + case U'\U000E0026': + return U"TAG AMPERSAND"; + case U'\U000E0027': + return U"TAG APOSTROPHE"; + case U'\U000E0028': + return U"TAG LEFT PARANTHESIS"; + case U'\U000E0029': + return U"TAG RIGHT PARANTHESIS"; + case U'\U000E002A': + return U"TAG ASTERISK"; + case U'\U000E002B': + return U"TAG PLUS SIGN"; + case U'\U000E002C': + return U"TAG COMMA"; + case U'\U000E002D': + return U"TAG HYPHEN-MINUS"; + case U'\U000E002E': + return U"TAG FULL STOP"; + case U'\U000E002F': + return U"TAG SOLIDUS"; + case U'\U000E0030': + return U"TAG DIGIT ZERO"; + case U'\U000E0031': + return U"TAG DIGIT ONE"; + case U'\U000E0032': + return U"TAG DIGIT TWO"; + case U'\U000E0033': + return U"TAG DIGIT THREE"; + case U'\U000E0034': + return U"TAG DIGIT FOUR"; + case U'\U000E0035': + return U"TAG DIGIT FIVE"; + case U'\U000E0036': + return U"TAG DIGIT SIX"; + case U'\U000E0037': + return U"TAG DIGIT SEVEN"; + case U'\U000E0038': + return U"TAG DIGIT EIGHT"; + case U'\U000E0039': + return U"TAG DIGIT NINE"; + case U'\U000E003A': + return U"TAG COLON"; + case U'\U000E003B': + return U"TAG SEMICOLON"; + case U'\U000E003C': + return U"TAG LESS-THAN SIGN"; + case U'\U000E003D': + return U"TAG EQUALS SIGN"; + case U'\U000E003E': + return U"TAG GREATER-THAN SIGN"; + case U'\U000E003F': + return U"TAG QUESTION MARK"; + case U'\U000E0040': + return U"TAG COMMERCIAL AT"; + case U'\U000E0041': + return U"TAG LATIN CAPITAL LETTER A"; + case U'\U000E0042': + return U"TAG LATIN CAPITAL LETTER B"; + case U'\U000E0043': + return U"TAG LATIN CAPITAL LETTER C"; + case U'\U000E0044': + return U"TAG LATIN CAPITAL LETTER D"; + case U'\U000E0045': + return U"TAG LATIN CAPITAL LETTER E"; + case U'\U000E0046': + return U"TAG LATIN CAPITAL LETTER F"; + case U'\U000E0047': + return U"TAG LATIN CAPITAL LETTER G"; + case U'\U000E0048': + return U"TAG LATIN CAPITAL LETTER H"; + case U'\U000E0049': + return U"TAG LATIN CAPITAL LETTER I"; + case U'\U000E004A': + return U"TAG LATIN CAPITAL LETTER J"; + case U'\U000E004B': + return U"TAG LATIN CAPITAL LETTER K"; + case U'\U000E004C': + return U"TAG LATIN CAPITAL LETTER L"; + case U'\U000E004D': + return U"TAG LATIN CAPITAL LETTER M"; + case U'\U000E004E': + return U"TAG LATIN CAPITAL LETTER N"; + case U'\U000E004F': + return U"TAG LATIN CAPITAL LETTER O"; + case U'\U000E0050': + return U"TAG LATIN CAPITAL LETTER P"; + case U'\U000E0051': + return U"TAG LATIN CAPITAL LETTER Q"; + case U'\U000E0052': + return U"TAG LATIN CAPITAL LETTER R"; + case U'\U000E0053': + return U"TAG LATIN CAPITAL LETTER S"; + case U'\U000E0054': + return U"TAG LATIN CAPITAL LETTER T"; + case U'\U000E0055': + return U"TAG LATIN CAPITAL LETTER U"; + case U'\U000E0056': + return U"TAG LATIN CAPITAL LETTER V"; + case U'\U000E0057': + return U"TAG LATIN CAPITAL LETTER W"; + case U'\U000E0058': + return U"TAG LATIN CAPITAL LETTER X"; + case U'\U000E0059': + return U"TAG LATIN CAPITAL LETTER Y"; + case U'\U000E005A': + return U"TAG LATIN CAPITAL LETTER Z"; + case U'\U000E005B': + return U"TAG LEFT SQUARE BRACKET"; + case U'\U000E005C': + return U"TAG REVERSE SOLIDUS"; + case U'\U000E005D': + return U"TAG RIGHT SQUARE BRACKET"; + case U'\U000E005E': + return U"TAG CIRCUMFLEX ACCENT"; + case U'\U000E005F': + return U"TAG LOW LINE"; + case U'\U000E0060': + return U"TAG GRAVE ACCENT"; + case U'\U000E0061': + return U"TAG LATIN SMALL LETTER A"; + case U'\U000E0062': + return U"TAG LATIN SMALL LETTER B"; + case U'\U000E0063': + return U"TAG LATIN SMALL LETTER C"; + case U'\U000E0064': + return U"TAG LATIN SMALL LETTER D"; + case U'\U000E0065': + return U"TAG LATIN SMALL LETTER E"; + case U'\U000E0066': + return U"TAG LATIN SMALL LETTER F"; + case U'\U000E0067': + return U"TAG LATIN SMALL LETTER G"; + case U'\U000E0068': + return U"TAG LATIN SMALL LETTER H"; + case U'\U000E0069': + return U"TAG LATIN SMALL LETTER I"; + case U'\U000E006A': + return U"TAG LATIN SMALL LETTER J"; + case U'\U000E006B': + return U"TAG LATIN SMALL LETTER K"; + case U'\U000E006C': + return U"TAG LATIN SMALL LETTER L"; + case U'\U000E006D': + return U"TAG LATIN SMALL LETTER M"; + case U'\U000E006E': + return U"TAG LATIN SMALL LETTER N"; + case U'\U000E006F': + return U"TAG LATIN SMALL LETTER O"; + case U'\U000E0070': + return U"TAG LATIN SMALL LETTER P"; + case U'\U000E0071': + return U"TAG LATIN SMALL LETTER Q"; + case U'\U000E0072': + return U"TAG LATIN SMALL LETTER R"; + case U'\U000E0073': + return U"TAG LATIN SMALL LETTER S"; + case U'\U000E0074': + return U"TAG LATIN SMALL LETTER T"; + case U'\U000E0075': + return U"TAG LATIN SMALL LETTER U"; + case U'\U000E0076': + return U"TAG LATIN SMALL LETTER V"; + case U'\U000E0077': + return U"TAG LATIN SMALL LETTER W"; + case U'\U000E0078': + return U"TAG LATIN SMALL LETTER X"; + case U'\U000E0079': + return U"TAG LATIN SMALL LETTER Y"; + case U'\U000E007A': + return U"TAG LATIN SMALL LETTER Z"; + case U'\U000E007B': + return U"TAG LEFT CURLY BRACKET"; + case U'\U000E007C': + return U"TAG VERTICAL LINE"; + case U'\U000E007D': + return U"TAG RIGHT CURLY BRACKET"; + case U'\U000E007E': + return U"TAG TILDE"; + case U'\U000E007F': + return U"CANCEL TAG"; + } +} diff --git a/include/dux/str.hh b/include/dux/str.hh new file mode 100644 index 0000000..6ecf0ca --- /dev/null +++ b/include/dux/str.hh @@ -0,0 +1,81 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of dux. + + dux is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your + option) any later version. + + dux is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + License for more details. + + You should have received a copy of the GNU Affero General Public License + along with dux. If not, see <https://www.gnu.org/licenses/>. +*/ + +namespace dux { + class str { + public: + constexpr auto app( ::dux::str const & oth) -> ::dux::str const &; + [[nodiscard]] constexpr auto begin() noexcept -> char32_t *; + [[nodiscard]] constexpr auto begin() const noexcept -> char32_t const *; + [[nodiscard]] constexpr auto cbegin() const noexcept -> char32_t const *; + [[nodiscard]] constexpr auto cend() const noexcept -> char32_t const *; + constexpr auto del( ::dux::usz pos) -> void; + [[nodiscard]] constexpr auto end() noexcept -> char32_t *; + [[nodiscard]] constexpr auto end() const noexcept -> char32_t const *; + [[nodiscard]] constexpr auto fnd( char32_t chr) const noexcept -> ::dux::usz; + constexpr auto ins( ::dux::usz pos, ::dux::str const & oth) -> ::dux::str const &; + constexpr auto len() const noexcept -> ::dux::usz; + constexpr auto operator + ( ::dux::str const & oth) const -> ::dux::str; + constexpr auto operator = ( ::dux::str const & oth) -> ::dux::str const &; + constexpr auto operator == (::dux::str const & oth) const noexcept -> bool; + constexpr auto operator [] (::dux::usz pos) noexcept -> char32_t &; + constexpr auto operator [] (::dux::usz pos) const noexcept -> char32_t const &; + [[nodiscard]] constexpr str() noexcept = default; + [[nodiscard]] constexpr str( char32_t chr); + [[nodiscard]] constexpr str( ::dux::str const & oth); + [[nodiscard]] constexpr str( ::dux::str && oth); + template<::dux::usz N> [[nodiscard]] constexpr str( char const (& strlit)[N]) noexcept = delete; + template<::dux::usz N> [[nodiscard]] constexpr str( char32_t const (& strlit)[N]) noexcept; + template<::dux::utf T> [[nodiscard]] constexpr str( T chr); + template<::dux::utf T> [[nodiscard]] constexpr str( T const * utf); + [[nodiscard]] constexpr auto sub( ::dux::usz pos, ::dux::usz len) const -> ::dux::str; + [[nodiscard]] constexpr auto u8() const -> ::dux::arr<char8_t>; + private: + ::dux::arr<char32_t> _arr; + }; + + template<::dux::utf T,::dux::utf T0> [[nodiscard]] constexpr auto cnv( T0 const * begin,T0 const * end) -> ::dux::arr<T>; + [[nodiscard,dux_attr_const]] constexpr auto isalnum( char32_t chr) -> bool; + [[nodiscard,dux_attr_const]] constexpr auto isalpha( char32_t chr) -> bool; + [[nodiscard,dux_attr_const]] constexpr auto iscntrl( char32_t chr) -> bool; + [[nodiscard,dux_attr_const]] constexpr auto isdigit( char32_t chr) -> bool; + [[nodiscard,dux_attr_const]] constexpr auto islower( char32_t chr) -> bool; + [[nodiscard,dux_attr_const]] constexpr auto ispunct( char32_t chr) -> bool; + [[nodiscard,dux_attr_const]] constexpr auto isspace( char32_t chr) -> bool; + [[nodiscard,dux_attr_const]] constexpr auto issurro( char32_t chr) -> bool; + [[nodiscard,dux_attr_const]] constexpr auto isupper( char32_t chr) -> bool; + [[nodiscard,dux_attr_const]] constexpr auto isxdigit(char32_t chr) -> bool; + [[nodiscard]] constexpr auto uniblk( char32_t chr) -> ::dux::str; + [[nodiscard]] constexpr auto uninm( char32_t chr) -> ::dux::str; +} + +#include <dux/str.d/cnv.hh> +#include <dux/str.d/isalnum.hh> +#include <dux/str.d/isalpha.hh> +#include <dux/str.d/iscntrl.hh> +#include <dux/str.d/isdigit.hh> +#include <dux/str.d/islower.hh> +#include <dux/str.d/ispunct.hh> +#include <dux/str.d/isspace.hh> +#include <dux/str.d/issurro.hh> +#include <dux/str.d/isupper.hh> +#include <dux/str.d/isxdigit.hh> +#include <dux/str.d/str.hh> +#include <dux/str.d/uniblk.hh> +#include <dux/str.d/uninm.hh> diff --git a/include/dux/sys b/include/dux/sys new file mode 100644 index 0000000..33dc533 --- /dev/null +++ b/include/dux/sys @@ -0,0 +1,27 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of dux. + + dux is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your + option) any later version. + + dux is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + License for more details. + + You should have received a copy of the GNU Affero General Public License + along with dux. If not, see <https://www.gnu.org/licenses/>. +*/ + +#if !defined(dux_hdr_sys) +#define dux_hdr_sys + +#include <dux/str> + +#include <dux/sys.hh> + +#endif diff --git a/include/dux/sys.d/_ass.hh b/include/dux/sys.d/_ass.hh new file mode 100644 index 0000000..ecb9548 --- /dev/null +++ b/include/dux/sys.d/_ass.hh @@ -0,0 +1,40 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of dux. + + dux is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your + option) any later version. + + dux is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + License for more details. + + You should have received a copy of the GNU Affero General Public License + along with dux. If not, see <https://www.gnu.org/licenses/>. +*/ + +#include <iostream> + +constexpr auto ::dux::_ass(char const * const dux_restr _fl,unsigned long const _ln,char const * const dux_restr _fn,bool const _expr,char const * const dux_restr _exprstr,char const * const dux_restr _msg) noexcept -> bool { + if (!_expr) [[unlikely]] { + ::std::cerr << "\n"; + ::std::cerr << "Assertion \u001B[38;2;225;61;61mfailed\u001B[0m"; + if (!::dux::cstrcmp(_msg,"")) { + ::std::cerr << "!"; + } + else { + ::std::cerr << ": \u001B[3m" << _msg << "\u001B[0m"; + } + ::std::cerr << "\n"; + ::std::cerr << "... at \u001B[38;2;225;169;61m\"" << _fl << "\"\u001B[0m:\u001B[38;2;255;169;61m" << _ln << "\u001B[0m\n"; + ::std::cerr << "... in \u001B[38;2;169;225;61m" << _fn << "\u001B[0m\n"; + ::std::cerr << " Expression (\u001B[38;2;61;169;225m" << _exprstr << "\u001B[0m) does not evaluate to true!\n"; + ::std::cerr << "\n"; + ::dux::abrt(); + } + return _expr; +} diff --git a/include/dux/sys.d/dobj.hh b/include/dux/sys.d/dobj.hh new file mode 100644 index 0000000..5f60b4c --- /dev/null +++ b/include/dux/sys.d/dobj.hh @@ -0,0 +1,65 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of dux. + + dux is free software: + you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + + dux is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License along with dux. + If not, see <https://www.gnu.org/licenses/>. +*/ + +#if defined(dux_os_posix) +#include <dlfcn.h> +#endif + +namespace dux { + class _dobjdat { + public: +#if defined(dux_os_posix) + void * dlhandl{nullptr}; +#endif + }; +} + +template<typename T,typename... Ts> auto ::dux::dobj::call(char const * const dux_restr _fn,Ts const &... _args) -> T { + [[maybe_unused]] auto const dat = static_cast<::dux::_dobjdat *>(this->_dat); + dux_ass(_fn != nullptr,"Input C-string points to null!"); +#if defined(dux_os_posix) + dux_ass(dat->dlhandl != nullptr,"Dynamic object has not been linked!"); + auto const sym = reinterpret_cast<T (*)(Ts...)>(::dlsym(dat->dlhandl,_fn)); + if (sym == nullptr) [[unlikely]] { + throw ::dux::runerr("Unable to load function!"); + } + return sym(_args...); +#endif +} +::dux::dobj::dobj() : _dat(::new ::dux::_dobjdat) { +} +auto ::dux::dobj::link(char const * const dux_restr _lib) -> void { + [[maybe_unused]] auto const dat = static_cast<::dux::_dobjdat *>(this->_dat); + dux_ass(_lib != nullptr,"Input C-string points to null!"); +#if defined(dux_os_posix) + dat->dlhandl = ::dlopen(_lib,RTLD_LOCAL | RTLD_NOW); + if (dat->dlhandl == nullptr) [[unlikely]] { + throw ::dux::runerr("Unable to open library!"); + } +#endif +} +auto ::dux::dobj::unlink() noexcept -> void { + [[maybe_unused]] auto const dat = static_cast<::dux::_dobjdat *>(this->_dat); +#if defined(dux_os_posix) + if (dat->dlhandl != nullptr) { + ::dlclose(dat->dlhandl); + dat->dlhandl = nullptr; + } +#endif +} +::dux::dobj::~dobj() noexcept { + ::delete static_cast<::dux::_dobjdat *>(this->_dat); +} diff --git a/include/dux/sys.hh b/include/dux/sys.hh new file mode 100644 index 0000000..9f34f20 --- /dev/null +++ b/include/dux/sys.hh @@ -0,0 +1,98 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of dux. + + dux is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your + option) any later version. + + dux is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + License for more details. + + You should have received a copy of the GNU Affero General Public License + along with dux. If not, see <https://www.gnu.org/licenses/>. +*/ + +#define dux_ass(expr,msg) \ + ([&]() { \ + if constexpr (::dux::dbg) { \ + ::dux::_ass(__FILE__,static_cast<unsigned long>(__LINE__),dux_fnnm,expr,#expr,msg); \ + } \ + }()) + +namespace dux { + enum class sig : ::dux::ubyte { + abrt, + fpe, + ill, + int_, + kill, + segv, + term, + trap, +#if defined(dux_os_posix) + alrm, + bus, + cont, + hup, + iot, + pipe, + poll, + prof, + quit, + rtmax, + rtmin, + stop, + sys, + tstp, + ttin, + ttou, + urg, + usr1, + usr2, + vtalrm, + winch, + xcpu, + xfsz, +#endif + }; + constexpr auto numsig{static_cast<::dux::ubyte>([]() { +#if defined(dux_os_posix) + return ::dux::sig::xfsz; +#else + return ::dux::sig::trap; +#endif + }()) + ::dux::ubytev(0x1)}; + + class dobj { + public: + template<typename T,typename... Ts> [[nodiscard]] inline auto call( char const * fn, Ts const &... args) -> T; + [[nodiscard]] inline dobj(); + inline auto link( char const * lib) -> void; + inline auto unlink() noexcept -> void; + inline ~dobj() noexcept; + private: + void * const dux_restr _dat; + }; + + constexpr auto _ass( char const * fl, unsigned long ln, char const * fn, bool expr,char const * exprstr,char const * msg) noexcept -> bool; + [[noreturn]] auto abrt() noexcept -> void; + [[noreturn]] auto abrt( ::dux::str const & msg) noexcept -> void; + [[noreturn]] auto exit( ::dux::stat stat = ::dux::stat::ok) noexcept -> void; + [[nodiscard]] auto getenv( char const * var) -> char const *; + [[noreturn]] auto qexit( ::dux::stat stat = ::dux::stat::err) noexcept -> void; + auto raise( ::dux::sig sig) noexcept -> void; + auto sighandl(::dux::sig sig, auto (* handl)(::dux::sig) -> void) -> auto (&)(::dux::sig) -> void; + auto sleep( ::dux::uint64 sec, ::dux::uint64 nsecx = ::dux::uint64v(0x0),::dux::uint64 nsecy = ::dux::uint64v(0x1)) noexcept -> void; + [[noreturn]] auto trap() noexcept -> void; + [[noreturn]] auto unreach() noexcept -> void; + + constexpr auto (* dflsighandl)(::dux::sig) -> void {nullptr}; +} + +#include <dux/sys.d/_ass.hh> +#include <dux/sys.d/dobj.hh> diff --git a/include/dux/thrd b/include/dux/thrd new file mode 100644 index 0000000..cc443d7 --- /dev/null +++ b/include/dux/thrd @@ -0,0 +1,26 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of dux. + + dux is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your + option) any later version. + + dux is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + License for more details. + + You should have received a copy of the GNU Affero General Public License + along with dux. If not, see <https://www.gnu.org/licenses/>. +*/ + +#if !defined(dux_hdr_thrd) +#define dux_hdr_thrd + +#include <dux/sys> +#include <dux/thrd.hh> + +#endif diff --git a/include/dux/thrd.d/thrd.hh b/include/dux/thrd.d/thrd.hh new file mode 100644 index 0000000..5f8aa29 --- /dev/null +++ b/include/dux/thrd.d/thrd.hh @@ -0,0 +1,87 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of dux. + + dux is free software: + you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + + dux is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License along with dux. + If not, see <https://www.gnu.org/licenses/>. +*/ + +/* + thrd implementation: + (To-do) On Linux, we will use our own wrappers for the Linux system calls (syscalls) that enable multithreading; + On POSIX, we will use our own wrappers for the POSIX Threads API, as to not polute the global scope; +*/ + + +namespace dux { +#if defined(dux_os_posix) + template<typename Fn,typename... Ts> class _thrdwrapdat { + public: + ::dux::tup<Ts...> args; + Fn * fn {nullptr}; + }; +#endif +} +template<typename T> auto ::dux::thrd::join(T * const dux_restr _ret) -> void { + if (this->_isjoin) [[unlikely]] { /* We do not need to do anything if the thread has joined. */ + return; + } +#if defined(dux_os_posix) + auto const ret{static_cast<T *>(::dux::_pthrdjoin(this->_pthrdhandl))}; /* POSIX Threads return the pointer passed to (::pthread_exit) on joining of thread. */ + if constexpr (!::dux::isvoid<T>) { /* (void) is an incomplete type, and we do not need to operate on it. */ + if (_ret) { /* Safe: "A prvalue of integral, floating-point, unscoped enumeration, __pointer__, and pointer-to-member types can be converted to a prvalue of type bool.", cppreference, 2021-11-17T15:40:00+0100 */ + *_ret = *ret; + } + } + ::delete ret; /* Free the allocated memory we got from the wrapper lambda in (::dux::thrd::operator ()). */ +#else + _Pragma("GCC message Unable to implement (::dux::thrd::join)!"); +#endif + this->_isjoin = true; +} +template<typename Fn,typename... Ts> auto ::dux::thrd::operator () (Fn const & _fn, Ts const &... _args) -> auto { + using T = decltype(_fn(Ts{}...)); +#if defined(dux_os_posix) + auto thrdwrap{[](void * const dux_restr _dat) -> void * { /* POSIX Threads use functions of type (void * (void *)). We will create a wrapper lambda, which calls the provided function (_fn). */ + auto const dat {static_cast<::dux::_thrdwrapdat<Fn,Ts...> *>(_dat)}; + auto const fn {dat->fn}; + auto const args{dat->args}; + ::delete dat; + auto const ret{::new T}; + *ret = args.apply(fn); + return ret; + }}; + auto const thrdwrapdat{::new ::dux::_thrdwrapdat<Fn,Ts...>}; + thrdwrapdat->fn = _fn; + thrdwrapdat->args = ::dux::tup{_args...}; + ::dux::_pthrdcrt(this->_pthrdhandl,thrdwrap,thrdwrapdat); +#else + _Pragma("GCC message Unable to implement (::dux::thrd::operator ())!"); +#endif + this->_isjoin = false; + return T{}; +} +template<typename Fn,typename... Ts> auto ::dux::thrd::run(Fn const & _fn, Ts const &... _args) -> decltype(auto) { /* This is a wrapper for (::dux::thrd::operator ()) to be used in cases of the thread being accessed using a handle ((thrd->run(...)) is prettier than (thrc->operator () (...))). */ + return this->operator () (_fn,_args...); +} +#if defined(dux_os_posix) +::dux::thrd::thrd() : _pthrdhandl(::dux::_getpthrdhandl()) {} +#else +::dux::thrd::thrd() {} +#endif +::dux::thrd::~thrd() noexcept { + if (!this->_isjoin) [[unlikely]] { /* The programmer did not join the thread before it got out of scope. We want safe programming, so we will __not__ recover from this. */ + ::dux::abrt(U"dux :: Active thread got out of scope!"); + } +#if defined(dux_os_posix) + ::dux::_freepthrdhandl(this->_pthrdhandl); +#endif +} diff --git a/include/dux/thrd.hh b/include/dux/thrd.hh new file mode 100644 index 0000000..558b737 --- /dev/null +++ b/include/dux/thrd.hh @@ -0,0 +1,47 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of dux. + + dux is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or (at your + option) any later version. + + dux is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + License for more details. + + You should have received a copy of the GNU Affero General Public License + along with dux. If not, see <https://www.gnu.org/licenses/>. +*/ + +namespace dux { + class thrderr : public ::dux::except { + public: + using ::dux::except::except; + }; + + class thrd { + public: + template<typename T = ::dux::ubyte> auto join( T * ret = nullptr) -> void; + template<typename T> auto join( ::dux::nullptrtyp) = delete; + template<typename Fn, typename... Ts> auto operator () (Fn const & fn, Ts const &... args) -> auto; + template<typename Fn, typename... Ts> auto run( Fn const & fn, Ts const &... args) -> decltype(auto); + [[nodiscard]] inline thrd(); + inline ~thrd() noexcept; + private: + bool _isjoin{true}; + void * const dux_restr _pthrdhandl; + }; + +#if defined(dux_os_posix) + auto _freepthrdhandl(void * handl) noexcept -> void; + auto _getpthrdhandl() -> void *; + auto _pthrdcrt( void * handl,auto (* fn)( void *) -> void *,void const * arg) -> void; + auto _pthrdjoin( void * handl) -> void *; +#endif +} + +#include <dux/thrd.d/thrd.hh> |