2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-16 10:57:02 +00:00

CVarManager: Bring back de/serialization

This commit is contained in:
2022-02-27 17:11:10 -08:00
parent d6f8ca44de
commit c79ddb8c42
13 changed files with 243 additions and 153 deletions

View File

@@ -0,0 +1,24 @@
#include "Runtime/Streams/CTextInStream.hpp"
#include <algorithm>
namespace metaforce {
CTextInStream::CTextInStream(CInputStream& in, int len) : m_in(&in), m_len(len) {}
std::string CTextInStream::GetNextLine() {
std::string ret;
while (true) {
auto chr = m_in->ReadChar();
ret += chr;
if (ret.back() == '\r' || ret.back() == '\n') {
if (ret.back() == '\r') {
m_in->ReadChar();
}
break;
}
}
ret.erase(std::remove(ret.begin(), ret.end(), '\r'), ret.end());
ret.erase(std::remove(ret.begin(), ret.end(), '\n'), ret.end());
return ret;
}
} // namespace metaforce