summaryrefslogtreecommitdiff
path: root/ZAPD/ZArray.cpp
diff options
context:
space:
mode:
authorLéo Lam <leo@leolam.fr>2021-03-20 10:17:39 +0100
committerGitHub <noreply@github.com>2021-03-20 05:17:39 -0400
commit4751db5c9ee0a25a26379ca5b44efad72215d256 (patch)
treece49e6e23e352c93424343f75b2e10601457a9c3 /ZAPD/ZArray.cpp
parent963a282dc10036f367a2cb09bb5651aefc73d2a4 (diff)
Add a clang-format config and reformat all source files (#63)
* build: Add genbuildinfo as a dependency for ZAPD object files * Add a clang-format config and reformat all source files The existing code style is mostly preserved; this just makes formatting more consistent and prevents lines from getting too long. * Fix missing includes
Diffstat (limited to 'ZAPD/ZArray.cpp')
-rw-r--r--ZAPD/ZArray.cpp25
1 files changed, 14 insertions, 11 deletions
diff --git a/ZAPD/ZArray.cpp b/ZAPD/ZArray.cpp
index f508a05..74fa9c5 100644
--- a/ZAPD/ZArray.cpp
+++ b/ZAPD/ZArray.cpp
@@ -1,11 +1,10 @@
#include "ZArray.h"
-#include "ZFile.h"
#include "Globals.h"
#include "StringHelper.h"
+#include "ZFile.h"
ZArray::ZArray()
{
-
}
void ZArray::ParseXML(tinyxml2::XMLElement* reader)
@@ -13,7 +12,8 @@ void ZArray::ParseXML(tinyxml2::XMLElement* reader)
ZResource::ParseXML(reader);
arrayCnt = reader->IntAttribute("Count", 0);
- testFile = new ZFile(ZFileMode::Extract, reader, Globals::Instance->baseRomPath, "", parent->GetName(), true);
+ testFile = new ZFile(ZFileMode::Extract, reader, Globals::Instance->baseRomPath, "",
+ parent->GetName(), true);
}
// TODO: This is a bit hacky, but until we refactor how ZFile parses the XML, it'll have to do.
@@ -31,7 +31,9 @@ std::string ZArray::GetSourceOutputCode(const std::string& prefix)
if (!res->DoesSupportArray())
{
- throw std::runtime_error(StringHelper::Sprintf("Error! Resource %s does not support being wrapped in an array!\n", res->GetName().c_str()));
+ throw std::runtime_error(StringHelper::Sprintf(
+ "Error! Resource %s does not support being wrapped in an array!\n",
+ res->GetName().c_str()));
}
for (int i = 0; i < arrayCnt; i++)
@@ -40,33 +42,34 @@ std::string ZArray::GetSourceOutputCode(const std::string& prefix)
res->SetRawDataIndex(childIndex);
res->ParseRawData();
std::string test = res->GetSourceOutputCode("");
- //output += " { " + testFile->declarations[childIndex]->text + " }";
+ // output += " { " + testFile->declarations[childIndex]->text + " }";
output += testFile->declarations[childIndex]->text;
-
+
if (i < arrayCnt - 1)
output += ",\n";
-
}
if (parent != nullptr)
- parent->AddDeclarationArray(rawDataIndex, DeclarationAlignment::None, GetRawDataSize(), res->GetSourceTypeName(), name, arrayCnt, output);
+ parent->AddDeclarationArray(rawDataIndex, DeclarationAlignment::None, GetRawDataSize(),
+ res->GetSourceTypeName(), name, arrayCnt, output);
return "";
}
int ZArray::GetRawDataSize()
{
- return arrayCnt * testFile->resources[0]->GetRawDataSize();
+ return arrayCnt * testFile->resources[0]->GetRawDataSize();
}
-ZArray* ZArray::ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector<uint8_t>& nRawData, const int rawDataIndex, const std::string& nRelPath, ZFile* nParent)
+ZArray* ZArray::ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector<uint8_t>& nRawData,
+ const int rawDataIndex, const std::string& nRelPath, ZFile* nParent)
{
ZArray* arr = new ZArray();
arr->rawData = nRawData;
arr->rawDataIndex = rawDataIndex;
arr->parent = nParent;
arr->ParseXML(reader);
- //arr->ParseRawData();
+ // arr->ParseRawData();
return arr;
}