| parseTOML {RcppTOML} | R Documentation |
The parseTOML function parses ‘TOML’ (for ‘Tom's
Obvious Markup Language’) files. The TOML format both highly
readable and expressive, allows comments, indentation and other
aspects suitable for human readers, contains typed objects yet
allows everything similar configuration languages permit.
parseTOML(input, verbose = FALSE, fromFile=TRUE, includize=FALSE, escape=TRUE) ## S3 method for class 'toml' print(x, ...) ## S3 method for class 'toml' summary(object, ...)
input |
A character object either denoting a path and file (where tilde-expansion is performed as well) from parsing from file, or a containing a suitable ‘TOML’ expression that is parsed from this expression. |
verbose |
A logical switch to turn on (very) verbose operation which can be useful in debugging a parsing issue in a file. |
fromFile |
A logical switch indicating whether |
includize |
A logical switch indicating whether the
|
escape |
A logical switch indicating whether special characters in strings (namely new line, double quotation mark and backslash) should be escaped in both printed output (when verbose = TRUE) and returned values or only in the printed output. Defaults to TRUE for the sake of backward compatibility. |
x |
A toml object. |
object |
A toml object. |
... |
Furter arguments. |
The package uses the ‘cpptoml’ C++11 parser by Charles Geigle. This requires a recent-enough C++11 compiler which excludes one deployed by Rtools on Windows at the time the package was initially put together.
Following TOML specification this package assumes that any file input
is a UTF-8 encoded text file. Any non-file input (when fromFile
= FALSE) is converted to UTF-8 if necessary (using R's
enc2utf(). Note that the conversion to UTF-8 may fail for input
with "unknown" declared encoding if the true encoding does not match
system's locale.
A toml object is returned, which is really just a list object
with a class attribute to allow for print and summary
methods.
Dirk Eddelbuettel put togther the R package. Charles Geigle wrote the cpptoml parser. Tom Preston-Werner is the Tom behind TOML.
Maintainer: Dirk Eddelbuettel <edd@debian.org>
TOML: https://toml.io/en/ cpptoml: https://github.com/skystrife/cpptoml
library(RcppTOML)
file <- system.file("toml", "example.toml", package="RcppTOML")
toml <- parseTOML(file) # given file, return parsed object
summary(toml) # really sparse summary method
print(toml) # print is a wrapper around str()
txt <- "value='''\nHello\nWorld!'''" # input with \n is ..
parseTOML(input = txt, fromFile = FALSE) # ... (doubly) escaped by default
parseTOML(input = txt, fromFile = FALSE, escape = FALSE) # ... kept 'as is'