Movatterモバイル変換


[0]ホーム

URL:


Dirk Eddelbuettel

RcppTOML: Rcpp bindings forTOML

Build StatusLicenseCRANDependenciesDownloadsLast Commit

What is TOML?

TOML is a configuration filegrammar for humans. It is easier to read and edit than the alternativesyet arguably more useful as it is strongly typed: values come back asinteger, double, (multiline-) character (strings), boolean or Datetime.Moreover, complex nesting and arrays are supported as well.

This package uses the C++11 implementation written by Chase Geigle incpptoml to provide aparser that can be used by R.

Example

Consider the followingTOML inputexample input:

# This is a TOML document.title="TOML Example"[owner]name="Tom Preston-Werner"dob=1979-05-27T07:32:00-08:00# First class dates[database]server="192.168.1.1"ports=[8001,8001,8002]connection_max=5000enabled=true[servers]# Indentation (tabs and/or spaces) is allowed but not required[servers.alpha]ip="10.0.0.1"dc="eqdc10"[servers.beta]ip="10.0.0.2"dc="eqdc10"[clients]data=[["gamma","delta"],[1,2]]# Line breaks are OK when inside arrayshosts=["alpha","omega"]

Once parsed, note how R has properly typed input:

R>library(RcppTOML)R>parseTOML("inst/toml/example.toml")List of5$ clients:List of2  ..$ data:List of2  .. ..$: chr [1:2]"gamma""delta"  .. ..$: int [1:2]12  ..$ hosts: chr [1:2]"alpha""omega"$ database:List of4  ..$ connection_max: int5000  ..$ enabled: logiTRUE  ..$ ports: int [1:3]800180018002  ..$ server: chr"192.168.1.1"$ owner:List of2  ..$ dob: POSIXct[1:1], format:"1979-05-27 15:32:00"  ..$ name: chr"Tom Preston-Werner"$ servers:List of2  ..$ alpha:List of2  .. ..$ dc: chr"eqdc10"  .. ..$ ip: chr"10.0.0.1"  ..$ beta:List of2  .. ..$ dc: chr"eqdc10"  .. ..$ ip: chr"10.0.0.2"$ title: chr"TOML Example"R>

See the other examples and theupstreamdocumentation for more. Also note that most decent editors haveproperTOML support which makesediting and previewing a breeze:

Installation

The package is onCRAN andcan be installed from every mirror via

install.packages("RcppTOML")

Development releases may be provided by theghrr repository which canaccessed via

## if needed, first do:  install.packages("drat")drat::addRepo("ghrr")

Status

Feature-complete withTOMLv0.5.0, see thetests/directory. It parses everything that the underlyingcpptoml parses with thesame (sole) exception of unicode escape characters in strings.

Installation

The package is onCRAN andcan be installed via a standard

install.packages("RcppTOML")

Continued Testing

As we rely on thetinytest package,the already-installed package can also be verified via

tinytest::test_package("RcppTOML")

at any later point.

Author

Dirk Eddelbuettel

License

GPL (>= 2)

Initially created: Mon Apr 27 20:44:45 CDT 2015
Last modified: Sun May 26 10:18:33 CDT 2024


[8]
ページ先頭

©2009-2025 Movatter.jp