Nimbin[12]?SDL & Graphics / sdl_runtime_compiler / src/levels/level.cpp

sdl_runtime_compiler git · main

SDL3 game for running and compiling code at runtime

sdl3 c++ compiler dlopen cmake · first commit 2026-04-19 · last commit 2026-07-03 (3 months ago) · synced 3 days ago · upstream: git.ide3.de/hsnr/sdl-runtime-compiler

C++ 72.3% C 26.2%
git clone https://git.christianimmanuel.de/sdl-graphics/sdl_runtime_compiler.gitwget https://git.christianimmanuel.de/sdl-graphics/sdl_runtime_compiler/archive/sdl_runtime_compiler.tar.gz
src/levels/level.cpp 888 B · 53 lines raw
#include <cctype>

#include "level.hpp"

namespace
Nimbin
{
namespace
Level
{

namespace
Check
{


std::string
normalize(const std::string& s)
{
    std::string out;
    out.reserve(s.size());

    bool last_space = true;
    for (char c : s) {
        if (std::isspace(static_cast<unsigned char>(c))) {
            if (!last_space) {
                out += ' ';
                last_space = true;
            }
        }
        else {
            out += c;
            last_space = false;
        }
    }
    if (!out.empty() && out.back() == ' ')
        out.pop_back();
    return out;
}


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


} // namespace Check
} // namespace Level
} // namespace Nimbin