Merged
Conversation
Collaborator
|
The IniMap is duplicating what Object already does. Reuse |
|
@lerno thanks for the feedback, I've changed it to use Object. I did not look into it but you're right, much of the code could be removed |
Collaborator
|
Also, can you make sure that this submission conforms to the rules for contributing here: https://github.com/c3lang/c3c/blob/master/CONTRIBUTING.md |
Adds a new INI parsing and encoding module to the stdlib with: - parse()/tparse() and encode()/tencode() - Full mutation API: set, remove_key, remove_section, clear, free - Iteration: iter(), @each_key, @each (section, key, value) - IniOptions: delimiter, padding, inline comments, duplicate-key policy - GLOBAL section for pre-header keys - 30 tests covering parse, encode, round-trip, edge cases
Collaborator
|
I ended up rewriting this one significantly because the encodings should really properly be stream first. Unfortunately this is not the case for some of the older code, but new should do so. |
ChristianReifberger
added a commit
to ChristianReifberger/c3c
that referenced
this pull request
Apr 8, 2026
* Add std::encoding::ini module * Updated API for store/load using streams. Changed API --------- Co-authored-by: Christoffer Lerno <christoffer@aegik.com>
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.
Adds a new INI parsing and encoding module to the stdlib with:
Types
IniMap— the parsed/constructed map; owns all allocated stringsIniOptions— parser and encoder configuration; pass by value starting fromini::DEFAULT_OPTIONSDuplicateKeyBehavior— enum:DUPLICATE_OVERWRITE(default) orDUPLICATE_ERRORconst String GLOBAL = ""— sentinel for keys before the first section headerfaultdef INVALID_SECTION, INVALID_KEY, DUPLICATE_KEYAPI
Implementation notes
Tests
test/unit/stdlib/ini.c3tcovers all cases: basic parse, global keys, comments (; and #), whitespace trimming, empty values, colon delimiter, duplicate key policies (DUPLICATE_OVERWRITE / DUPLICATE_ERROR), error cases (INVALID_SECTION, INVALID_KEY), programmatic construction via init/set, mutation (remove_key, remove_section, clear), iteration (iter(), @each_key/each including GLOBAL visibility), round-trip parse → encode → parse, inline comments, CRLF line endings, and serialization options (pad_delimiter, custom delimiter).