summaryrefslogtreecommitdiffhomepage
path: root/include/ocl
diff options
context:
space:
mode:
Diffstat (limited to 'include/ocl')
-rw-r--r--include/ocl/tproc.hpp1
-rw-r--r--include/ocl/tproc/detail/config.hpp10
-rw-r--r--include/ocl/tproc/detail/rope_fwd.hpp3
-rw-r--r--include/ocl/tproc/detail/rope_fwd.inl26
-rw-r--r--include/ocl/tproc/rope.hpp92
-rw-r--r--include/ocl/tproc/rope.inl86
6 files changed, 193 insertions, 25 deletions
diff --git a/include/ocl/tproc.hpp b/include/ocl/tproc.hpp
index a23b91c..b4c4778 100644
--- a/include/ocl/tproc.hpp
+++ b/include/ocl/tproc.hpp
@@ -8,5 +8,6 @@
#include <ocl/tproc/detail/config.hpp>
#include <ocl/tproc/rope.hpp>
+//#include <ocl/tproc/regex.hpp>
#endif // __OCL_TPROC_HPP
diff --git a/include/ocl/tproc/detail/config.hpp b/include/ocl/tproc/detail/config.hpp
index e9880fd..89026a2 100644
--- a/include/ocl/tproc/detail/config.hpp
+++ b/include/ocl/tproc/detail/config.hpp
@@ -12,16 +12,6 @@
#include <ocl/equiv.hpp>
#include <ocl/option.hpp>
#include <ocl/smart_ptr.hpp>
-
#include <boost/core/detail/string_view.hpp>
-namespace ocl
-{
-
- namespace pmr
- {
- }
-
-} // namespace ocl
-
#endif // ifndef __OCL_TPROC_CONFIG
diff --git a/include/ocl/tproc/detail/rope_fwd.hpp b/include/ocl/tproc/detail/rope_fwd.hpp
index 912d889..a172f90 100644
--- a/include/ocl/tproc/detail/rope_fwd.hpp
+++ b/include/ocl/tproc/detail/rope_fwd.hpp
@@ -49,6 +49,9 @@ namespace ocl::tproc
~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);
+
basic_rope& operator=(basic_rope&& rope);
basic_rope(basic_rope&& rope);
diff --git a/include/ocl/tproc/detail/rope_fwd.inl b/include/ocl/tproc/detail/rope_fwd.inl
index 1d282bb..6951b20 100644
--- a/include/ocl/tproc/detail/rope_fwd.inl
+++ b/include/ocl/tproc/detail/rope_fwd.inl
@@ -12,17 +12,21 @@ namespace ocl::tproc
template <class CharT, class Traits, class Allocator>
struct basic_rope<CharT, Traits, Allocator>::tree_impl
{
- size_t size_;
- CharT *head_, tail_;
+ private:
+ std::allocator_traits<Allocator>::size_type size_;
+ CharT *head_, tail_{};
- size_t size()
+ public:
+ std::allocator_traits<Allocator>::size_type size()
{
return size_;
}
+
CharT* begin()
{
return head_;
}
+
CharT* end()
{
return tail_;
@@ -53,6 +57,20 @@ namespace ocl::tproc
}
template <class CharT, class Traits, class Allocator>
+ basic_rope<CharT, Traits, Allocator>&
+ basic_rope<CharT, Traits, Allocator>::operator=(basic_rope&& other)
+ {
+ impl_ = std::exchange(other.impl_);
+ return *this;
+ }
+
+ template <class CharT, class Traits, class Allocator>
+ basic_rope<CharT, Traits, Allocator>::basic_rope(basic_rope&& other)
+ {
+ impl_ = std::exchange(other.impl_);
+ }
+
+ 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())
@@ -81,7 +99,7 @@ namespace ocl::tproc
template <class CharT, class Traits, class Allocator>
bool basic_rope<CharT, Traits, Allocator>::empty() const
{
- return impl_->size() < 1;
+ return impl_->size() < 1UL;
}
} // namespace ocl::tproc
diff --git a/include/ocl/tproc/rope.hpp b/include/ocl/tproc/rope.hpp
index 968b704..9d9356a 100644
--- a/include/ocl/tproc/rope.hpp
+++ b/include/ocl/tproc/rope.hpp
@@ -7,28 +7,98 @@
#define __OCL_TPROC_ROPE_HPP
#include <ocl/tproc/detail/rope_fwd.hpp>
+#include <string>
namespace ocl::tproc::rope
{
- struct reverse_pred;
- struct uppercase_pred;
- struct lowercase_pred;
- struct exact_pred;
- struct starts_with_pred;
+ class reverse_pred
+ {
+ std::string cond_;
+
+ public:
+ reverse_pred(const boost::core::string_view& cond)
+ : cond_(cond)
+ {
+ }
+
+ template <typename It>
+ It operator()(It begin, It end);
+ };
+
+ class uppercase_pred
+ {
+ std::string cond_;
+
+ public:
+ uppercase_pred(const boost::core::string_view& cond)
+ : cond_(cond)
+ {
+ }
+
+ template <typename It>
+ It operator()(It begin, It end);
+ };
+
+ class lowercase_pred
+ {
+ std::string cond_;
+
+ public:
+ lowercase_pred(const boost::core::string_view& cond)
+ : cond_(cond)
+ {
+ }
+
+ template <typename It>
+ It operator()(It begin, It end);
+ };
+
+ class exact_pred
+ {
+ std::string cond_;
+
+ public:
+ exact_pred(const boost::core::string_view& cond)
+ : cond_(cond)
+ {
+ }
+
+ template <typename It>
+ It operator()(It begin, It end);
+ };
+
+ class starts_with_pred
+ {
+ std::string cond_;
+
+ public:
+ starts_with_pred(const boost::core::string_view& cond)
+ : cond_(cond)
+ {
+ }
+
+ template <typename It>
+ It operator()(It begin, It end);
+ };
+
+} // namespace ocl::tproc::rope
+
+namespace ocl::tproc
+{
template <typename It, class Pred>
It find(It begin, It end, Pred);
- template <typename It, class Callable>
- It find_if(It begin, It end, Callable);
+ template <typename It, class Pred>
+ It find_if(It begin, It end, Pred);
template <typename It, class Pred>
- size_t erase(It begin, It end, Pred);
+ It::typename size_type erase(It begin, It end, Pred);
- template <typename It, class Callable>
- size_t erase_if(It begin, It end, Callable);
+ template <typename It, class Pred>
+ It::typename size_type erase_if(It begin, It end, Pred);
-} // namespace ocl::tproc::rope
+} // namespace ocl::tproc
#endif // __OCL_TPROC_ROPE_HPP
diff --git a/include/ocl/tproc/rope.inl b/include/ocl/tproc/rope.inl
new file mode 100644
index 0000000..fe4218e
--- /dev/null
+++ b/include/ocl/tproc/rope.inl
@@ -0,0 +1,86 @@
+// Copyright 2025, Amlal El Mahrouss (amlal@nekernel.org)
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+// Official repository: https://github.com/ocl-org/tproc
+
+#ifndef __OCL_TPROC_ROPE_INL
+#define __OCL_TPROC_ROPE_INL
+
+namespace ocl::tproc::rope
+{
+
+ template <typename It, class Pred>
+ It find(It begin, It end, Pred pred)
+ {
+ for (auto it = begin; it != end; ++it)
+ {
+ if (*it == pred)
+ {
+ return it;
+ }
+ }
+
+ return end;
+ }
+
+ template <typename It, class Pred>
+ It find_if(It begin, It end, Pred pred)
+ {
+ for (auto it = begin; it != end; ++it)
+ {
+ if (pred(it, pred))
+ {
+ return it;
+ }
+ }
+
+ return end;
+ }
+
+ template <typename It, class Pred>
+ It::typename size_type erase(It begin, It end, Pred)
+ {
+ It original_begin = begin;
+ size_t count = 0;
+
+ for (auto it = begin; it != end; )
+ {
+ if (*it == pred)
+ {
+ it = begin.erase(it);
+ ++count;
+ }
+ else
+ {
+ ++it;
+ }
+ }
+
+ return count;
+ }
+
+ template <typename It, class Pred>
+ It::typename size_type erase_if(It begin, It end, Pred)
+ {
+ It original_begin = begin;
+ size_t count = 0;
+
+ for (auto it = begin; it != end; )
+ {
+ if (pred(it, end) != end)
+ {
+ it = begin.erase(it);
+ ++count;
+ }
+ else
+ {
+ ++it;
+ }
+ }
+
+ return count;
+ }
+
+} // namespace ocl::tproc::rope
+
+#endif \ No newline at end of file