Target section modification - #3
Draft
laurentj wants to merge 11 commits into
Draft
Conversation
Documents test/build commands and the token-based parsing approach that lets IniReader/IniModifier preserve comments and formatting.
…ini file Unlike IniModifierArray, which always writes to the last file in the stack, IniModifierArray2 picks whichever modifiable file already has the section and parameter, else has the section, else the closest to the end of the stack — falling through read-only files along the way.
…difierArray setPreferedFile() lets callers pin sections to a specific ini file in the stack, taking priority over the existing 3-rule resolution; if no modifier matches that file yet, one is created and inserted just before the last (highest-priority) modifier. Bare filenames (no directory part) are resolved against an optional directory passed to the IniModifierArray2 constructor.
…eader
The parser now recognizes "; @preferedFile <filename>" comments above
a section, and a file-wide "; @defaultPreferedFile <filename>" fallback
for sections without their own attribute ("self" resolves to the
current file's basename). getPreferedFiles() exposes the result as
section => filename. IniModifier inherits this for free via IniReader.
… declared attributes The constructor now consults getPreferedFiles() on every stacked modifier that exposes it (IniReader/IniModifier), so @preferedFile comment attributes declared in the ini files themselves are honored without requiring an explicit setPreferedFile() call. Later (higher priority) modifiers override earlier ones for the same section, and relative filenames are resolved the same way as setPreferedFile().
Moves each section with a declared prefered file into that file when it currently lives elsewhere in the stack, merging values from every other modifiable file that has it and removing it from there. Reuses the same target resolution (find-or-create) as resolveTargetModifier().
"@preferedFile <filename> <section>" can now appear in any comment, directly targeting the named section, instead of requiring the comment to precede that section's header. The single-parameter form keeps its existing adjacency rule. getPreferedFiles() now also surfaces two-parameter declarations for sections not (yet) present in the file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When modifying several "merged" ini files, new methods and ini attributes allow to indicate in which ini file a new ini value should be stored. This is implemented into a new IniModifierArray2 class.