diff --git a/src/Entity.jl b/src/Entity.jl index 2e7197133cd8febf88a14672e0f13c6252016c76..cb63ebf8bd999a575a43fad80c8054055869b35f 100644 --- a/src/Entity.jl +++ b/src/Entity.jl @@ -750,22 +750,6 @@ function get_value(entity::Ref{_Entity}) return unsafe_string(out[]) end -function get_property_list_length(property::Ref{_Property}) - - length = Ref{Cint}(0) - - err_code = ccall( - (:caosdb_entity_property_get_value_list_length, CaosDB.library_name), - Cint, - (Ref{_Property}, Ref{Cint}), - property, - length, - ) - - CaosDB.Exceptions.evaluate_return_code(err_code) - - return length[] -end """ function get_value(property::Ref{_Property}) @@ -774,7 +758,7 @@ Return the value of the given `property` function get_value(property::Ref{_Property}) _caosdb_dtypes = ("INTEGER", "DOUBLE", "BOOLEAN", "TEXT") - + prop_datatype = get_datatype(property) is_list = prop_datatype[3] if prop_datatype[1] in _caosdb_dtypes @@ -788,7 +772,7 @@ function get_value(property::Ref{_Property}) property, out, ) - + out = out[] elseif prop_datatype[1] == "DOUBLE" out = Ref{Cdouble}(0) @@ -825,31 +809,31 @@ function get_value(property::Ref{_Property}) list_length = get_property_list_length(property) if prop_datatype[1] == "INTEGER" out = Vector{Cint}() - for i::Cint in 1:list_length + for i::Cint = 1:list_length temp = get_int_list_value_at(property, i) append!(out, temp) end elseif prop_datatype[1] == "DOUBLE" out = Vector{Cdouble}() - for i::Cint in 1:list_length + for i::Cint = 1:list_length temp = get_double_list_value_at(property, i) append!(out, temp) end elseif prop_datatype[1] == "BOOLEAN" out = Vector{Bool}() - for i::Cint in 1:list_length + for i::Cint = 1:list_length temp = get_bool_list_value_at(property, i) append!(out, temp) end elseif prop_datatype[1] == "TEXT" out = Vector{String}() - for i::Cint in 1:list_length + for i::Cint = 1:list_length temp = get_string_list_value_at(property, i) append!(out, [temp]) end end end - if @isdefined err_code + if @isdefined err_code CaosDB.Exceptions.evaluate_return_code(err_code) end end @@ -857,22 +841,44 @@ function get_value(property::Ref{_Property}) return out end +""" + function get_property_list_length(property::Ref{_Property}) + +Return the length of the list of the given `property` +""" +function get_property_list_length(property::Ref{_Property}) + + length = Ref{Cint}(0) + + err_code = ccall( + (:caosdb_entity_property_get_value_list_length, CaosDB.library_name), + Cint, + (Ref{_Property}, Ref{Cint}), + property, + length, + ) + + CaosDB.Exceptions.evaluate_return_code(err_code) + + return length[] +end + """ function get_int_list_value_at(property::Ref{_Property}, index::Cint) Return the value of the INTEGER list of the given `property` at the position `index`. """ function get_int_list_value_at(property::Ref{_Property}, index::Cint) - + err_code = ccall( (:caosdb_entity_property_get_int_list_value_at, CaosDB.library_name), Cint, (Ref{_Property}, Ref{Cint}, Cint), property, out, - index-Cint(1), - ) - + index - Cint(1), + ) + CaosDB.Exceptions.evaluate_return_code(err_code) return out[] end @@ -890,8 +896,8 @@ function get_double_list_value_at(property::Ref{_Property}, index::Cint) (Ref{_Property}, Ref{Cdouble}, Cint), property, out, - index-Cint(1), - ) + index - Cint(1), + ) CaosDB.Exceptions.evaluate_return_code(err_code) return out[] @@ -910,8 +916,8 @@ function get_bool_list_value_at(property::Ref{_Property}, index::Cint) (Ref{_Property}, Ref{Cint}, Cint), property, out, - index-Cint(1), - ) + index - Cint(1), + ) CaosDB.Exceptions.evaluate_return_code(err_code) out = convert(Bool, out[]) @@ -931,8 +937,8 @@ function get_string_list_value_at(property::Ref{_Property}, index::Cint) (Ref{_Property}, Ref{Ptr{UInt8}}, Cint), property, out, - index-Cint(1), - ) + index - Cint(1), + ) CaosDB.Exceptions.evaluate_return_code(err_code) out = unsafe_string(out[])