16 #ifndef INCLUDE_NN_NLIB_TEXTREADER_H_ 17 #define INCLUDE_NN_NLIB_TEXTREADER_H_ 44 if (cur_ + 1 < bufend_) {
45 unsigned char c = *
reinterpret_cast<unsigned char*
>(cur_);
46 if (c >
' ')
return 0;
49 c = *
reinterpret_cast<unsigned char*
>(cur_);
54 return this->SkipWs_(1);
57 return this->SkipWs_(0);
62 return this->ReadUntil(len, &buf[0], N, delim);
67 template<
class T,
size_t N>
69 return this->ReadUntil(len, buf, N, pred);
74 return this->ReadDecimalString(buf, N);
78 NLIB_ASSERT(!(c & 0x80) && c != 0x0A);
79 if (cur_ == bufend_) {
81 if (cur_ == bufend_)
return false;
83 if (*cur_ != c)
return false;
90 if (errno_ == 0) errno_ = e;
96 return static_cast<int>((cur_ - &buf_[0]) + 1 + pos_of_buf_ - pos_of_line_);
114 char buf_[512 + 3 + 1];
118 size_t utf8_bytecount_;
119 InputStream* stream_;
120 mutable ErrnoT errno_;
137 char* pend = buf + n;
139 if (cur_ == bufend_) {
141 if (cur_ == bufend_) {
147 while (p != pend && cur_ != bufend_) {
148 if ((*reinterpret_cast<unsigned char*>(cur_) & 0xC0) != 0x80 &&
149 pred((
const char*)cur_)) {
158 if (cur_ != bufend_ && (*reinterpret_cast<unsigned char*>(cur_) & 0xC0) == 0x80) {
162 }
while ((*reinterpret_cast<unsigned char*>(cur_) & 0xC0) == 0x80);
172 #endif // INCLUDE_NN_NLIB_TEXTREADER_H_ bool ReadUntil(size_t *len, nlib_utf8_t(&buf)[N], T pred) noexcept
上記関数のテンプレートオーバーロードです。
#define NLIB_DISALLOW_COPY_AND_ASSIGN(TypeName)
TypeName で指定されたクラスのコピーコンストラクタと代入演算子を禁止します。
#define NLIB_SAFE_BOOL(class_name, exp)
クラス内に安全なoperator bool()を定義します。 可能であればC++11のexplicit boolを利用します。 ...
InputStream * GetStream() noexcept
テキストリーダーが書き込みを行うストリームを取得します。
int GetColumn() const noexcept
現在の桁を取得します。
errno_t GetErrorValue() const noexcept
読み込みが失敗した際に、エラーの原因を取得できます。
size_t ReadDecimalString(char(&buf)[N]) noexcept
上記関数のテンプレートオーバーロードです。
bool Proceed(char c) noexcept
文字c の分だけストリームを進めます。
bool ReadUntil(size_t *len, nlib_utf8_t(&buf)[N], char delim) noexcept
上記関数のテンプレートオーバーロードです。
int GetLine() const noexcept
現在の行番号を取得します。
#define NLIB_NOEXCEPT
環境に合わせてnoexcept 又は同等の定義がされます。
bool Proceed(StringView &str, const StringView &prefix) noexcept
strがprefixで始まっていればその文字列長だけ進めます。
int SkipWs() noexcept
ストリーム内の空白(スペース,改行,タブ,復帰)文字を読み飛ばして、読み飛ばした空白の数を返します。 ...
bool Read(BinaryReader *r, T *x)
この関数テンプレートを特殊化することで、ユーザー定義クラスに読み込むことができます。 ...