mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2025-01-09 18:39:45 +01:00
Move endsWith() to UtilityClass.cpp and put it in header file
This ensures that endsWith() can be used outside of editor.cpp. When leo60228 originally wrote endsWith(), it was static, but I asked him on Discord just now and he more-or-less confirmed that it's fine if it's not static. If it was static, it would be confined to UtilityClass.cpp now instead!
This commit is contained in:
parent
ed527bc872
commit
34e89bfcd3
3 changed files with 15 additions and 13 deletions
|
@ -230,3 +230,16 @@ bool is_positive_num(const std::string& str, bool hex)
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool endsWith(const std::string& str, const std::string& suffix)
|
||||||
|
{
|
||||||
|
if (str.size() < suffix.size())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return str.compare(
|
||||||
|
str.size() - suffix.size(),
|
||||||
|
suffix.size(),
|
||||||
|
suffix
|
||||||
|
) == 0;
|
||||||
|
}
|
||||||
|
|
|
@ -13,6 +13,8 @@ std::vector<std::string> split(const std::string &s, char delim);
|
||||||
|
|
||||||
bool is_positive_num(const std::string& str, bool hex);
|
bool is_positive_num(const std::string& str, bool hex);
|
||||||
|
|
||||||
|
bool endsWith(const std::string& str, const std::string& suffix);
|
||||||
|
|
||||||
#define INBOUNDS(index, vector) ((int) index >= 0 && (int) index < (int) vector.size())
|
#define INBOUNDS(index, vector) ((int) index >= 0 && (int) index < (int) vector.size())
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -88,19 +88,6 @@ bool compare_nocase (std::string first, std::string second)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool endsWith(const std::string& str, const std::string& suffix)
|
|
||||||
{
|
|
||||||
if (str.size() < suffix.size())
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return str.compare(
|
|
||||||
str.size() - suffix.size(),
|
|
||||||
suffix.size(),
|
|
||||||
suffix
|
|
||||||
) == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void editorclass::loadZips()
|
void editorclass::loadZips()
|
||||||
{
|
{
|
||||||
directoryList = FILESYSTEM_getLevelDirFileNames();
|
directoryList = FILESYSTEM_getLevelDirFileNames();
|
||||||
|
|
Loading…
Reference in a new issue