mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-08-19 21:03:42 -07:00
git subrepo clone https://github.com/HarbourMasters/ZAPDTR.git
subrepo: subdir: "ZAPDTR" merged: "a53a53ea4" upstream: origin: "https://github.com/HarbourMasters/ZAPDTR.git" branch: "master" commit: "a53a53ea4" git-subrepo: version: "0.4.1" origin: "???" commit: "???"
This commit is contained in:
parent
f52a2a6406
commit
5dda5762ba
217 changed files with 47152 additions and 0 deletions
69
ZAPDTR/ZAPD/ZString.cpp
Normal file
69
ZAPDTR/ZAPD/ZString.cpp
Normal file
|
@ -0,0 +1,69 @@
|
|||
#include "ZString.h"
|
||||
|
||||
#include "Utils/File.h"
|
||||
#include "Utils/StringHelper.h"
|
||||
#include "ZFile.h"
|
||||
|
||||
REGISTER_ZFILENODE(String, ZString);
|
||||
|
||||
ZString::ZString(ZFile* nParent) : ZResource(nParent)
|
||||
{
|
||||
}
|
||||
|
||||
void ZString::ParseRawData()
|
||||
{
|
||||
size_t size = 0;
|
||||
const auto& rawData = parent->GetRawData();
|
||||
const auto& rawDataArr = rawData.data();
|
||||
size_t rawDataSize = rawData.size();
|
||||
for (size_t i = rawDataIndex; i < rawDataSize; ++i)
|
||||
{
|
||||
++size;
|
||||
if (rawDataArr[i] == '\0')
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
auto dataStart = rawData.begin() + rawDataIndex;
|
||||
strData.assign(dataStart, dataStart + size);
|
||||
}
|
||||
|
||||
Declaration* ZString::DeclareVar(const std::string& prefix, const std::string& bodyStr)
|
||||
{
|
||||
std::string auxName = name;
|
||||
|
||||
if (name == "")
|
||||
auxName = GetDefaultName(prefix);
|
||||
|
||||
Declaration* decl =
|
||||
parent->AddDeclarationArray(rawDataIndex, GetDeclarationAlignment(), GetRawDataSize(),
|
||||
GetSourceTypeName(), auxName, 0, bodyStr);
|
||||
decl->staticConf = staticConf;
|
||||
return decl;
|
||||
}
|
||||
|
||||
std::string ZString::GetBodySourceCode() const
|
||||
{
|
||||
return StringHelper::Sprintf("\t\"%s\"", strData.data());
|
||||
}
|
||||
|
||||
std::string ZString::GetSourceOutputHeader([[maybe_unused]] const std::string& prefix)
|
||||
{
|
||||
return StringHelper::Sprintf("#define %s_macro \"%s\"", name.c_str(), strData.data());
|
||||
}
|
||||
|
||||
std::string ZString::GetSourceTypeName() const
|
||||
{
|
||||
return "char";
|
||||
}
|
||||
|
||||
ZResourceType ZString::GetResourceType() const
|
||||
{
|
||||
return ZResourceType::String;
|
||||
}
|
||||
|
||||
size_t ZString::GetRawDataSize() const
|
||||
{
|
||||
return strData.size();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue