diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-12-26 09:30:37 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2025-12-26 09:30:37 +0100 |
| commit | 932101ae44d6fc43e9facff898ed769d1d1099ec (patch) | |
| tree | 35d2611b0354fdd9406719d3f41390334f25d8da | |
| parent | a5fbde90e35c3ed38a70377249a0e0ecd91901ab (diff) | |
feat: API additions and rope_fwd fixes.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
| -rw-r--r-- | include/ocl/tproc/detail/rope_fwd.hpp | 2 | ||||
| -rw-r--r-- | include/ocl/tproc/detail/rope_fwd.inl | 20 | ||||
| -rw-r--r-- | include/ocl/tproc/rope.hpp | 12 | ||||
| -rw-r--r-- | test/rope_test/crope.test.cpp | 5 |
4 files changed, 26 insertions, 13 deletions
diff --git a/include/ocl/tproc/detail/rope_fwd.hpp b/include/ocl/tproc/detail/rope_fwd.hpp index 7a9bca5..f694269 100644 --- a/include/ocl/tproc/detail/rope_fwd.hpp +++ b/include/ocl/tproc/detail/rope_fwd.hpp @@ -11,7 +11,7 @@ /// \file rope_fwd.hpp /// \brief Basic forward definitions of the `rope` type. -namespace ocl +namespace ocl::tproc { /// \brief This class implements a rope type for any **CharT** type. diff --git a/include/ocl/tproc/detail/rope_fwd.inl b/include/ocl/tproc/detail/rope_fwd.inl index 852e065..11ed792 100644 --- a/include/ocl/tproc/detail/rope_fwd.inl +++ b/include/ocl/tproc/detail/rope_fwd.inl @@ -6,12 +6,18 @@ #ifndef OCL_TPROC_ROPE_FWD_INL #define OCL_TPROC_ROPE_FWD_INL -namespace ocl +namespace ocl::tproc { template <class CharT, class Traits, class Allocator> struct basic_rope<CharT, Traits, Allocator>::tree_impl { + size_t size_; + CharT* head_, tail_; + + size_t size() { return size_; } + CharT* begin() { return head_; } + CharT* end() { return tail_; } }; template <class CharT, class Traits, class Allocator> @@ -24,7 +30,7 @@ namespace ocl template <class CharT, class Traits, class Allocator> basic_rope<CharT, Traits, Allocator>& basic_rope<CharT, Traits, Allocator>::operator=( - basic_rope<CharT, Traits, Allocator>&& rope) + basic_rope<CharT, Traits, Allocator>&& other) { impl_ = std::exchange(other.impl_); return *this; @@ -32,7 +38,7 @@ namespace ocl template <class CharT, class Traits, class Allocator> basic_rope<CharT, Traits, Allocator>::basic_rope( - basic_rope<CharT, Traits, Allocator>&& rope) + basic_rope<CharT, Traits, Allocator>&& other) { impl_ = std::exchange(other.impl_); rope.impl_ = nullptr; @@ -48,26 +54,26 @@ namespace ocl template <class CharT, class Traits, class Allocator> CharT* basic_rope<CharT, Traits, Allocator>::begin() { - return nullptr; + return impl_->begin(); } template <class CharT, class Traits, class Allocator> CharT* basic_rope<CharT, Traits, Allocator>::end() { - return nullptr; + return impl_->end(); } template <class CharT, class Traits, class Allocator> basic_rope<CharT, Traits, Allocator>::size_type basic_rope<CharT, Traits, Allocator>::size() { - return 0UL; + return impl_->size(); } template <class CharT, class Traits, class Allocator> bool basic_rope<CharT, Traits, Allocator>::empty() const { - return true; + return impl_->size() < 1; } } // namespace ocl diff --git a/include/ocl/tproc/rope.hpp b/include/ocl/tproc/rope.hpp index 9a072c9..c0fd756 100644 --- a/include/ocl/tproc/rope.hpp +++ b/include/ocl/tproc/rope.hpp @@ -8,14 +8,20 @@ #include <ocl/tproc/detail/rope_fwd.hpp> -namespace ocl::tproc +namespace ocl::tproc::rope { template <typename It, class Pred> - It find(It begin, It end, Pred callable); + It find(It begin, It end, Pred); template <typename It, class Callable> - It find_if(It begin, It end, Callable callable); + It find_if(It begin, It end, Callable); + + template <typename It, class Pred> + size_t erase(It begin, It end, Pred); + + template <typename It, class Callable> + size_t erase_if(It begin, It end, Callable); } // namespace ocl::tproc diff --git a/test/rope_test/crope.test.cpp b/test/rope_test/crope.test.cpp index 061da98..4565900 100644 --- a/test/rope_test/crope.test.cpp +++ b/test/rope_test/crope.test.cpp @@ -12,12 +12,13 @@ BOOST_AUTO_TEST_CASE(allocator_should_succeed_in_empty) { - auto rope = ocl::crope(""); + auto rope = ocl::tproc::crope(""); BOOST_TEST(rope.empty() == true); } BOOST_AUTO_TEST_CASE(allocator_should_not_succeed_in_empty) { - auto rope = ocl::crope("foobar"); + auto rope = ocl::tproc::crope("foobar"); + // rope += ".txt"; BOOST_TEST(rope.empty() == false); } |
