diff options
| author | Lywx <kiritodev01@gmail.com> | 2023-09-16 04:01:24 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-09-16 04:01:24 -0600 |
| commit | ae8487a4adc5d6d33c47d41e3a40d3c67ddb1e45 (patch) | |
| tree | e03627371fc7423c684631ed7eee68d697709e0f /lib/binarytools/BinaryReader.cpp | |
| parent | f5cbd0056d601e4adaf5ed9006192dd510226ee3 (diff) | |
| parent | 98b6d598324fdcb499a2cc4d37a7a6fcd19e8ead (diff) | |
Merge pull request #1 from KiritoDv/feature/audio
Implemented full audio extraction
Diffstat (limited to 'lib/binarytools/BinaryReader.cpp')
| -rw-r--r-- | lib/binarytools/BinaryReader.cpp | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/lib/binarytools/BinaryReader.cpp b/lib/binarytools/BinaryReader.cpp index 3aff001..f802885 100644 --- a/lib/binarytools/BinaryReader.cpp +++ b/lib/binarytools/BinaryReader.cpp @@ -2,6 +2,7 @@ #include "MemoryStream.h" #include <cmath> #include <stdexcept> +#include <locale> LUS::BinaryReader::BinaryReader(char* nBuffer, size_t nBufferSize) { mStream = std::make_shared<MemoryStream>(nBuffer, nBufferSize); @@ -57,7 +58,6 @@ int16_t LUS::BinaryReader::ReadInt16() { if (mEndianness != Endianness::Native) { result = BSWAP16(result); } - return result; } @@ -113,6 +113,28 @@ uint64_t LUS::BinaryReader::ReadUInt64() { return result; } +unsigned short LUS::BinaryReader::ReadUShort() { + unsigned short result = 0; + mStream->Read((char*)&result, sizeof(unsigned short)); + + if (mEndianness != Endianness::Native) { + result = BSWAP16(result); + } + + return result; +} + +short LUS::BinaryReader::ReadShort() { + short result = 0; + mStream->Read((char*)&result, sizeof(short)); + + if (mEndianness != Endianness::Native) { + result = BSWAP16(result); + } + + return result; +} + float LUS::BinaryReader::ReadFloat() { float result = NAN; @@ -169,6 +191,7 @@ std::string LUS::BinaryReader::ReadString() { for (int i = 0; i < numChars; i++) { res += ReadChar(); } + return res; } @@ -188,6 +211,10 @@ std::string LUS::BinaryReader::ReadCString() { return res; } +size_t LUS::BinaryReader::GetLength() { + return mStream->GetLength(); +} + std::vector<char> LUS::BinaryReader::ToVector() { return mStream->ToVector(); -} +}
\ No newline at end of file |
