summaryrefslogtreecommitdiff
path: root/ZAPD/ZVector.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ZAPD/ZVector.cpp')
-rw-r--r--ZAPD/ZVector.cpp47
1 files changed, 24 insertions, 23 deletions
diff --git a/ZAPD/ZVector.cpp b/ZAPD/ZVector.cpp
index 31d5dc4..29bf3bf 100644
--- a/ZAPD/ZVector.cpp
+++ b/ZAPD/ZVector.cpp
@@ -1,5 +1,7 @@
#include "ZVector.h"
-#include <assert.h>
+
+#include <cassert>
+
#include "Globals.h"
#include "Utils/BitConverter.h"
#include "Utils/File.h"
@@ -17,6 +19,16 @@ ZVector::ZVector(ZFile* nParent) : ZResource(nParent)
RegisterRequiredAttribute("Dimensions");
}
+void ZVector::ExtractFromBinary(uint32_t nRawDataIndex, ZScalarType nScalarType,
+ uint32_t nDimensions)
+{
+ rawDataIndex = nRawDataIndex;
+ scalarType = nScalarType;
+ dimensions = nDimensions;
+
+ ParseRawData();
+}
+
void ZVector::ParseXML(tinyxml2::XMLElement* reader)
{
ZResource::ParseXML(reader);
@@ -34,9 +46,8 @@ void ZVector::ParseRawData()
for (uint32_t i = 0; i < dimensions; i++)
{
- ZScalar scalar(scalarType, parent);
- scalar.rawDataIndex = currentRawDataIndex;
- scalar.ParseRawData();
+ ZScalar scalar(parent);
+ scalar.ExtractFromBinary(currentRawDataIndex, scalarType);
currentRawDataIndex += scalar.GetRawDataSize();
scalars.push_back(scalar);
@@ -86,20 +97,15 @@ std::string ZVector::GetBodySourceCode() const
{
std::string body = "";
- for (size_t i = 0; i < this->scalars.size(); i++)
- body += StringHelper::Sprintf("%6s, ", scalars[i].GetBodySourceCode().c_str());
-
- return "{ " + body + "}";
-}
+ for (size_t i = 0; i < scalars.size(); i++)
+ {
+ body += StringHelper::Sprintf("%6s", scalars[i].GetBodySourceCode().c_str());
-std::string ZVector::GetSourceOutputCode([[maybe_unused]] const std::string& prefix)
-{
- Declaration* decl =
- parent->AddDeclaration(rawDataIndex, DeclarationAlignment::Align4, GetRawDataSize(),
- GetSourceTypeName(), GetName(), GetBodySourceCode());
- decl->staticConf = staticConf;
+ if (i + 1 < scalars.size())
+ body += ", ";
+ }
- return "";
+ return body;
}
ZResourceType ZVector::GetResourceType() const
@@ -107,12 +113,7 @@ ZResourceType ZVector::GetResourceType() const
return ZResourceType::Vector;
}
-void ZVector::SetScalarType(ZScalarType type)
-{
- scalarType = type;
-}
-
-void ZVector::SetDimensions(uint32_t dim)
+DeclarationAlignment ZVector::GetDeclarationAlignment() const
{
- dimensions = dim;
+ return scalars.at(0).GetDeclarationAlignment();
}