From fb3f50f23e44ae3f3592df5bb3af63e100a26ed8 Mon Sep 17 00:00:00 2001 From: florian <f.spreckelsen@inidscale.com> Date: Tue, 7 Sep 2021 10:40:20 +0200 Subject: [PATCH] ENH: Implement get_value for references --- src/Entity.jl | 43 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/src/Entity.jl b/src/Entity.jl index 064b5dc..6dce4d3 100644 --- a/src/Entity.jl +++ b/src/Entity.jl @@ -806,11 +806,29 @@ function get_value(entity::Ref{_Entity}) end end end - if @isdefined err_code - CaosDB.Exceptions.evaluate_return_code(err_code) + elseif ent_datatype[2] + # is reference + if !is_list + out = Ref{Ptr{UInt8}}(Ptr{UInt8}()) + err_code = ccall( + (:caosdb_entity_entity_get_string_value, CaosDB.library_name), + Cint, + (Ref{_Entity}, Ref{Ptr{UInt8}}), + entity, + out, + ) + out = unsafe_string(out[]) + else + # is list of references + list_length = get_property_list_length(entity) + out = [get_string_list_value_at(entity, Cint(ii)) for ii = 1:list_length] end end + if @isdefined err_code + CaosDB.Exceptions.evaluate_return_code(err_code) + end + return out end @@ -897,10 +915,27 @@ function get_value(property::Ref{_Property}) end end end - if @isdefined err_code - CaosDB.Exceptions.evaluate_return_code(err_code) + elseif prop_datatype[2] + # is reference + if !is_list + 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[]) + else + # is list of references + list_length = get_property_list_length(property) + out = [get_string_list_value_at(property, Cint(ii)) for ii = 1:list_length] end end + if @isdefined err_code + CaosDB.Exceptions.evaluate_return_code(err_code) + end return out end -- GitLab