diff --git a/Project.toml b/Project.toml index 856a712..0db91d9 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "SpiceData" uuid = "8ca2a67e-f683-5b14-a319-732e1d1d8f2e" -version = "0.3.1" +version = "0.3.2" [deps] diff --git a/src/base.jl b/src/base.jl index e8ada3c..80fcf7d 100644 --- a/src/base.jl +++ b/src/base.jl @@ -85,6 +85,25 @@ mutable struct DataReader end +#==Helper Functions +===============================================================================# + +hex(x::Integer) = string(x, base=16) +printable(v::String) = isprint(v) ? v : "" +_reorder(v::T, ::BigEndian) where T = ntoh(v) +_reorder(v::T, ::LittleEndian) where T = ltoh(v) + +#Debug: show block header info +function _show(io::IO, hdr::BlockHeader, pos::Int) + print(io, "Block: 0x", hex(WRITEBLOCK_SYNCWORD)) + print(io, " 0x", hex(hdr.typeid)) + print(io, " 0x", hex(WRITEBLOCK_SYNCWORD)) + print(io, " 0x", hex(hdr._size)) + print(io, " (start 0x", hex(pos), ")") + println(io) +end + + #==Exceptions ===============================================================================# function corruptword_exception(io::IO, w::DataWord, expected::DataWord) @@ -101,21 +120,9 @@ function stringboundary_exception(io::IO, ) end -#==Helper Functions +#== ===============================================================================# -printable(v::String) = isprint(v) ? v : "" - -#Debug: show block header info -function _show(io::IO, hdr::BlockHeader, pos::Int) - print(io, "Block: 0x", hex(WRITEBLOCK_SYNCWORD)) - print(io, " 0x", hex(hdr.typeid)) - print(io, " 0x", hex(WRITEBLOCK_SYNCWORD)) - print(io, " 0x", hex(hdr._size)) - print(io, " (start 0x", hex(pos), ")") - println(io) -end - #------------------------------------------------------------------------------- xtype(::Format_9601) = Float32 ytype(::Format_9601) = Float32 @@ -129,9 +136,6 @@ ytype(::Format_2001) = Float64 xtype(::Format_2013) = Float64 ytype(::Format_2013) = Float32 -#------------------------------------------------------------------------------- -_reorder(v::T, ::BigEndian) where T = ntoh(v) -_reorder(v::T, ::LittleEndian) where T = ltoh(v) #IO reads #-------------------------------------------------------------------------------