Skip to content

Commit 03015e6

Browse files
committed
tidy:解决modules/network/buffer.h编码不是utf-8的问题
1 parent c05ae0b commit 03015e6

File tree

2 files changed

+36
-28
lines changed

2 files changed

+36
-28
lines changed

CONTRIBUTING.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,15 @@ Fix it, then add corresponding unit test case in `xxx_test.cpp`.
2424

2525
If you add new components named `xxx`.
2626

27-
1. You should added xxx.cpp and xxx.h files.
28-
2. You should add the corresponding xxx\_test.cpp files in the same directory and implement its unit test cases, and make sure all unit tests pass.
27+
1. You should added `xxx.cpp` and `xxx.h` files.
28+
2. You should add the corresponding `xxx_test.cpp` files in the same directory and implement its unit test cases, and make sure all unit tests pass.
2929
3. You'd better also implement the corresponding sample program to show how to use this module.
3030

31+
File require:
32+
33+
- Formart: unix
34+
- Encoding: utf-8
35+
36+
## Pull request
37+
38+
- Pull request to develop branch, not master.

modules/network/buffer.h

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ namespace tbox {
2626
namespace network {
2727

2828
/**
29-
* 缓冲区类
29+
* 缓冲区类
3030
*
3131
* buffer_ptr_ buffer_size_
3232
* | |
@@ -38,17 +38,17 @@ namespace network {
3838
* | |
3939
* read_index_ write_index_
4040
*
41-
* 使用示例:
41+
* 使用示例:
4242
* Buffer b;
43-
* b.append("abc", 4); //! 往缓冲中写入4字节的数据
43+
* b.append("abc", 4); //! 往缓冲中写入4字节的数据
4444
* char buff[10];
45-
* b.fetch(buff, 4); //! 从缓冲中取出4字节的数据
45+
* b.fetch(buff, 4); //! 从缓冲中取出4字节的数据
4646
*
47-
* b.ensureWritableSize(10); //! 预留10个字节
48-
* memset(b.writableBegin(), 0xcc, 10); //! 将该10个字节全置为0xcc
49-
* b.hasWritten(10); //! 标该已写入10个字节
47+
* b.ensureWritableSize(10); //! 预留10个字节
48+
* memset(b.writableBegin(), 0xcc, 10); //! 将该10个字节全置为0xcc
49+
* b.hasWritten(10); //! 标该已写入10个字节
5050
*
51-
* \warnning 多线程使用需在外部加锁
51+
* \warnning 多线程使用需在外部加锁
5252
*/
5353
class Buffer {
5454
public:
@@ -68,62 +68,62 @@ class Buffer {
6868

6969
public:
7070
/**
71-
* 写缓冲操作
71+
* 写缓冲操作
7272
*/
7373

74-
//! 获取可写空间大小
74+
//! 获取可写空间大小
7575
inline size_t writableSize() const { return buffer_size_ - write_index_; }
7676

77-
//! 保障有指定容量的可写空间
77+
//! 保障有指定容量的可写空间
7878
bool ensureWritableSize(size_t write_size);
7979

80-
//! 获取写首地址
80+
//! 获取写首地址
8181
inline uint8_t* writableBegin() const {
8282
return (buffer_ptr_ != nullptr) ? (buffer_ptr_ + write_index_) : nullptr;
8383
}
8484

85-
//! 标记已写入数据大小
85+
//! 标记已写入数据大小
8686
void hasWritten(size_t write_size);
8787

88-
//! 往缓冲区追加指定的数据块,返回实现写入的大小
88+
//! 往缓冲区追加指定的数据块,返回实现写入的大小
8989
size_t append(const void *p_data, size_t data_size);
9090

9191
/**
92-
* 读缓冲操作
92+
* 读缓冲操作
9393
*/
9494

95-
//! 获取可读区域大小
95+
//! 获取可读区域大小
9696
inline size_t readableSize() const { return write_index_ - read_index_; }
9797

98-
//! 获取可读区首地址
98+
//! 获取可读区首地址
9999
inline uint8_t* readableBegin() const {
100100
return (buffer_ptr_ != nullptr) ? (buffer_ptr_ + read_index_) : nullptr;
101101
}
102102

103-
//! 标记已读数据大小
103+
//! 标记已读数据大小
104104
void hasRead(size_t read_size);
105105

106-
//! 标记已读取全部数据
106+
//! 标记已读取全部数据
107107
void hasReadAll();
108108

109-
//! 从缓冲区读取指定的数据块,返回实际读到的数据大小
109+
//! 从缓冲区读取指定的数据块,返回实际读到的数据大小
110110
size_t fetch(void *p_buff, size_t buff_size);
111111

112112
/**
113-
* 其它
113+
* 其它
114114
*/
115-
//! 缩减缓冲多余容量
115+
//! 缩减缓冲多余容量
116116
void shrink();
117117

118118
protected:
119119
void cloneFrom(const Buffer &other);
120120

121121
private:
122-
uint8_t *buffer_ptr_ = nullptr; //! 缓冲区地址
123-
size_t buffer_size_ = 0; //! 缓冲区大小
122+
uint8_t *buffer_ptr_ = nullptr; //! 缓冲区地址
123+
size_t buffer_size_ = 0; //! 缓冲区大小
124124

125-
size_t read_index_ = 0; //! 读位置偏移
126-
size_t write_index_ = 0; //! 写位置偏移
125+
size_t read_index_ = 0; //! 读位置偏移
126+
size_t write_index_ = 0; //! 写位置偏移
127127
};
128128

129129
}

0 commit comments

Comments
 (0)