@@ -30,13 +30,13 @@ function add_loadsave(format, predicates)
30
30
end
31
31
end
32
32
33
- @doc """
33
+ """
34
34
`DataFormat{sym}()` indicates a known binary or text format of kind `sym`,
35
35
where `sym` is always a symbol. For example, a .csv file might have
36
36
`DataFormat{:CSV}()`.
37
37
38
38
An easy way to write `DataFormat{:CSV}` is `format"CSV"`.
39
- """ ->
39
+ """
40
40
immutable DataFormat{sym} end
41
41
42
42
macro format_str (s)
45
45
46
46
const unknown_df = DataFormat{:UNKNOWN }
47
47
48
- @doc """
49
- `unknown(f)` returns true if the format of `f` is unknown.""" ->
48
+ """
49
+ `unknown(f)` returns true if the format of `f` is unknown."""
50
50
unknown (:: Type{format"UNKNOWN"} ) = true
51
51
unknown {sym} (:: Type{DataFormat{sym}} ) = false
52
52
@@ -64,7 +64,7 @@ function add_format(fmt, magic, extension, load_save_libraries...)
64
64
fmt
65
65
end
66
66
67
- @doc """
67
+ """
68
68
`add_format(fmt, magic, extention)` registers a new `DataFormat`.
69
69
For example:
70
70
@@ -73,7 +73,7 @@ For example:
73
73
add_format(format"NRRD", "NRRD", [".nrrd",".nhdr"])
74
74
75
75
Note that extensions, magic numbers, and format-identifiers are case-sensitive.
76
- """ ->
76
+ """
77
77
function add_format {sym} (fmt:: Type{DataFormat{sym}} , magic: :@compat (Union{Tuple,AbstractVector,String}), extension)
78
78
haskey (sym2info, sym) && error (" format " , fmt, " is already registered" )
79
79
m = canonicalize_magic (magic)
@@ -113,9 +113,9 @@ function add_format{sym}(fmt::Type{DataFormat{sym}}, magic, extension)
113
113
fmt
114
114
end
115
115
116
- @doc """
116
+ """
117
117
`del_format(fmt::DataFormat)` deletes `fmt` from the format registry.
118
- """ ->
118
+ """
119
119
function del_format {sym} (fmt:: Type{DataFormat{sym}} )
120
120
magic, extension = sym2info[sym]
121
121
del_magic (magic, sym)
@@ -148,9 +148,9 @@ function del_magic{N}(magic::NTuple{N, UInt8}, sym)
148
148
nothing
149
149
end
150
150
151
- @doc """
151
+ """
152
152
`info(fmt)` returns the magic bytes/extension information for
153
- `DataFormat` `fmt`.""" ->
153
+ `DataFormat` `fmt`."""
154
154
Base. info {sym} (:: Type{DataFormat{sym}} ) = sym2info[sym]
155
155
156
156
@@ -209,32 +209,32 @@ end
209
209
210
210
abstract Formatted{F<: DataFormat } # A specific file or stream
211
211
212
- @doc """
212
+ """
213
213
`File(fmt, filename)` indicates that `filename` is a file of known
214
214
DataFormat `fmt`. For example, `File{fmtpng}(filename)` would indicate a PNG
215
- file.""" ->
215
+ file."""
216
216
immutable File{F<: DataFormat } <: Formatted{F}
217
217
filename:: Compat.UTF8String
218
218
end
219
219
File {sym} (fmt:: Type{DataFormat{sym}} , filename) = File {fmt} (filename)
220
220
221
- @doc """
221
+ """
222
222
`filename(file)` returns the filename associated with `File` `file`.
223
- """ ->
223
+ """
224
224
filename (f:: File ) = f. filename
225
225
226
- @doc """
226
+ """
227
227
`file_extension(file)` returns the file extension associated with `File` `file`.
228
- """ ->
228
+ """
229
229
file_extension (f:: File ) = splitext (filename (f))[2 ]
230
230
231
231
232
232
233
- @doc """
233
+ """
234
234
`Stream(fmt, io, [filename])` indicates that the stream `io` is
235
235
written in known `Format`. For example, `Stream{PNG}(io)` would
236
236
indicate PNG format. If known, the optional `filename` argument can
237
- be used to improve error messages, etc.""" ->
237
+ be used to improve error messages, etc."""
238
238
immutable Stream{F<: DataFormat ,IOtype<: IO } <: Formatted{F}
239
239
io:: IOtype
240
240
filename:: Nullable{Compat.UTF8String}
@@ -245,17 +245,17 @@ Stream{F<:DataFormat}(::Type{F}, io::IO, filename::AbstractString) = Stream{F,ty
245
245
Stream {F<:DataFormat} (:: Type{F} , io:: IO , filename) = Stream {F,typeof(io)} (io,filename)
246
246
Stream {F} (file:: File{F} , io:: IO ) = Stream {F,typeof(io)} (io,filename (file))
247
247
248
- @doc " `stream(s)` returns the stream associated with `Stream` `s`" ->
248
+ " `stream(s)` returns the stream associated with `Stream` `s`"
249
249
stream (s:: Stream ) = s. io
250
250
251
- @doc """
251
+ """
252
252
`filename(stream)` returns a nullable-string of the filename
253
- associated with `Stream` `stream`.""" ->
253
+ associated with `Stream` `stream`."""
254
254
filename (s:: Stream ) = s. filename
255
255
256
- @doc """
256
+ """
257
257
`file_extension(file)` returns a nullable-string for the file extension associated with `Stream` `stream`.
258
- """ ->
258
+ """
259
259
function file_extension (f:: Stream )
260
260
isnull (filename (f)) && return filename (f)
261
261
splitext (get (filename (f)))[2 ]
@@ -301,13 +301,13 @@ Base.readbytes(s::Stream, nb) = read(stream(s), nb)
301
301
Base. isreadonly (s:: Stream ) = isreadonly (stream (s))
302
302
Base. isopen (s:: Stream ) = isopen (stream (s))
303
303
304
- @doc " `magic(fmt)` returns the magic bytes of format `fmt`" ->
304
+ " `magic(fmt)` returns the magic bytes of format `fmt`"
305
305
magic {F<:DataFormat} (fmt:: Type{F} ) = UInt8[info (fmt)[1 ]. .. ]
306
306
307
- @doc """
307
+ """
308
308
`skipmagic(s)` sets the position of `Stream` `s` to be just after the magic bytes.
309
309
For a plain IO object, you can use `skipmagic(io, fmt)`.
310
- """ ->
310
+ """
311
311
skipmagic {F} (s:: Stream{F} ) = (skipmagic (stream (s), F); s)
312
312
function skipmagic {sym} (io, fmt:: Type{DataFormat{sym}} )
313
313
magic, _ = sym2info[sym]
345
345
unknown {F} (:: File{F} ) = unknown (F)
346
346
unknown {F} (:: Stream{F} ) = unknown (F)
347
347
348
- @doc """
348
+ """
349
349
`query(filename)` returns a `File` object with information about the
350
- format inferred from the file's extension and/or magic bytes.""" ->
350
+ format inferred from the file's extension and/or magic bytes."""
351
351
function query (filename:: AbstractString )
352
352
_, ext = splitext (filename)
353
353
if haskey (ext2sym, ext)
@@ -381,9 +381,9 @@ hasfunction(v::Vector) = any(hasfunction, v)
381
381
hasfunction (s:: Any ) = true # has function
382
382
hasfunction (s:: Tuple ) = false # has magic
383
383
384
- @doc """
384
+ """
385
385
`query(io, [filename])` returns a `Stream` object with information about the
386
- format inferred from the magic bytes.""" ->
386
+ format inferred from the magic bytes."""
387
387
query (io:: IO , filename) = query (io, Nullable (Compat. UTF8String (filename)))
388
388
389
389
function query (io:: IO , filename:: Nullable{Compat.UTF8String} = Nullable {Compat.UTF8String} ())
0 commit comments