Introduce Scenario class

This commit is contained in:
kichikuou
2024-12-09 14:44:37 +09:00
parent 8303f7c770
commit 5483d1932f
8 changed files with 329 additions and 317 deletions
+30
View File
@@ -0,0 +1,30 @@
#include "scenario.h"
#include <string.h>
#include "encoding.h"
void Scenario::skip_string(Encoding *enc, uint8_t terminator)
{
for (uint8_t c = getd(); c != terminator; c = getd()) {
if (c != '\\')
ungetd();
skip(enc->mblen(ptr()));
}
}
void Scenario::get_syseng_string(char* buf, int size, Encoding *enc, uint8_t terminator)
{
int start_addr = addr();
int i = 0;
for (uint8_t c = getd(); c != terminator; c = getd()) {
if (c != '\\')
ungetd();
int len = enc->mblen(ptr());
if (i + len < size - 1) {
memcpy(&buf[i], ptr(), len);
i += len;
}
skip(len);
}
buf[i] = '\0';
}