Skip to content

Target section modification - #3

Draft
laurentj wants to merge 11 commits into
masterfrom
target-section-modification
Draft

Target section modification#3
laurentj wants to merge 11 commits into
masterfrom
target-section-modification

Conversation

@laurentj

Copy link
Copy Markdown
Member

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.

laurentj added 8 commits July 15, 2026 22:21
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().
@laurentj laurentj self-assigned this Jul 17, 2026
laurentj added 3 commits July 18, 2026 18:25
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant