mirror of
https://github.com/OPM/ResInsight.git
synced 2026-11-01 08:38:00 -06:00
Python: add api for getting values back from key-value store.
This commit is contained in:
1 parent
377d300767
commit
90d1555de3
7 files changed
+167
-20
No files matched your search
@@ -23,3 +23,22 @@ std::vector<float> RiaKeyValueStoreUtil::convertToFloatVector( const std::option
|
||||
|
||||
return floatVector;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<char> RiaKeyValueStoreUtil::convertToByteVector( const std::vector<float>& floatVec )
|
||||
{
|
||||
if ( floatVec.empty() ) return {};
|
||||
|
||||
// Calculate the total size needed for the byte array
|
||||
size_t sizeInBytes = floatVec.size() * sizeof( float );
|
||||
|
||||
// Create a vector of bytes with the appropriate size
|
||||
std::vector<char> byteVec( sizeInBytes );
|
||||
|
||||
// Copy the binary data from the float vector to the byte vector
|
||||
std::memcpy( byteVec.data(), floatVec.data(), sizeInBytes );
|
||||
|
||||
return byteVec;
|
||||
}
|
||||
@@ -28,4 +28,5 @@ class RiaKeyValueStoreUtil
|
||||
{
|
||||
public:
|
||||
static std::vector<float> convertToFloatVector( const std::optional<std::vector<char>>& input );
|
||||
static std::vector<char> convertToByteVector( const std::vector<float>& floatVec );
|
||||
};
|
||||
Reference in new issue
Block a user