-
-
Notifications
You must be signed in to change notification settings - Fork 141
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
Parsing multiple files #92
Comments
While being a reasonable idea, there's a few barriers to overcome:
Given the above I don't think this feature belongs in the library. You're better off implementing this in your own code so you can handle conflicts exactly as you need them handled in your specific case. |
Hm, doesn't look like the specification people want to add this: toml-lang/toml#397 I don't get your first point. For me, it would be totally fine if some file creates a table array and another adds to it. As if they were in a single file. Having the same So, no, I don't need a recursive tree-merge solution. I mean with the simple concatenation one could have tables like Regarding the 2nd point: without a complicated recursive tree-merge solution there is no need for special conflict resolution. So in one aspect the proposed feature isn't equivalent to concatenating the files: element location reporting, i.e. line numbers and filenames need to be reset for each file. What would also work for me is some slightly lower-lever parse-file method, such as:
That means each call would just reuse what's already there. |
You don't, no, but if this is added to the library, it's not just for you. For it to work in a sane way it would have to be a tree merge; concatenation simply wouldn't work in the general case. I'm sorry but I'm not going to implement this. |
Fair enough. I don't see how anyone would want to have the tree-merge approach you think would be necessary, though. Such a tree-merge would be anything but sane. Perhaps your assumption that there is a 'general case' that requires it is flawed. |
I don't just think it would be necessary, it's easy to show that any 'consume multiple TOML files as one virtual one' approach would boil down to that out of necessity. Consider your assertion that "the result should be equivalent to concatenating the files first and then parsing it", and use the following two TOML files as inputs: # file1.toml
a = 1
[b]
c = 3 # file2.toml
d = 0
[e]
f = 0 If you just do an as-if concatenation, then effectively you have this: a = 1
[b]
c = 3
d = 0
[e]
f = 0 Note that
Nope. Not an assumption at all. See above. Obviously the above example is only a problem for documents with top-level keys; if you could guarantee that you never had top-level keys or conflicting names, a concatenation approach would work. But I, as the library author, can't mandate that! That's a very limiting restriction for the general case. You might be able to guarantee that in your own files as a domain-specific expectation, but then in that scenario you should just do the concatenation yourself in your own application. |
Is your feature request related to a problem? Please describe.
I would like to use tomlplusplus to parse multiple .toml files into a single parse_result.
Describe the solution you'd like
Basically I want to use it like this (or similar):
The result should be equivalent to concatenating the files first and then parsing it, e.g.:
Additional context
So why would that be useful?
Because splitting larger configurations into multiple toml files might simplify maintenance.
Example:
The text was updated successfully, but these errors were encountered: