mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2024-11-10 19:45:09 -05:00
91bd693ff6
* Bump LUS version * Removes the "now" boolean from the LUS resource bridge functions. * Bump LUS * More LUS bump * Update soh/soh/resource/importer/AudioSampleFactory.cpp --------- Co-authored-by: briaguya <70942617+briaguya-ai@users.noreply.github.com>
70 lines
1.5 KiB
C++
70 lines
1.5 KiB
C++
#include "ZString.h"
|
|
|
|
#include <Utils/DiskFile.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, std::set<std::string> *nameSet)
|
|
{
|
|
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();
|
|
}
|