Add handy StringUtils begin/end compare functions

This commit is contained in:
Jack Andersen 2016-08-30 15:13:00 -10:00
parent 735e6b2096
commit f0b1837300
2 changed files with 34 additions and 1 deletions

View File

@ -1089,6 +1089,11 @@ public:
return hecl::ProjectPath(getProject(), getRelativePath() + _S('|') + auxStr);
}
hecl::ProjectPath ensureAuxInfo(const SystemString& auxStr) const
{
return ensureAuxInfo(auxStr.c_str());
}
/**
* @brief Type of path
*/
@ -1194,6 +1199,29 @@ public:
};
/**
* @brief handy functions not directly provided via STL strings
*/
class StringUtils
{
public:
static bool BeginsWith(const SystemString& str, const SystemChar* test)
{
size_t len = StrLen(test);
if (len > str.size())
return false;
return !StrCmp(str.data(), test);
}
static bool EndsWith(const SystemString& str, const SystemChar* test)
{
size_t len = StrLen(test);
if (len > str.size())
return false;
return !StrCmp(&*(str.end() - len), test);
}
};
/**
* @brief Mutex-style centralized resource-path tracking
*

View File

@ -123,7 +123,12 @@ void ProjectPath::assign(const ProjectPath& parentPath, const std::string& path)
ProjectPath ProjectPath::getCookedPath(const Database::DataSpecEntry& spec) const
{
ProjectPath woExt = getWithExtension(nullptr, true);
return ProjectPath(m_proj->getProjectCookedPath(spec), woExt.getRelativePath());
ProjectPath ret(m_proj->getProjectCookedPath(spec), woExt.getRelativePath());
if (getAuxInfo().size())
return ret.getWithExtension((_S('.') + getAuxInfo()).c_str());
else
return ret;
}
ProjectPath::Type ProjectPath::getPathType() const