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:
committed by
Torsten (PC)
parent
1451225978
commit
23c07a3570
30
src/utils.h
Normal file
30
src/utils.h
Normal 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);
|
||||
};
|
||||
Reference in New Issue
Block a user