Commit 720170b1 authored by Alberto Ramos's avatar Alberto Ramos

Updated documentation

parent a289f553
""" """
Set user name globally for writing BDIO files. Set user name globally for writing BDIO files.
BDIO_set_user(us::String)
### Arguments ### Arguments
- us: The user name - us: Set `us` as the user name when writing BDIO files.
### Examples ### Examples
```julia-repl ```julia-repl
...@@ -17,8 +19,10 @@ end ...@@ -17,8 +19,10 @@ end
""" """
Set host machine globally for writing BDIO files. Set host machine globally for writing BDIO files.
BDIO_set_host(us::String)
### Arguments ### Arguments
- us: The user name - us: Set `us` as the host when writing BDIO files.
### Examples ### Examples
```julia-repl ```julia-repl
...@@ -32,7 +36,11 @@ end ...@@ -32,7 +36,11 @@ end
""" """
Opens a BDIO file and returns the BDIO handle. The file can be opened in several modes: Opens a BDIO file and returns the BDIO handle.
BDIO_open(fname::String, mode::String, protocol_info::String="")
The file can be opened in several modes:
- Write mode ("w"): The file is created and a header written. If the file exists an error is printed. - Write mode ("w"): The file is created and a header written. If the file exists an error is printed.
- Write mode ("d"): The file is created and a header written. If the file exists it is overwritten. - Write mode ("d"): The file is created and a header written. If the file exists it is overwritten.
- Write mode ("a"): The file is created if it does not exist, or opened for appending if the file exists. - Write mode ("a"): The file is created if it does not exist, or opened for appending if the file exists.
...@@ -82,6 +90,8 @@ end ...@@ -82,6 +90,8 @@ end
""" """
Closes the file associated with fb and clears the record database Closes the file associated with fb and clears the record database
BDIO_close!(fb::BDIOstream)
## Arguments ## Arguments
- `fb`: A BDIOstream type. It must be associated with a file. - `fb`: A BDIOstream type. It must be associated with a file.
...@@ -90,36 +100,38 @@ Closes the file associated with fb and clears the record database ...@@ -90,36 +100,38 @@ Closes the file associated with fb and clears the record database
julia> fb = BDIO_open("new_file.bdio", "w", "Test file") julia> fb = BDIO_open("new_file.bdio", "w", "Test file")
julia> BDIO_close(fb) julia> BDIO_close(fb)
""" """
function BDIO_close!(fb) function BDIO_close!(fb::BDIOstream)
close(fb.io) close(fb.io)
fb.records = similar(Array{Record,1}, 0) fb.records = similar(Array{Record,1}, 0)
end end
""" """
Start a new BDIO record at the end of the file. Currently the supported formats are Start a new BDIO record at the end of the file.
- `BDIO_BIN_GENERIC`: Generic binary data
- `BDIO_ASC_EXEC`: ASCII Executable (i.e. `sh` script) BDIO_start_record!(fb::BDIOstream, ifmt, iuinfo, long::Bool = false)
- `BDIO_BIN_INT32BE`: 32-bit integer in Big Endian format
- `BDIO_BIN_INT32LE`: 32-bit integer in Little Endian format
- `BDIO_BIN_INT64BE`: 64-bit integer in Big Endian format
- `BDIO_BIN_INT64LE`: 64-bit integer in Little Endian format
- `BDIO_BIN_F32BE`: 32-bit float in Big Endian format
- `BDIO_BIN_F32LE`: 32-bit float in Little Endian format
- `BDIO_BIN_F64BE`: 64-bit float in Big Endian format
- `BDIO_BIN_F64LE`: 64-bit float in Little Endian format
- `BDIO_ASC_GENERIC`: ASCII text file
- `BDIO_ASC_XML`: Plain XML data
## Arguments ## Arguments
- `fb`: A BDIOstream type. It must be associated with a file in either `w` or `a` mode - `fb`: A BDIOstream type. It must be associated with a file in either `w` or `a` mode
- `ifmt`: Format (see above). - `ifmt`: Format. Currently the supported formats are
* `BDIO_BIN_GENERIC`: Generic binary data
* `BDIO_ASC_EXEC`: ASCII Executable (i.e. `sh` script)
* `BDIO_BIN_INT32BE`: 32-bit integer in Big Endian format
* `BDIO_BIN_INT32LE`: 32-bit integer in Little Endian format
* `BDIO_BIN_INT64BE`: 64-bit integer in Big Endian format
* `BDIO_BIN_INT64LE`: 64-bit integer in Little Endian format
* `BDIO_BIN_F32BE`: 32-bit float in Big Endian format
* `BDIO_BIN_F32LE`: 32-bit float in Little Endian format
* `BDIO_BIN_F64BE`: 64-bit float in Big Endian format
* `BDIO_BIN_F64LE`: 64-bit float in Little Endian format
* `BDIO_ASC_GENERIC`: ASCII text file
* `BDIO_ASC_XML`: Plain XML data
- `iuinfo`: Integer in the range 0-15. A user specified label to help indentifying the record - `iuinfo`: Integer in the range 0-15. A user specified label to help indentifying the record
- `long` (optional): If true create a long record. To store more than 1048575 bytes of data (``\\approx 1\\, {\\rm MB}``), a long record is required. Default value of `false`. - `long` (optional): If true create a long record. To store more than 1048575 bytes of data (``\\approx 1\\, {\\rm MB}``), a long record is required. Default value of `false`.
## Examples ## Examples
```julia-repl ```julia-repl
julia> fb = BDIO_open("new_file.bdio", "w", "Test file") julia> fb = BDIO_open("new_file.bdio", "w", "Test file")
julia> BDIO_start_record!(fb, BDIO.BDIO_BIN_F32, 2) julia> BDIO_start_record!(fb, BDIO_BIN_F32, 2)
``` ```
""" """
...@@ -160,6 +172,8 @@ end ...@@ -160,6 +172,8 @@ end
""" """
Write `data` to BDIO file to the end of the last record. Write `data` to BDIO file to the end of the last record.
BDIO_write!(fb::BDIOstream,data,hash::Bool=true)
## Arguments ## Arguments
- `fb`: A BDIOstream type. It must be associated with a file in either `w` or `a` mode. - `fb`: A BDIOstream type. It must be associated with a file in either `w` or `a` mode.
- `data`: Data to write to file. - `data`: Data to write to file.
...@@ -169,11 +183,11 @@ Write `data` to BDIO file to the end of the last record. ...@@ -169,11 +183,11 @@ Write `data` to BDIO file to the end of the last record.
```julia-repl ```julia-repl
julia> # Write 1000 normal random numbers to file `randoms.bdio` julia> # Write 1000 normal random numbers to file `randoms.bdio`
julia> fb = BDIO_open("randoms.bdio", "w", "File with random numbers") julia> fb = BDIO_open("randoms.bdio", "w", "File with random numbers")
julia> BDIO_start_record!(fb, BDIO.BDIO_BIN_F32, 2) julia> BDIO_start_record!(fb, BDIO_BIN_F32, 2)
julia> BDIO_write!(fb, randn(1000)) julia> BDIO_write!(fb, randn(1000))
``` ```
""" """
function BDIO_write!(fb,data,hash::Bool=true) function BDIO_write!(fb::BDIOstream,data,hash::Bool=true)
if (fb.imode == BDIO_R_MODE) if (fb.imode == BDIO_R_MODE)
error("Attemp to write in READ mode") error("Attemp to write in READ mode")
...@@ -198,8 +212,10 @@ end ...@@ -198,8 +212,10 @@ end
""" """
Write the `MD5` checksum of the actual record as a new record. Write the `MD5` checksum of the actual record as a new record.
BDIO_write_hash!(fb::BDIOstream)
## Arguments ## Arguments
- `fb`: A BDIOstream type. It must be associated with a file in either `w` or `a` mode. - `fb`: A `BDIOstream` type. It must be associated with a file in either `w` or `a` mode.
## Examples ## Examples
```julia-repl ```julia-repl
...@@ -227,9 +243,11 @@ end ...@@ -227,9 +243,11 @@ end
""" """
Move the read position backward/forward `icnt` records Move the read position backward/forward `icnt` records
BDIO_seek!(fb::BDIOstream, icnt::Int = 1)
## Arguments ## Arguments
- `fb`: A BDIOstream type. It must be associated with a file. - `fb`: A BDIOstream type. It must be associated with a file.
- `icnt` (optional): number of records to move forward (if `icnt>0`) or backwards (`icnt<0`). The default value is `+1`. - `icnt` (optional): number of records to move forward (if `icnt>0`) or backwards (`icnt<0`). If `icnt=0` move to the first record. The default value is `+1`.
## Examples ## Examples
```julia-repl ```julia-repl
...@@ -261,6 +279,8 @@ end ...@@ -261,6 +279,8 @@ end
""" """
Read `data` from BDIO file. Read `data` from BDIO file.
BDIO_read(fb::BDIOstream, vdata::Vector, n::Int64 = 0)
## Arguments ## Arguments
- `fb`: A BDIOstream type. It must be associated with a file in either `w` or `a` mode. - `fb`: A BDIOstream type. It must be associated with a file in either `w` or `a` mode.
- `data[:]`: A `Vector` of data to read. - `data[:]`: A `Vector` of data to read.
...@@ -275,7 +295,7 @@ julia> data = similar({Array, 1}, 1000) ...@@ -275,7 +295,7 @@ julia> data = similar({Array, 1}, 1000)
julia> BDIO_read(fb, data) julia> BDIO_read(fb, data)
``` ```
""" """
function BDIO_read(fb, vdata::Vector, n::Int64 = 0) function BDIO_read(fb::BDIOstream, vdata::Vector, n::Int64 = 0)
if (n>0) if (n>0)
nmax = n nmax = n
...@@ -299,8 +319,10 @@ end ...@@ -299,8 +319,10 @@ end
""" """
Returns the len (in bytes) of the current record Returns the len (in bytes) of the current record
BDIO_get_len(fb::BDIOstream)
## Arguments ## Arguments
- `fb`: A BDIOstream type. It must be associated with a file. - `fb`: A `BDIOstream` type. It must be associated with a file.
## Examples ## Examples
```julia-repl ```julia-repl
...@@ -317,8 +339,10 @@ BDIO_get_len(fb::BDIOstream) = fb.records[fb.ipt].rlen ...@@ -317,8 +339,10 @@ BDIO_get_len(fb::BDIOstream) = fb.records[fb.ipt].rlen
""" """
Returns the format of the current record Returns the format of the current record
BDIO_get_fmt(fb::BDIOstream)
## Arguments ## Arguments
- `fb`: A BDIOstream type. It must be associated with a file. - `fb`: A `BDIOstream` type. It must be associated with a file.
## Examples ## Examples
```julia-repl ```julia-repl
...@@ -337,8 +361,10 @@ BDIO_get_fmt(fb::BDIOstream) = fb.records[fb.ipt].rfmt ...@@ -337,8 +361,10 @@ BDIO_get_fmt(fb::BDIOstream) = fb.records[fb.ipt].rfmt
""" """
Returns the user provided info of each record Returns the user provided info of each record
BDIO_get_uinfo(fb::BDIOstream)
## Arguments ## Arguments
- `fb`: A BDIOstream type. It must be associated with a file. - `fb`: A `BDIOstream type`. It must be associated with a file.
## Examples ## Examples
```julia-repl ```julia-repl
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment