Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Boolean Arrays return Lists #14

Closed
gerrymanoim opened this issue Mar 17, 2017 · 2 comments
Closed

Boolean Arrays return Lists #14

gerrymanoim opened this issue Mar 17, 2017 · 2 comments

Comments

@gerrymanoim
Copy link

@gerrymanoim gerrymanoim commented Mar 17, 2017

Sorry to pile on today.

Here's my TOML file:

title = "TOML Testing Example"

[testing]

bool = true
bool_vec = [true, false, true]

string = "Test String"
string_vec = ["All", "work and no", "play"]

num = 1
num_vec = [1, 2, 3, 4]

And my R code:

> library(RcppTOML)
> toml <- parseTOML("testing.toml")
> str(toml)

List of 2
 $ testing:List of 6
  ..$ bool      : logi TRUE
  ..$ bool_vec  :List of 3
  .. ..$ : logi TRUE
  .. ..$ : logi FALSE
  .. ..$ : logi TRUE
  ..$ num       : int 1
  ..$ num_vec   : int [1:4] 1 2 3 4
  ..$ string    : chr "Test String"
  ..$ string_vec: chr [1:3] "All" "work and no" "play"
 $ title  : chr "TOML Testing Example"
 - attr(*, "class")= chr [1:2] "toml" "list"
 - attr(*, "file")= chr "testing.toml"

I don't think that bool_vec should be structured as a list, right?

@eddelbuettel
Copy link
Owner

@eddelbuettel eddelbuettel commented Mar 17, 2017

That is the same segment of code. We consider numeric, int and string and pass everything else on unchanged. Will be easy to make logicals behave.

Keep'em coming :)

@eddelbuettel
Copy link
Owner

@eddelbuettel eddelbuettel commented Mar 17, 2017

That was literally just this (in case you can quickly re-build from source)

1 file changed, 5 insertions(+)
src/parse.cpp | 5 +++++

modified   src/parse.cpp
@@ -180,6 +180,11 @@ SEXP collapsedList(Rcpp::List ll) {
             return v;
             break;              // not reached ...
         }
+        case LGLSXP: {
+            Rcpp::LogicalVector v(ll.begin(), ll.end());
+            return v;
+            break;              // not reached ...
+        }
         case STRSXP: {              // minor code smell that this is different :-/
             int n = ll.size();
             Rcpp::CharacterVector v(n);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.