Learn R Programming

ctypesio (version 0.1.2)

set_bounds_check: For this connection, set the response when values do not fit into given type before writing.

Description

For this connection, set the response when values do not fit into given type before writing.

Usage

set_bounds_check(con, bounds_check = "error")

Value

Modified connection object

Arguments

con

Connection object or raw vector. Connection objects can be created with file(), url(), rawConnection() or any of the other many connection creation functions.

bounds_check

Default bounds checking behaviour. One of: 'ignore', 'warn', 'error'. Default: 'error'. This default may be over-ridden by specifying the bounds_check argument when calling individual functions.

ignore

No explicit checks will be made for out-of-bound values. The underlying R functions (e.g. readBin(), writeBin()) may still do checking.

warn

Explicit checks will be made for out-of-bound values. If any are found, then a warning() will be issued.

error

Explicit checks will be made for out-of-bound values. If any are found, then a error will be raised.

See Also

Other connection configuration functions: set_endian(), set_eof_check(), set_integer_promotion(), set_na_check()

Examples

Run this code
if (FALSE) { # interactive()
# Open a connection and configure it so out-of-bounds values
# will cause a warning only.
con <- rawConnection(as.raw(1:8), "rb")
con <- set_bounds_check(con, bounds_check = "warn")

# This line attempts to read a value from the connection which
# is too large to store in a double precision floating point without
# loss of integer precision.
# Usually this would cause an error to be raised, but the 'bounds_check'
# option has been set to give a warning only.
read_uint64(con, n = 1, promote = "dbl")

close(con)
}

Run the code above in your browser using DataLab