From 7727db9a8ac29cdcae6145a2ea758f7e258edcb8 Mon Sep 17 00:00:00 2001 From: Riccardo Elitropi Date: Fri, 26 Sep 2025 11:55:43 +0200 Subject: [PATCH] Include : - modifica prototipi per funzioni redis - aggiunta funzione GetValInNotes con parametro aggiuntivo. --- EGnStringKeyVal.h | 43 +++++++++++++++++++++++++++++++++++++++---- EXeExecutor.h | 4 ++-- 2 files changed, 41 insertions(+), 6 deletions(-) diff --git a/EGnStringKeyVal.h b/EGnStringKeyVal.h index ef90e39..97598fc 100644 --- a/EGnStringKeyVal.h +++ b/EGnStringKeyVal.h @@ -101,14 +101,14 @@ GetVal( const std::string& sString, const std::string& sKey, T& Val) inline bool SetValInNotes( const std::string& sKey, const std::string& sVal, std::string& sNotes) { - // verifiche validità chiave + // verifiche validità chiave if ( ! IsValidKey( sKey) || ! IsValidVal( sVal)) return false ; // chiave con carattere finale speciale std::string sTkey = sKey ; if ( sKey.back() != COLON) sTkey += EQUAL ; - // ricerca se già presente + // ricerca se già presente STRVECTOR vsTokens ; Tokenize( sNotes, ";", vsTokens) ; bool bFound = false ; @@ -143,7 +143,7 @@ SetValInNotes( const std::string& sKey, T& Val, std::string& sNotes) inline bool GetValInNotes( const std::string& sNotes, const std::string& sKey, std::string& sVal) { - // verifiche validità chiave + // verifiche validità chiave if ( sNotes.empty() || ! IsValidKey( sKey)) return false ; // chiave con carattere finale speciale @@ -171,11 +171,46 @@ GetValInNotes( const std::string& sNotes, const std::string& sKey, T& Val) return ( GetValInNotes( sNotes, sKey, sVal) && FromString( sVal, Val)) ; } +//---------------------------------------------------------------------------- +inline bool +GetValInNotes( const std::string& sNotes, const std::string& sKey, const std::string& sToken, std::string& sVal) +{ + // verifiche validità chiave + if ( sNotes.empty() || ! IsValidKey( sKey)) + return false ; + // verifiche validità del token + if ( sToken.empty()) + return false ; + // chiave con carattere finale speciale + std::string sTkey = sKey ; + if ( sKey.back() != COLON) + sTkey += EQUAL ; + // ricerca + STRVECTOR vsTokens ; + Tokenize( sNotes, sToken, vsTokens) ; + for ( const auto& sToken : vsTokens) { + if ( FindKey( sToken, sTkey, true)) { + sVal = sToken.substr( sTkey.length()) ; + return true ; + } + } + return false ; +} + +//---------------------------------------------------------------------------- +template +inline bool +GetValInNotes( const std::string& sNotes, const std::string& sKey, const std::string& sToken, T& Val) +{ + std::string sVal ; + return ( GetValInNotes( sNotes, sKey, sToken, sVal) && FromString( sVal, Val)) ; +} + //---------------------------------------------------------------------------- inline bool RemoveValInNotes( const std::string& sKey, std::string& sNotes) { - // verifiche validità chiave + // verifiche validità chiave if ( sNotes.empty() || ! IsValidKey( sKey)) return false ; // chiave con carattere finale speciale diff --git a/EXeExecutor.h b/EXeExecutor.h index dcd23cd..41fae98 100644 --- a/EXeExecutor.h +++ b/EXeExecutor.h @@ -1457,11 +1457,11 @@ EXE_EXPORT const std::string& ExeGetLanguage( void) ; EXE_EXPORT const std::string& ExeGetMsg( int nMsg) ; // Redis -EXE_EXPORT bool ExeRedisConnect( const std::string& sHost, int nPort, int nDataBase, double dTimeOutSeconds) ; +EXE_EXPORT bool ExeRedisConnect( const std::string& sConnection) ; EXE_EXPORT bool ExeRedisDisconnect( void) ; EXE_EXPORT bool ExeRedisSetValFromKey( const std::string& sKey, const std::string& sVal) ; EXE_EXPORT bool ExeRedisGetValFromKey( const std::string& sKey, std::string& sVal) ; -EXE_EXPORT bool ExeRedisAsyncConnect( const std::string& sHost, int nPort, int nDataBase, double dMaxTimeOut) ; +EXE_EXPORT bool ExeRedisAsyncConnect( const std::string& sConnection) ; EXE_EXPORT bool ExeRedisAsyncDisconnect( void) ; EXE_EXPORT bool ExeRedisAsyncPublish( const std::string& sChannel, const std::string& sMessage) ; EXE_EXPORT bool ExeRedisAsyncSubscribe( const std::string& sChannel) ;