diff --git a/src/Entity.jl b/src/Entity.jl index 6fa2c7ec8e24cc0622f3f0265e74b032a04d623e..56b56de557a791e25396d760487c9e9bf8b5af64 100644 --- a/src/Entity.jl +++ b/src/Entity.jl @@ -755,19 +755,57 @@ Return the value of the given `property` """ function get_value(property::Ref{_Property}) - out = Ref{Ptr{UInt8}}(Ptr{UInt8}()) - - err_code = ccall( - (:caosdb_entity_property_get_value, CaosDB.library_name), - Cint, - (Ref{_Property}, Ref{Ptr{UInt8}}), - property, - out, - ) - - CaosDB.Exceptions.evaluate_return_code(err_code) + _caosdb_dtypes = ("INTEGER", "DOUBLE", "BOOLEAN", "TEXT") + + prop_datatype = get_datatype(property) + if prop_datatype[1] in _caosdb_dtypes + + if prop_datatype[1] == "INTEGER" + out = Ref{Cint}(0) + err_code = ccall( + (:caosdb_entity_property_get_int_value, CaosDB.library_name), + Cint, + (Ref{_Property}, Ref{Cint}), + property, + out, + ) + + out = out[] + elseif prop_datatype[1] == "DOUBLE" + out = Ref{Cdouble}(0) + err_code = ccall( + (:caosdb_entity_property_get_double_value, CaosDB.library_name), + Cint, + (Ref{_Property}, Ref{Cdouble}), + property, + out, + ) + out = out[] + elseif prop_datatype[1] == "BOOLEAN" + out = Ref{Cint}(0) + err_code = ccall( + (:caosdb_entity_property_get_boolean_value, CaosDB.library_name), + Cint, + (Ref{_Property}, Ref{Cint}), + property, + out, + ) + out = convert(Bool, out[]) + elseif prop_datatype[1] == "TEXT" + out = Ref{Ptr{UInt8}}(Ptr{UInt8}()) + err_code = ccall( + (:caosdb_entity_property_get_string_value, CaosDB.library_name), + Cint, + (Ref{_Property}, Ref{Ptr{UInt8}}), + property, + out, + ) + out = unsafe_string(out[]) + end + CaosDB.Exceptions.evaluate_return_code(err_code) + end - return unsafe_string(out[]) + return out end """