mFrame
載入中...
搜尋中...
無符合項目
Readable.h
1
8#ifndef MFRAME_C433E89F_1FFA_4FA6_856A_0FD0C2327CD6
9#define MFRAME_C433E89F_1FFA_4FA6_856A_0FD0C2327CD6
10
11/* ***************************************************************************************
12 * Include
13 */
14
15//----------------------------------------------------------------------------------------
16#include "./../lang/Interface.h"
17#include "./../lang/Iterable.h"
18
19//----------------------------------------------------------------------------------------
20
21/* ***************************************************************************************
22 * Namespace
23 */
24namespace ufm::lang {
25 struct Readable;
26 struct Appendable;
27} // namespace ufm::lang
28
29/* ***************************************************************************************
30 * Class/struct/Struct/Enum
31 */
32
46struct ufm::lang::Readable : public ufm::lang::Iterable<const char> {
47 /* *************************************************************************************
48 * Method
49 */
50
55 virtual int avariable(void) const abstract;
56
63 virtual int pollByte(char& result) abstract;
64
70 virtual int poll(ufm::lang::Appendable& appendable) abstract;
71
78 virtual int poll(void* pointer, int length) abstract;
79
80 /* *************************************************************************************
81 * Default
82 */
83
89 inline bool isEmpty(void) const {
90 return (this->avariable() == 0);
91 }
92
98 inline int poll(ufm::lang::Appendable&& appendable) {
99 return this->poll(appendable);
100 }
101
107 inline int skip(int length) {
108 return this->poll(nullptr, length);
109 }
110};
111
112/* ***************************************************************************************
113 * End of file
114 */
115
116#endif /* MFRAME_C433E89F_1FFA_4FA6_856A_0FD0C2327CD6 */
Definition Appendable.h:23
資料附加介面 (Appendable)
Definition Appendable.h:43
[Interface] 定義可迭代集合介面
Definition Iterable.h:49
[Interface] 定義資料讀取介面
Definition Readable.h:46
virtual int avariable(void) const override
取得可讀取的資料數量
int skip(int length)
跳過緩衝區中指定數量的資料
Definition Readable.h:107
virtual int poll(void *pointer, int length) override
從緩衝區讀取指定長度的資料到指定的記憶體位置
virtual int poll(ufm::lang::Appendable &appendable) override
從緩衝區讀取資料並寫入到Appendable物件中
int poll(ufm::lang::Appendable &&appendable)
從緩衝區讀取資料到臨時Appendable物件中
Definition Readable.h:98
bool isEmpty(void) const
檢查緩衝區是否為空
Definition Readable.h:89
virtual int pollByte(char &result) override
讀取一個字節並將其從緩衝區移除