Skip to content

Commit

Permalink
The world is not ready for C++23
Browse files Browse the repository at this point in the history
  • Loading branch information
louve committed Oct 1, 2024
1 parent 88dd6c0 commit 14171bc
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion premake5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ workspace "iw4x"
configurations {"Debug", "Release"}

language "C++"
cppdialect "C++23"
cppdialect "C++20"

architecture "x86"
platforms "Win32"
Expand Down
4 changes: 2 additions & 2 deletions src/Components/Modules/Download.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -890,12 +890,12 @@ namespace Components

bool Download::ClientDownload::File::allowed() const
{
if (name.contains("..") || name.contains(":"))
if (Utils::String::Contains(name, "..") || Utils::String::Contains(name, ":"))
{
return false;
}

if (name.contains("\\") || name.contains("/"))
if (Utils::String::Contains(name, "\\") || Utils::String::Contains(name, "/"))
{
return false;
}
Expand Down
10 changes: 10 additions & 0 deletions src/Utils/String.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,16 @@ namespace Utils::String
return std::equal(needle.rbegin(), needle.rend(), haystack.rbegin());
}

bool Contains(const std::string& haystack, const std::string& needle)
{
if (haystack.find(needle) != std::string::npos)
{
return true;
}

return false;
}

bool IsNumber(const std::string& str)
{
return !str.empty() && std::find_if(str.begin(), str.end(), [](unsigned char input)
Expand Down
1 change: 1 addition & 0 deletions src/Utils/String.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ namespace Utils::String

[[nodiscard]] bool StartsWith(const std::string& haystack, const std::string& needle);
[[nodiscard]] bool EndsWith(const std::string& haystack, const std::string& needle);
[[nodiscard]] bool Contains(const std::string& haystack, const std::string& needle);

[[nodiscard]] bool IsNumber(const std::string& str);

Expand Down

0 comments on commit 14171bc

Please sign in to comment.