flatten 20260225

This commit is contained in:
Timothy Prepscius
2026-02-25 12:39:24 -05:00
commit fa54be052a
315 changed files with 49791 additions and 0 deletions

42
tjp/core/args/Args.cpp Normal file
View File

@@ -0,0 +1,42 @@
// TJP COPYRIGHT HEADER
#ifdef TJP_CORE_HEADER_ONLY
#pragma once
#endif
#include <tjp/core/header_only/compile.h>
#include "Args.h"
#include <tjp/core/string/starts_with.hpp>
namespace tjp::core {
TJP_CORE_HEADER_ONLY_INLINE
std::map<std::string, std::string> mapArgs(int argc, const char *argv[])
{
std::map<std::string, std::string> mapped;
static const std::string prefix = "--";
for (int i=1; i<argc; ++i)
{
std::string s = argv[i];
if (starts_with(s, prefix))
{
bool hasValue = (i+1)<argc && !starts_with(std::string(argv[i+1]), prefix);
std::string key = s.substr(2);
if (hasValue)
{
std::string value = argv[i+1];
mapped[key] = value;
i++;
}
else
{
mapped[key] = "";
}
}
}
return mapped;
}
} // namespace