UdonLibrary 1.0.0
機械システム研究部 C++ ライブラリ
読み取り中…
検索中…
一致する文字列を見つけられません
AsyncStreamReader.hpp
[詳解]
1//
2// 非同期ストリーム読み取り
3//
4// Copyright (c) 2022-2024 udonrobo
5//
6
7#pragma once
8
10
11namespace Udon
12{
15 {
16
17 Stream& istream;
18
19 char buffer[256];
20 char* iterator;
21
22 public:
23 AsyncStreamReader(Stream& istream)
24 : istream(istream)
25 , buffer()
26 , iterator(buffer)
27 {
28 }
29
31 {
32 while (istream.available())
33 {
34 const auto read = istream.read();
35
36 if (read == -1)
37 {
38 continue;
39 }
40
41 if (iterator == std::end(buffer))
42 {
43 break;
44 }
45
46 if (read == terminate)
47 {
48 const auto end = iterator;
49 iterator = buffer;
50 return { buffer, end };
51 }
52
53 *iterator = read;
54 ++iterator;
55 }
56
57 return { buffer, (size_t)0 };
58 }
59 };
60
61} // namespace Udon
非同期ストリーム読み取り
Definition AsyncStreamReader.hpp:15
Udon::StringView readStringUntil(char terminate)
Definition AsyncStreamReader.hpp:30
AsyncStreamReader(Stream &istream)
Definition AsyncStreamReader.hpp:23
文字列参照クラス
Definition StringView.hpp:30
Definition Bit.hpp:12