Füge UndergroundWorker hinzu und implementiere Logik für unterirdische Aufgaben. Aktualisiere CMakeLists.txt, um neue Quell- und Header-Dateien einzuschließen. Verbessere die Fehlerbehandlung in der Datenbank und sende Benachrichtigungen nach bestimmten Ereignissen. Integriere Hilfsfunktionen zur sicheren Verarbeitung von Daten.

This commit is contained in:
Torsten Schulz (local)
2025-08-31 23:11:09 +02:00
committed by Torsten (PC)
parent 1451225978
commit 23c07a3570
18 changed files with 1255 additions and 88 deletions

30
src/utils.h Normal file
View File

@@ -0,0 +1,30 @@
#pragma once
#include <string>
#include <unordered_map>
#include <vector>
#include <optional>
#include <chrono>
class Utils {
public:
// Safe conversions with fallback
static int optionalStoiOrDefault(const std::unordered_map<std::string, std::string>& row,
const std::string& key, int def = -1);
static double optionalStodOrDefault(const std::unordered_map<std::string, std::string>& row,
const std::string& key, double def = 0.0);
static bool isNullOrEmpty(const std::string& s);
// Parse timestamp from common ISO / SQL formats into time_point
static std::optional<std::chrono::system_clock::time_point> parseTimestamp(const std::string& iso);
// Compute full years age from birthdate string; returns nullopt on parse failure.
static std::optional<int> computeAgeYears(const std::string& birthdate_iso);
// Build Postgres integer array literal "{1,2,3}"
static std::string buildPgIntArrayLiteral(const std::vector<int>& elems);
// Safely parse a nullable integer-like string
static std::optional<int> optionalUid(const std::string& val);
};