Feature/updated cpptoml #10

Merged
merged 3 commits into from Jan 29, 2017

Projects

None yet

2 participants

@eddelbuettel
Owner

No description provided.

added some commits Jan 23, 2017
@eddelbuettel new upstream version of cpptoml.h 19a60c2
@eddelbuettel support for local_date(time)
rolled version
7b17e2b
@eddelbuettel support parse from character
4be0896
@eddelbuettel eddelbuettel merged commit b5b4aa0 into master Jan 29, 2017

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
@eddelbuettel eddelbuettel deleted the feature/updated_cpptoml branch Jan 29, 2017
@eddelbuettel eddelbuettel referenced this pull request Jan 29, 2017
Closed

parse from string #7

@dpastoor
Contributor

just wanted to pass along, tried it out, works beautifully!

For those that come along and would like an example,

example_string <- "
[[test]]
var1 = 'hello'
var2 = 2
var3 = '''
some
multiline string
'''
[test2]
date = 1970-01-01
"

RcppTOML::parseTOML(example_string, fromFile = F)

which gives

image

@eddelbuettel any reason why the print method gives a trailing NULL value?

Even when saving to an object, when querying the object, it always has that trailing NULL

output <- RcppTOML::parseTOML(example_string, fromFile = F)

> output
List of 2
 $ test :List of 3
  ..$ var1: chr "hello"
  ..$ var2: int 2
  ..$ var3: chr "some\\nmultiline string\\n"
 $ test2:List of 1
  ..$ date: Date[1:1], format: "1970-01-01"
NULL

Just in case:

> devtools::session_info()
Session info ------------------------------------------------------------------------------------------------------------
 setting  value                       
 version  R version 3.3.2 (2016-10-31)
 system   x86_64, mingw32             
 ui       RStudio (1.1.36)            
 language (EN)                        
 collate  English_United States.1252  
 tz       America/New_York            
 date     2017-01-29                  

Packages ----------------------------------------------------------------------------------------------------------------
 package    * version     date       source                                
 assertthat   0.1         2013-12-06 CRAN (R 3.3.2)                        
 backports    1.0.4       2016-10-24 CRAN (R 3.3.2)                        
 callr        1.0.0.9000  2017-01-07 Github (mangothecat/callr@3007ba2)    
 curl         2.3         2016-11-24 CRAN (R 3.3.2)                        
 DBI          0.5-1       2016-09-10 CRAN (R 3.3.2)                        
 devtools     1.12.0.9000 2017-01-07 Github (hadley/devtools@1ce84b0)      
 digest       0.6.11      2017-01-03 CRAN (R 3.3.2)                        
 dplyr        0.5.0       2016-06-24 CRAN (R 3.3.2)                        
 git2r        0.18.0      2017-01-01 CRAN (R 3.3.2)                        
 httr         1.2.1       2016-07-03 CRAN (R 3.3.2)                        
 jsonlite     1.2         2016-12-31 CRAN (R 3.3.2)                        
 magrittr     1.5         2014-11-22 CRAN (R 3.3.2)                        
 memoise      1.0.0       2016-01-29 CRAN (R 3.3.2)                        
 pkgbuild     0.0.0.9000  2017-01-07 Github (r-pkgs/pkgbuild@65eace0)      
 pkgload      0.0.0.9000  2017-01-07 Github (r-pkgs/pkgload@def2b10)       
 R6           2.2.0       2016-10-05 CRAN (R 3.3.2)                        
 rbabylon   * 0.0.2       <NA>       local                                 
 Rcpp         0.12.8      2016-11-17 CRAN (R 3.3.2)                        
 RcppTOML     0.1.0.1     2017-01-30 Github (eddelbuettel/rcpptoml@b5b4aa0)
 roxygen2     5.0.1       2015-11-11 CRAN (R 3.3.2)                        
 rprojroot    1.1         2016-10-29 CRAN (R 3.3.2)                        
 stringi      1.1.2       2016-10-01 CRAN (R 3.3.2)                        
 stringr      1.1.0       2016-08-19 CRAN (R 3.3.2)                        
 tibble       1.2         2016-08-26 CRAN (R 3.3.2)                        
 withr        1.0.2       2016-06-20 CRAN (R 3.3.2) 
@eddelbuettel
Owner
eddelbuettel commented Jan 30, 2017 edited

We use str() inside the print() and I dont't know how to not make it show NULL.

@eddelbuettel
Owner

This seems to work better:

print.toml <- function(x, ...) { cat(utils::str(x, give.attr=FALSE)); invisible(x) }

Now:

R> z
List of 2
 $ test :List of 3
  ..$ var1: chr "hello"
  ..$ var2: int 2
  ..$ var3: chr "some\\nmultiline string\\n"
 $ test2:List of 1
  ..$ date: Date[1:1], format: "1970-01-01"
R> print(z)
List of 2
 $ test :List of 3
  ..$ var1: chr "hello"
  ..$ var2: int 2
  ..$ var3: chr "some\\nmultiline string\\n"
 $ test2:List of 1
  ..$ date: Date[1:1], format: "1970-01-01"
R> 

I'll make the change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment