1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2024-12-04 16:55:56 +00:00
oot/tools/ZAPD/ZAPD/ZString.cpp
louist103 750c0cab35
Update ZAPD (#1001)
* remove fake match

* git subrepo pull --force tools/ZAPD

subrepo:
  subdir:   "tools/ZAPD"
  merged:   "3e9ed72e2"
upstream:
  origin:   "https://github.com/zeldaret/ZAPD.git"
  branch:   "master"
  commit:   "3e9ed72e2"
git-subrepo:
  version:  "0.4.3"
  origin:   "https://github.com/ingydotnet/git-subrepo.git"
  commit:   "2f68596"

* new extraction script and a hack to make clear tag work

* fix clear tag again

* remove static from clear tag DLists

* git subrepo pull --force tools/ZAPD

subrepo:
  subdir:   "tools/ZAPD"
  merged:   "e7a8a48cf"
upstream:
  origin:   "https://github.com/zeldaret/ZAPD.git"
  branch:   "master"
  commit:   "e7a8a48cf"
git-subrepo:
  version:  "0.4.3"
  origin:   "https://github.com/ingydotnet/git-subrepo.git"
  commit:   "2f68596"

* git subrepo pull --force tools/ZAPD

subrepo:
  subdir:   "tools/ZAPD"
  merged:   "e243634e5"
upstream:
  origin:   "https://github.com/zeldaret/ZAPD.git"
  branch:   "master"
  commit:   "e243634e5"
git-subrepo:
  version:  "0.4.3"
  origin:   "https://github.com/ingydotnet/git-subrepo.git"
  commit:   "2f68596"

* git subrepo pull --force tools/ZAPD

subrepo:
  subdir:   "tools/ZAPD"
  merged:   "d0cd6b397"
upstream:
  origin:   "https://github.com/zeldaret/ZAPD.git"
  branch:   "master"
  commit:   "d0cd6b397"
git-subrepo:
  version:  "0.4.3"
  origin:   "https://github.com/ingydotnet/git-subrepo.git"
  commit:   "2f68596"

* Update ovl_En_Clear_Tag.xml
2021-10-17 13:32:09 +02:00

69 lines
1.5 KiB
C++

#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();
}