Utilities
DynamicStructs defines a few functions to simplify working with dynamic properties, as well as the more general case where propertynames(x) != fieldnames(typeof(x)).
DynamicStructs.NoFields — TypeInsert as second argument to Base.propertynames, propertyvalues, or propertypairs to exclude field names.
DynamicStructs.OnlyFields — TypeInsert as second argument to Base.propertynames, propertyvalues, or propertypairs to include only field names.
Base.propertynames — FunctionBase.propertynames(x, ::Type{NoFields}, private=false)Excludes field names.
Base.propertynames(x, ::Type{OnlyFields}, private=false)Includes only field names.
DynamicStructs.propertyvalues — Functionpropertyvalues(x, args...)Get a tuple of the current property values. args is propagated to Base.propertynames.
DynamicStructs.propertypairs — Functionpropertypairs(x, args...)Get a tuple of the current property names and values. args is propagated to Base.propertynames.
Examples
julia> using DynamicStructsjulia> @dynamic struct Spaceship name::String endjulia> ship = Spaceship("Blip-A"; pressure=28.0)Main.Spaceship("Blip-A"; pressure = 28.0)julia> propertynames(ship, OnlyFields)(:name,)julia> propertynames(ship, NoFields)(:pressure,)julia> propertyvalues(ship)("Blip-A", 28.0)julia> propertyvalues(ship, NoFields)(28.0,)julia> propertypairs(ship)(:name => "Blip-A", :pressure => 28.0)julia> propertypairs(ship, OnlyFields)(:name => "Blip-A",)julia> ship == Spaceship(propertyvalues(ship, OnlyFields)...; propertypairs(ship, NoFields)...)true