39 lines
757 B
C++
39 lines
757 B
C++
#include "StringDecoder.h"
|
|
|
|
FlxStringDecoder::FlxStringDecoder(std::string_view s) {
|
|
Text = s.data();
|
|
Size = s.size();
|
|
ErrBeyondEOF = false;
|
|
ErrStringTooLong = false;
|
|
}
|
|
|
|
void FlxStringDecoder::Reset(std::string_view s, bool clear) {
|
|
Text = s.data();
|
|
Size = s.size();
|
|
if (clear) {
|
|
ErrBeyondEOF = false;
|
|
ErrStringTooLong = false;
|
|
}
|
|
}
|
|
|
|
std::string_view FlxStringDecoder::GetRest() {
|
|
return std::string_view(Text, Size);
|
|
}
|
|
|
|
std::string_view FlxStringDecoder::read_string_view() {
|
|
size_t length = read_length();
|
|
if (length > Size) {
|
|
ErrBeyondEOF = true;
|
|
return std::string_view();
|
|
}
|
|
std::string_view result(Text, length);
|
|
Text += length;
|
|
Size -= length;
|
|
return result;
|
|
}
|
|
|
|
void FlxStringDecoder::set_at_eof() {
|
|
Text += Size;
|
|
Size = 0;
|
|
}
|