From f0b1837300027192371f8b35133207439fa53017 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Tue, 30 Aug 2016 15:13:00 -1000 Subject: [PATCH] Add handy StringUtils begin/end compare functions --- hecl/include/hecl/hecl.hpp | 28 ++++++++++++++++++++++++++++ hecl/lib/ProjectPath.cpp | 7 ++++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/hecl/include/hecl/hecl.hpp b/hecl/include/hecl/hecl.hpp index aa3c1c9b6..9b8f2b96e 100644 --- a/hecl/include/hecl/hecl.hpp +++ b/hecl/include/hecl/hecl.hpp @@ -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 * diff --git a/hecl/lib/ProjectPath.cpp b/hecl/lib/ProjectPath.cpp index 342faee39..301311198 100644 --- a/hecl/lib/ProjectPath.cpp +++ b/hecl/lib/ProjectPath.cpp @@ -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