2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-08 15:44:56 +00:00

string_view refactor

This commit is contained in:
Jack Andersen
2017-11-12 20:19:18 -10:00
parent 742ab2514f
commit f7ec7bdc0c
345 changed files with 907 additions and 921 deletions

View File

@@ -44,7 +44,7 @@ bool AGSC::Cook(const hecl::ProjectPath& inPath, const hecl::ProjectPath& outPat
return false;
hecl::ProjectPath woExt = inPath.getWithExtension(nullptr, true);
std::string lastComp = woExt.getLastComponentUTF8();
std::string lastComp = std::string(woExt.getLastComponentUTF8());
if (hecl::StringUtils::EndsWith(lastComp, "_AGSC"))
lastComp.assign(lastComp.cbegin(), lastComp.cend() - 5);

View File

@@ -25,9 +25,9 @@ namespace DNAMP2
{
logvisor::Module Log("urde::DNAMP2");
static bool GetNoShare(const std::string& name)
static bool GetNoShare(std::string_view name)
{
std::string lowerName = name;
std::string lowerName(name);
std::transform(lowerName.begin(), lowerName.end(), lowerName.begin(), tolower);
if (!lowerName.compare(0, 7, "metroid"))
return false;
@@ -65,9 +65,9 @@ PAKBridge::PAKBridge(hecl::Database::Project& project,
}
}
static hecl::SystemString LayerName(const std::string& name)
static hecl::SystemString LayerName(std::string_view name)
{
hecl::SystemString ret = hecl::SystemStringView(name).sys_str();
hecl::SystemString ret(hecl::SystemStringConv(name).sys_str());
for (auto& ch : ret)
if (ch == _S('/') || ch == _S('\\'))
ch = _S('-');
@@ -91,7 +91,7 @@ void PAKBridge::build()
}
bool named;
std::string bestName = m_pak.bestEntryName(e, named);
level.name = hecl::SystemStringView(bestName).sys_str();
level.name = hecl::SystemStringConv(bestName).sys_str();
level.areas.reserve(mlvl.areaCount);
unsigned layerIdx = 0;
@@ -127,11 +127,11 @@ void PAKBridge::build()
}
if (areaDeps.name.empty())
{
areaDeps.name = hecl::SystemStringView(area.internalAreaName).sys_str();
areaDeps.name = hecl::SystemStringConv(area.internalAreaName).sys_str();
if (areaDeps.name.empty())
{
std::string idStr = area.areaMREAId.toString();
areaDeps.name = _S("MREA_") + hecl::SystemStringView(idStr).sys_str();
areaDeps.name = hecl::SystemString(_S("MREA_")) + hecl::SystemStringConv(idStr).c_str();
}
}
hecl::SystemChar num[16];

View File

@@ -28,8 +28,8 @@ public:
bool doExtract=true);
void build();
static ResExtractor<PAKBridge> LookupExtractor(const DNAMP1::PAK& pak, const DNAMP1::PAK::Entry& entry);
const std::string& getName() const {return m_node.getName();}
const hecl::SystemString& getLevelString() const {return m_levelString;}
std::string_view getName() const {return m_node.getName();}
hecl::SystemStringView getLevelString() const {return m_levelString;}
using PAKType = DNAMP1::PAK;
const PAKType& getPAK() const {return m_pak;}

View File

@@ -19,9 +19,9 @@ struct STRG : ISTRG
std::unordered_map<FourCC, std::vector<std::u16string>*> langMap;
std::map<std::string, int32_t> names;
int32_t lookupIdx(const std::string& name) const
int32_t lookupIdx(std::string_view name) const
{
auto search = names.find(name);
auto search = names.find(name.data());
if (search == names.end())
return -1;
return search->second;