diff --git a/src/Countries.jl b/src/Countries.jl index 3011415..8ef6ce3 100644 --- a/src/Countries.jl +++ b/src/Countries.jl @@ -24,7 +24,8 @@ Licensed under MIT License, see LICENSE.md """ module Countries -export Country +export Country, country, @country +export name, code, currencies, dial, capital, continent, isdeveloping, region, subregion """ This is a singleton type, intended to be used as a label for dispatch purposes @@ -55,6 +56,13 @@ country(S::Symbol) = _country_data[S][1] country(::Type{C}) where {C<:Country} = C +macro country(syms) + args = syms isa Expr ? syms.args : [syms] + for nam in args + @eval __module__ const $nam = Countries.$nam + end +end + """ Returns the official name from the UN Statistics Division. """ @@ -109,4 +117,9 @@ end allsymbols() = keys(_country_data) allpairs() = pairs(_country_data) +# Contruct cash position types for convenience. +for (s,(cntry,u,c,n)) in Countries.allpairs() + @eval const $s = typeof($(country(cntry))()) +end + end # module Countries