More work on AnimQueueDecoder
This commit is contained in:
@@ -1,17 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "lpx-basewriter.hpp"
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//
|
||||
// StringDecoder
|
||||
// FStringDecoder
|
||||
//
|
||||
// This class is used to decipher 8-bit strings that
|
||||
// contain packed ints, strings, and other data.
|
||||
// The typical example of usage is to decipher the
|
||||
// serialized animation queues fed to us by Luprex.
|
||||
//
|
||||
// The StringDecoder doesn't make a copy of the string
|
||||
// The FStringDecoder doesn't make a copy of the string
|
||||
// you pass in, instead, it stores a pointer to it.
|
||||
// So be sure not to free the string until you're
|
||||
// done analyzing it.
|
||||
@@ -25,7 +26,7 @@
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
|
||||
class StringDecoder : public BaseReader<StringDecoder> {
|
||||
class FStringDecoder : public BaseReader<FStringDecoder> {
|
||||
private:
|
||||
const char* Text;
|
||||
size_t Size;
|
||||
@@ -42,10 +43,9 @@ public:
|
||||
//
|
||||
void read_bytes_into(char* buffer, size_t size) {
|
||||
if (size > Size) {
|
||||
ErrBeyondEOF = true;
|
||||
memset(buffer, 0, size);
|
||||
Text += Size;
|
||||
Size = 0;
|
||||
ErrBeyondEOF = true;
|
||||
set_at_eof();
|
||||
}
|
||||
else {
|
||||
memcpy(buffer, Text, size);
|
||||
@@ -68,20 +68,19 @@ public:
|
||||
|
||||
// Initialize the string decoder with a text to analyze.
|
||||
//
|
||||
StringDecoder(const char* text, int size) {
|
||||
Text = text;
|
||||
Size = size;
|
||||
ErrBeyondEOF = false;
|
||||
ErrStringTooLong = false;
|
||||
}
|
||||
FStringDecoder(std::string_view s);
|
||||
|
||||
// Get the size of the remaining text.
|
||||
//
|
||||
size_t GetSize() { return Size; }
|
||||
size_t get_size() { return Size; }
|
||||
|
||||
// Return true if the remaining text is empty.
|
||||
//
|
||||
bool AtEOF() { return Size == 0; }
|
||||
bool at_eof() { return Size == 0; }
|
||||
|
||||
// Move the cursor to EOF.
|
||||
//
|
||||
void set_at_eof();
|
||||
|
||||
// Read a string as a string_view
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user