Create stringtool.hpp

This commit is contained in:
tobid7 2021-08-12 22:17:46 +02:00 committed by GitHub
parent f7f0d26896
commit a15b0bdb2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

11
internal/stringtool.hpp Normal file
View File

@ -0,0 +1,11 @@
template<class T>
T GetFileName(T const & path, T const & delims = "/\\")
{
return path.substr(path.find_last_of(delims) + 1);
}
template<class T>
T remove_ext(T const & filename)
{
typename T::size_type const p(filename.find_last_of('.'));
return p > 0 && p != T::npos ? filename.substr(0, p) : filename;
}