From 0f7a8d3c928ef93c6250fa048b5c1cda2e42ed57 Mon Sep 17 00:00:00 2001 From: taynpg Date: Wed, 11 Dec 2024 22:49:46 +0800 Subject: [PATCH] =?UTF-8?q?add=EF=BC=9A=E6=B7=BB=E5=8A=A0get=5Flen?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/of_util.h | 2 ++ src/of_util.cpp | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/include/of_util.h b/include/of_util.h index 8d97fa5..701d815 100644 --- a/include/of_util.h +++ b/include/of_util.h @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -40,6 +41,7 @@ public: void push(const char* data, int len); int index_of(const char* data, int len, int start_pos = 0); const char* get_data() const; + int get_len() const; void remove_of(int start_pos, int len); void clear(); private: diff --git a/src/of_util.cpp b/src/of_util.cpp index 843afcc..5ca54ad 100644 --- a/src/of_util.cpp +++ b/src/of_util.cpp @@ -33,6 +33,11 @@ const char* CMutBuffer::get_data() const return buffer_.data(); } +int CMutBuffer::get_len() const +{ + return static_cast(buffer_.size()); +} + void CMutBuffer::clear() { std::lock_guard lock(mutex_);