add:添加get_len接口。

This commit is contained in:
taynpg 2024-12-11 22:49:46 +08:00
parent 79e086bae5
commit 0f7a8d3c92
2 changed files with 7 additions and 0 deletions

View File

@ -4,6 +4,7 @@
#include <iostream>
#include <memory>
#include <mutex>
#include <vector>
#include <algorithm>
#include <cstring>
@ -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:

View File

@ -33,6 +33,11 @@ const char* CMutBuffer::get_data() const
return buffer_.data();
}
int CMutBuffer::get_len() const
{
return static_cast<int>(buffer_.size());
}
void CMutBuffer::clear()
{
std::lock_guard<std::mutex> lock(mutex_);