skystrife / cpptoml

cpptoml is a header-only library for parsing TOML

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Feature] Add include directive?

eddelbuettel opened this issue · comments

We have some use cases where an #include <>-alike would be really handy. I looked over at the TOML repo and eg in #36 this is dismissed as against the minimalist design. I do have some sympathy for this rejection.

Yet this feature would be handy. Would you entertain the idea here to go 'slightly beyond' the spec, or do you think that is a bad idea?

I think I can also get to this from my RcppTOML package by potentially postprocessing the initial read, and responding to a particular token, and then merge. Better idea, maybe?

Hmm, this is interesting. I think the proper thing to do here is to handle this outside of the parser since this is not an officially recognized feature of the spec.

In theory, you could set up a special "language" in the configuration file to specify these includes like you mentioned, and then post-process the output to perform the actual include.

Something akin to

includes = ["file1.toml", "file2.toml", "file3.toml"]

or something.