ref<StringArrayList> FastLogReader::ReadTextColumns(WCHAR separator) { if (IsEof()) return NULL; std::wstring16 seg; ref<StringArrayList> r = gc_new<StringArrayList>(); while (!IsEof()) { WCHAR ch = ReadChar(); if (ch == separator) { r->Add(stringx(seg)); seg.clear(); } else if (ch == 10) // \n { r->Add(stringx(seg)); return r; } else if (ch == 13) // \r, \r\n { if (PeekByte() == 10) ReadByte(); r->Add(stringx(seg)); return r; } else seg += ch; } r->Add(stringx(seg)); return r; }
void ParsePositions(Builder& builder) const { std::vector<PositionEntry> positions; uint_t loop = 0; PositionEntry entry; for (std::size_t posCursor = fromLE(Source.PositionsOffset); ; ++posCursor) { Require(positions.size() <= MAX_POSITIONS_COUNT); const uint_t val = PeekByte(posCursor); if (val == 0xff) { break; } else if (val == 0xfe) { loop = positions.size(); } else if (val >= 0x60) { entry.Transposition = val - 0x60; } else { Require(0 == val % 3); entry.PatternIndex = val / 3; positions.push_back(entry); } } Require(!positions.empty()); builder.SetPositions(positions, loop); Dbg("Positions: %1% entries, loop to %2%", positions.size(), loop); }
bool FastLogReader::ReadTextColumns(REF std::wstring16& buffer, REF std::vector<FastLogReader::Seg>& segs, WCHAR separator) { if (IsEof()) return false; buffer.clear(); segs.clear(); int pb = 0, pc = 0; while (!IsEof()) { WCHAR ch = ReadChar(); buffer += ch; if (ch == separator) { segs.push_back(Seg(pb, pc - pb)); pb = pc + 1; } else if (ch == 10) // \n { segs.push_back(Seg(pb, pc - pb)); return true; } else if (ch == 13) // \r, \r\n { if (PeekByte() == 10) ReadByte(); segs.push_back(Seg(pb, pc - pb)); return true; } ++pc; } return true; }
// Core functionallity. bool Bytebuffer::ReadDatatype(eBytebufferType Type) { if (PeekByte() == (uint8_t)Type) SetPosition(GetPosition() + 1); else return false; return true; }
void CEgIStream::Readln() { unsigned char p, c = GetByte(); while ( noErr() && c != 13 && c != 10 ) // Stop on a CR or LFor error c = GetByte(); p = PeekByte(); if ( ( p == 13 && c == 10 ) || ( p == 10 && c == 13 ) ) GetByte(); }
void StormMessageReaderCursor::SkipWhiteSpace() { while (m_DataLength > 0) { auto b = PeekByte(); if (b == ' ' || b == '\t' || b == '\r' || b == '\n') { Advance(1); } else { return; } } }
void CEgIStream::Readln( UtilStr* outStr ) { unsigned char p, c = GetByte(); if ( outStr ) { outStr -> Wipe(); while ( noErr() && c != 13 && c != 10 ) { // Stop on a CR or LF or error outStr -> Append( (char) c ); c = GetByte(); } p = PeekByte(); if ( ( p == 13 && c == 10 ) || ( p == 10 && c == 13 ) ) GetByte(); } }
uint32_t StormMessageReaderCursor::HashUntilDelimiter(char delimiter) { Hash hash = crc32begin(); while (m_DataLength > 0) { char c = PeekByte(); if (c == delimiter) { return crc32end(hash); } hash = crc32additive(hash, c); Advance(1); } return crc32end(hash); }
uint32_t StormMessageReaderCursor::HashRemainingData(bool include_spaces) { Hash hash = crc32begin(); while (m_DataLength > 0) { char c = PeekByte(); if (c == ' ') { continue; } hash = crc32additive(hash, c); Advance(1); } return crc32end(hash); }
unsigned char CEgIStream::PeekByte() { register unsigned char c; if ( mIsTied ) { if ( mPos != 0 ) c = *((unsigned char*) mNextPtr); } else if ( mPos < long(mBufPos + mStrLen) && mPos >= mBufPos ) c = *((unsigned char*) mNextPtr); else if ( noErr() ) { fillBuf(); if ( noErr() ) c = PeekByte(); else throwErr( cNoErr ); } return c; }