#pragma once #include #include #include #include #include class Utils { public: // Safe conversions with fallback static int optionalStoiOrDefault(const std::unordered_map& row, const std::string& key, int def = -1); static double optionalStodOrDefault(const std::unordered_map& 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 parseTimestamp(const std::string& iso); // Compute full years age from birthdate string; returns nullopt on parse failure. static std::optional computeAgeYears(const std::string& birthdate_iso); // Build Postgres integer array literal "{1,2,3}" static std::string buildPgIntArrayLiteral(const std::vector& elems); // Safely parse a nullable integer-like string static std::optional optionalUid(const std::string& val); };