diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-12-25 12:57:06 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2025-12-25 12:57:06 +0100 |
| commit | a3b23dcaabb53b8770c6ac8cfc33c6002b815589 (patch) | |
| tree | 2e6b0ee229c39686947938162b446989928bdf91 /include/ocl/tproc | |
| parent | 543f288e808b575f97efd56f2d14c495b49459f3 (diff) | |
feat: add clang-format, and improved public API.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'include/ocl/tproc')
| -rw-r--r-- | include/ocl/tproc/detail/config.hpp | 9 | ||||
| -rw-r--r-- | include/ocl/tproc/detail/rope_fwd.hpp | 74 | ||||
| -rw-r--r-- | include/ocl/tproc/detail/rope_fwd.inl | 72 | ||||
| -rw-r--r-- | include/ocl/tproc/rope.hpp | 11 |
4 files changed, 121 insertions, 45 deletions
diff --git a/include/ocl/tproc/detail/config.hpp b/include/ocl/tproc/detail/config.hpp index 47bd0b2..e9880fd 100644 --- a/include/ocl/tproc/detail/config.hpp +++ b/include/ocl/tproc/detail/config.hpp @@ -13,9 +13,14 @@ #include <ocl/option.hpp> #include <ocl/smart_ptr.hpp> -namespace ocl { +#include <boost/core/detail/string_view.hpp> -namespace pmr {} +namespace ocl +{ + + namespace pmr + { + } } // namespace ocl diff --git a/include/ocl/tproc/detail/rope_fwd.hpp b/include/ocl/tproc/detail/rope_fwd.hpp index c9c3567..eadefce 100644 --- a/include/ocl/tproc/detail/rope_fwd.hpp +++ b/include/ocl/tproc/detail/rope_fwd.hpp @@ -6,49 +6,53 @@ #ifndef OCL_TPROC_ROPE_FWD_HPP #define OCL_TPROC_ROPE_FWD_HPP -#include <boost/utility/string_view.hpp> -#include <memory> +#include <ocl/tproc/detail/config.hpp> /// \file rope_fwd.hpp /// \brief Basic forward definitions of the `rope` type. -namespace ocl { - -/// \brief This class implements a rope type for any **CharT** type. -/// \note Specializations are available as `crope` and `wrope`. -/// \author Amlal El Mahrouss -template <class CharT, class Traits = std::char_traits<CharT>, - class Allocator = std::allocator<CharT>> -class basic_rope final { -public: - using traits_type = Traits; - using value_type = CharT; - using allocator_type = Allocator; - using size_type = std::allocator_traits<Allocator>::size_type; - using reference = CharT &; - using const_reference = const CharT &; - using pointer = std::allocator_traits<Allocator>::pointer; - using const_pointer = std::allocator_traits<Allocator>::pointer; - - CharT *begin(); - CharT *end(); - size_type size(); - bool empty() const; - - ~basic_rope(); - basic_rope(const boost::basic_string_view<CharT> &in = {}); - -private: - struct tree_impl; - std::unique_ptr<tree_impl> impl_; -}; +namespace ocl +{ + + /// \brief This class implements a rope type for any **CharT** type. + /// \note Specializations are available as `crope` and `wrope`. + /// \author Amlal El Mahrouss + template <class CharT, class Traits = std::char_traits<CharT>, class Allocator = std::allocator<CharT>> + class basic_rope final + { + public: + using traits_type = Traits; + using value_type = CharT; + using allocator_type = Allocator; + using size_type = std::allocator_traits<Allocator>::size_type; + using reference = CharT&; + using const_reference = const CharT&; + using pointer = std::allocator_traits<Allocator>::pointer; + using const_pointer = std::allocator_traits<Allocator>::pointer; + + CharT* begin(); + CharT* end(); + size_type size(); + bool empty() const; + + ~basic_rope(); + basic_rope(const boost::core::basic_string_view<CharT>& in = {}); + + basic_rope& operator=(const basic_rope&& rope); + basic_rope(const basic_rope&& rope); + + private: + struct tree_impl; + tree_impl* impl_{}; + }; #if __cplusplus >= 201811L -using u8rope = basic_rope<char8_t>; + using u8rope = basic_rope<char8_t>; + using u16rope = basic_rope<char16_t>; #endif -using crope = basic_rope<char>; -using wrope = basic_rope<wchar_t>; + using crope = basic_rope<char>; + using wrope = basic_rope<wchar_t>; } // namespace ocl diff --git a/include/ocl/tproc/detail/rope_fwd.inl b/include/ocl/tproc/detail/rope_fwd.inl index 2d11c14..0dd1e92 100644 --- a/include/ocl/tproc/detail/rope_fwd.inl +++ b/include/ocl/tproc/detail/rope_fwd.inl @@ -6,17 +6,73 @@ #ifndef OCL_TPROC_ROPE_FWD_INL #define OCL_TPROC_ROPE_FWD_INL -namespace ocl { +namespace ocl +{ -template <class CharT, class Traits, class Allocator> -struct basic_rope<CharT, Traits, Allocator>::tree_impl {}; + template <class CharT, class Traits, class Allocator> + struct basic_rope<CharT, Traits, Allocator>::tree_impl + { + }; -template <class CharT, class Traits, class Allocator> -basic_rope<CharT, Traits, Allocator>::~basic_rope() = default; + template <class CharT, class Traits, class Allocator> + basic_rope<CharT, Traits, Allocator>::~basic_rope() + { + delete impl_; + impl_ = nullptr; + } -template <class CharT, class Traits, class Allocator> -basic_rope<CharT, Traits, Allocator>::basic_rope( - const boost::basic_string_view<CharT> &in) {} + template <class CharT, class Traits, class Allocator> + basic_rope<CharT, Traits, Allocator>& + basic_rope<CharT, Traits, Allocator>::operator=( + const basic_rope<CharT, Traits, Allocator>&& rope) + { + delete this->impl_; + this->impl_ = rope.impl_; + rope.impl_ = nullptr; + + return *this; + } + + template <class CharT, class Traits, class Allocator> + basic_rope<CharT, Traits, Allocator>::basic_rope( + const basic_rope<CharT, Traits, Allocator>&& rope) + { + delete this->impl_; + this->impl_ = rope.impl_; + rope.impl_ = nullptr; + } + + template <class CharT, class Traits, class Allocator> + basic_rope<CharT, Traits, Allocator>::basic_rope( + const boost::core::basic_string_view<CharT>& in) + : impl_(new tree_impl()) + { + } + + template <class CharT, class Traits, class Allocator> + CharT* basic_rope<CharT, Traits, Allocator>::begin() + { + return nullptr; + } + + template <class CharT, class Traits, class Allocator> + CharT* basic_rope<CharT, Traits, Allocator>::end() + { + return nullptr; + } + + template <class CharT, class Traits, class Allocator> + basic_rope<CharT, Traits, Allocator>::size_type + basic_rope<CharT, Traits, Allocator>::size() + { + return 0UL; + } + + template <class CharT, class Traits, class Allocator> + bool basic_rope<CharT, Traits, Allocator>::empty() const + { + return true; + } } // namespace ocl diff --git a/include/ocl/tproc/rope.hpp b/include/ocl/tproc/rope.hpp index 86f1c5e..9a072c9 100644 --- a/include/ocl/tproc/rope.hpp +++ b/include/ocl/tproc/rope.hpp @@ -8,4 +8,15 @@ #include <ocl/tproc/detail/rope_fwd.hpp> +namespace ocl::tproc +{ + + template <typename It, class Pred> + It find(It begin, It end, Pred callable); + + template <typename It, class Callable> + It find_if(It begin, It end, Callable callable); + +} // namespace ocl::tproc + #endif // __OCL_TPROC_ROPE_HPP
\ No newline at end of file |
