summaryrefslogtreecommitdiff
path: root/ZAPDUtils/Utils/BinaryReader.cpp
diff options
context:
space:
mode:
authorNicholas Estelami <NEstelami@users.noreply.github.com>2021-08-08 13:51:51 -0400
committerGitHub <noreply@github.com>2021-08-08 13:51:51 -0400
commit0fb7568ec0d07ea414f8c3f286de352e9606d016 (patch)
treedeba58f4cf06f669aa14e85462055d63b4bc6e99 /ZAPDUtils/Utils/BinaryReader.cpp
parent82bd27604a4c8f8c1f01f9c2f54c87fab103c39f (diff)
Moved utility code into its own library (#162)
* Initial exporter implementation * Updated to use static library. * minor cleanup * Cleaned things up a bit * Fixed merge issues * Minor commenting * Added Begin and End functions, and removed HL stuff (to be turned into an exporter at a later date) * Cleaned some stuff up * Additional cleanup * Removed some commented out code * Fixed compilation issues * Cleanup * Fixed merge issues * Got rid of unused windows.h includes * Cleanup * Fixed warning * Removed additional redundancies * Cleanup * Fixed merge issues * Fixed some compiler issues, added makefile for exportertest. * Removed redundancies and clang formatted * Made sure exportertest compiles with C++17 * Moved certain files into new "Utils" folder. * GetExporterMap uses a reference now * Minor fixes and updates. * Moved utility code into its own library * Fixed merge issues * Fixed compilation issue * Added missing classes * Updated makefile * Minor update * Forgot to make an enum an 'enum class' * Minor fix * Few more adjustments * Bug fix * Another bug fix * Bug fix again * added comment * New functions added for exporters * Made certain fields public Co-authored-by: Jack Walker <7463599+Jack-Walker@users.noreply.github.com>
Diffstat (limited to 'ZAPDUtils/Utils/BinaryReader.cpp')
-rw-r--r--ZAPDUtils/Utils/BinaryReader.cpp142
1 files changed, 142 insertions, 0 deletions
diff --git a/ZAPDUtils/Utils/BinaryReader.cpp b/ZAPDUtils/Utils/BinaryReader.cpp
new file mode 100644
index 0000000..192fb1f
--- /dev/null
+++ b/ZAPDUtils/Utils/BinaryReader.cpp
@@ -0,0 +1,142 @@
+#pragma once
+
+#include "BinaryReader.h"
+#include "Stream.h"
+
+BinaryReader::BinaryReader(Stream* nStream)
+{
+ stream.reset(nStream);
+}
+
+void BinaryReader::Close()
+{
+ stream->Close();
+}
+
+void BinaryReader::Seek(uint32_t offset, SeekOffsetType seekType)
+{
+ stream->Seek(offset, seekType);
+}
+
+uint32_t BinaryReader::GetBaseAddress()
+{
+ return stream->GetBaseAddress();
+}
+
+void BinaryReader::Read(char* buffer, int32_t length)
+{
+ stream->Read(length);
+}
+
+char BinaryReader::ReadChar()
+{
+ return (char)stream->ReadByte();
+}
+
+int8_t BinaryReader::ReadByte()
+{
+ return stream->ReadByte();
+}
+
+uint8_t BinaryReader::ReadUByte()
+{
+ return (uint8_t)stream->ReadByte();
+}
+
+int16_t BinaryReader::ReadInt16()
+{
+ int16_t result;
+
+ stream->Read((char*)&result, sizeof(int16_t));
+ return result;
+}
+
+int32_t BinaryReader::ReadInt32()
+{
+ int32_t result;
+
+ stream->Read((char*)&result, sizeof(int32_t));
+ return result;
+}
+
+uint16_t BinaryReader::ReadUInt16()
+{
+ uint16_t result;
+
+ stream->Read((char*)&result, sizeof(uint16_t));
+ return result;
+}
+
+uint32_t BinaryReader::ReadUInt32()
+{
+ uint32_t result;
+
+ stream->Read((char*)&result, sizeof(uint32_t));
+ return result;
+}
+
+uint64_t BinaryReader::ReadUInt64()
+{
+ uint64_t result;
+
+ stream->Read((char*)&result, sizeof(uint64_t));
+ return result;
+}
+
+float BinaryReader::ReadSingle()
+{
+ float result;
+
+ stream->Read((char*)&result, sizeof(float));
+ return result;
+}
+
+double BinaryReader::ReadDouble()
+{
+ double result;
+
+ stream->Read((char*)&result, sizeof(double));
+ return result;
+}
+
+Vec3f BinaryReader::ReadVec3f()
+{
+ return Vec3f();
+}
+
+Vec3s BinaryReader::ReadVec3s()
+{
+ return Vec3s(0, 0, 0);
+}
+
+Vec3s BinaryReader::ReadVec3b()
+{
+ return Vec3s(0, 0, 0);
+}
+
+Vec2f BinaryReader::ReadVec2f()
+{
+ return Vec2f();
+}
+
+Color3b BinaryReader::ReadColor3b()
+{
+ return Color3b();
+}
+
+std::string BinaryReader::ReadString()
+{
+ std::string res = "";
+ char c;
+
+ do
+ {
+ c = ReadChar();
+
+ if (c != 0)
+ res += c;
+ } while (c != 0);
+
+
+ return res;
+} \ No newline at end of file