Flint Engine
Modular C++20 2D game engine powered by SDL3
Loading...
Searching...
No Matches
utils.h
1// SPDX-License-Identifier: MIT
2// SPDX-FileCopyrightText: 2025-2026 Manuel Osorio
3#pragma once
4#include <algorithm>
5#include <cctype>
6#include <string>
7
8namespace Flint {
9 namespace Utilities {
16 inline bool equalsIgnoreCase(const std::string &source, const std::string &target) {
17 if (source.size() != target.size()) {
18 return false;
19 }
20
21 return std::equal(source.begin(), source.end(), target.begin(),
22 [](unsigned char lhs, unsigned char rhs) {
23 return std::tolower(lhs) == std::tolower(rhs);
24 });
25 }
26
31 inline void trim(std::string &value) {
32 const auto start = value.find_first_not_of(" \t\r\n\f\v");
33 if (start == std::string::npos) {
34 value.clear();
35 return;
36 }
37 const auto end = value.find_last_not_of(" \t\r\n\f\v");
38
39 value.erase(end + 1);
40 value.erase(0, start);
41 }
42 }
43}