Include :

- modifica prototipi per funzioni redis
- aggiunta funzione GetValInNotes con parametro aggiuntivo.
This commit is contained in:
Riccardo Elitropi
2025-09-26 11:55:43 +02:00
parent f6caa955e2
commit 7727db9a8a
2 changed files with 41 additions and 6 deletions
+39 -4
View File
@@ -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 <class T>
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
+2 -2
View File
@@ -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) ;