Fixed AIFC Extraction

This commit is contained in:
KiritoDv
2023-09-03 20:11:35 -06:00
parent 1134723029
commit 063224c69d
9 changed files with 358 additions and 53 deletions
+9 -4
View File
@@ -132,10 +132,11 @@ void LUS::BinaryWriter::Write(double value) {
mStream->Write((char*)&value, sizeof(double));
}
void LUS::BinaryWriter::Write(const std::string& str) {
int strLen = str.size();
Write(strLen);
void LUS::BinaryWriter::Write(const std::string& str, bool writeLength) {
if(writeLength){
int strLen = str.size();
Write(strLen);
}
for (char c : str) {
mStream->WriteByte(c);
}
@@ -145,6 +146,10 @@ void LUS::BinaryWriter::Write(char* srcBuffer, size_t length) {
mStream->Write(srcBuffer, length);
}
void LUS::BinaryWriter::WriteByte(char value) {
mStream->WriteByte(value);
}
std::vector<char> LUS::BinaryWriter::ToVector() {
return mStream->ToVector();
}
+2 -1
View File
@@ -33,8 +33,9 @@ class BinaryWriter {
void Write(uint64_t value);
void Write(float value);
void Write(double value);
void Write(const std::string& str);
void Write(const std::string& str, bool writeLength = true);
void Write(char* srcBuffer, size_t length);
void WriteByte(char value);
std::vector<char> ToVector();
+38 -4
View File
@@ -1,6 +1,7 @@
#pragma once
#include <vector>
#include <unordered_map>
namespace PyUtils {
template<typename T>
@@ -12,12 +13,45 @@ std::vector<T> slice(std::vector<T> const &v, uint32_t m, uint32_t n = -1) {
return vec;
}
std::vector<uint32_t> range(uint32_t start, uint32_t end) {
std::vector<uint32_t> result;
for (uint32_t i = start; i < end; ++i) {
result.push_back(i);
std::vector<uint32_t> range(uint32_t start, uint32_t end);
template<typename T>
T max(std::vector<T> const &v) {
T max = v[0];
for (auto const &value: v) {
if (value > max) {
max = value;
}
}
return max;
}
template<typename T>
T min(std::vector<T> const &v) {
T min = v[0];
for (auto const &value: v) {
if (value < min) {
min = value;
}
}
return min;
}
template<typename T, typename X>
std::vector<T> keys(std::unordered_map<T, X> const &map) {
std::vector<T> result;
for (auto const &pair: map) {
result.push_back(pair.first);
}
return result;
}
}
template <typename T>
std::vector<T> operator+(std::vector<T> const &x, std::vector<T> const &y)
{
std::vector<T> vec;
vec.reserve(x.size() + y.size());
vec.insert(vec.end(), x.begin(), x.end());
vec.insert(vec.end(), y.begin(), y.end());
return vec;
}