mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-11-30 02:58:26 +08:00
improve iostream
This commit is contained in:
parent
e0f4b42c2d
commit
56e39cc852
@ -1,6 +1,8 @@
|
||||
# 最新动态
|
||||
|
||||
* 2019/12/29
|
||||
* 使用event\_source\_manager实现主循环。
|
||||
* iostream增加几个包装函数。
|
||||
|
||||
* 2019/12/27
|
||||
* 增加str\_from\_wstr\_with\_len
|
||||
|
@ -32,3 +32,30 @@ tk_ostream_t* tk_iostream_get_ostream(tk_iostream_t* stream) {
|
||||
|
||||
return stream->get_ostream(stream);
|
||||
}
|
||||
|
||||
int32_t tk_iostream_read(tk_iostream_t* stream, uint8_t* buff, uint32_t max_size) {
|
||||
tk_istream_t* is = tk_iostream_get_istream(stream);
|
||||
|
||||
return tk_istream_read(is, buff, max_size);
|
||||
}
|
||||
|
||||
int32_t tk_iostream_read_len(tk_iostream_t* stream, uint8_t* buff, uint32_t max_size,
|
||||
uint32_t timeout_ms) {
|
||||
tk_istream_t* is = tk_iostream_get_istream(stream);
|
||||
|
||||
return tk_istream_read_len(is, buff, max_size, timeout_ms);
|
||||
}
|
||||
|
||||
int32_t tk_iostream_write(tk_iostream_t* stream, const uint8_t* buff, uint32_t max_size) {
|
||||
tk_ostream_t* os = tk_iostream_get_ostream(stream);
|
||||
|
||||
return tk_ostream_write(os, buff, max_size);
|
||||
}
|
||||
|
||||
int32_t tk_iostream_write_len(tk_iostream_t* stream, const uint8_t* buff, uint32_t max_size,
|
||||
uint32_t timeout_ms) {
|
||||
tk_ostream_t* os = tk_iostream_get_ostream(stream);
|
||||
|
||||
return tk_ostream_write_len(os, buff, max_size, timeout_ms);
|
||||
}
|
||||
|
||||
|
@ -72,6 +72,66 @@ tk_istream_t* tk_iostream_get_istream(tk_iostream_t* stream);
|
||||
*/
|
||||
tk_ostream_t* tk_iostream_get_ostream(tk_iostream_t* stream);
|
||||
|
||||
/**
|
||||
* @method tk_iostream_read
|
||||
*
|
||||
* 读取数据。
|
||||
*
|
||||
* @param {tk_iostream_t*} stream iostream对象。
|
||||
* @param {uint8_t*} buff 返回数据的缓冲区。
|
||||
* @param {uint32_t} max_size 缓冲区的大小。
|
||||
*
|
||||
* @return {int32_t} 返回负数表示读取失败,否则返回实际读取数据的长度。
|
||||
*
|
||||
*/
|
||||
int32_t tk_iostream_read(tk_iostream_t* stream, uint8_t* buff, uint32_t max_size);
|
||||
|
||||
/**
|
||||
* @method tk_iostream_read_len
|
||||
*
|
||||
* 读取指定长度的数据。
|
||||
*
|
||||
* @param {tk_iostream_t*} stream iostream对象。
|
||||
* @param {uint8_t*} buff 返回数据的缓冲区。
|
||||
* @param {uint32_t} max_size 缓冲区的大小。
|
||||
* @param {uint32_t} timeout_ms timeout.
|
||||
*
|
||||
* @return {int32_t} 返回负数表示读取失败,否则返回实际读取数据的长度。
|
||||
*
|
||||
*/
|
||||
int32_t tk_iostream_read_len(tk_iostream_t* stream, uint8_t* buff, uint32_t max_size,
|
||||
uint32_t timeout_ms);
|
||||
|
||||
/**
|
||||
* @method tk_iostream_write
|
||||
*
|
||||
* 写入数据。
|
||||
*
|
||||
* @param {tk_iostream_t*} stream iostream对象。
|
||||
* @param {const uint8_t*} buff 返回数据的缓冲区。
|
||||
* @param {uint32_t} max_size 缓冲区的大小。
|
||||
*
|
||||
* @return {int32_t} 返回负数表示写入失败,否则返回实际写入数据的长度。
|
||||
*
|
||||
*/
|
||||
int32_t tk_iostream_write(tk_iostream_t* stream, const uint8_t* buff, uint32_t max_size);
|
||||
|
||||
/**
|
||||
* @method tk_iostream_write_len
|
||||
*
|
||||
* 写入指定长度的数据。
|
||||
*
|
||||
* @param {tk_iostream_t*} stream iostream对象。
|
||||
* @param {const uint8_t*} buff 数据的缓冲区。
|
||||
* @param {uint32_t} max_size 缓冲区的大小。
|
||||
* @param {uint32_t} timeout_ms timeout.
|
||||
*
|
||||
* @return {int32_t} 返回负数表示写入失败,否则返回实际写入数据的长度。
|
||||
*
|
||||
*/
|
||||
int32_t tk_iostream_write_len(tk_iostream_t* stream, const uint8_t* buff, uint32_t max_size,
|
||||
uint32_t timeout_ms);
|
||||
|
||||
#define TK_IOSTREAM(obj) ((tk_iostream_t*)(obj))
|
||||
|
||||
END_C_DECLS
|
||||
|
Loading…
Reference in New Issue
Block a user