hrszpuk / odin-ini

:fire: An easy to use and highly customizable INI serialiser/deserialiser for Odin!
MIT License
1 stars 0 forks source link

During serialisation `^Config.value` is modified for each section/sub-section #31

Open hrszpuk opened 3 months ago

hrszpuk commented 3 months ago
// Section name appends to a "prefix" which is made up of the previous structs.
            if prefix {
                section_head := fmt.aprintf("%s%v%s", c.value, Options.Symbols.NestedSection, value.value)
                strings.write_string(&sections, section_head)
                new_value := fmt.aprintf("%s%v%s", c.value, Options.Symbols.NestedSection, value.value)
                delete(value.value)

                // TODO(hrs) directly modifying the values means post-serialisation values will be different... If you serialise twice you'll get double the nesting.
                // Perhaps "prefix" could be a string of previous nesting? Override it for each new section/nested section.

                value.value = new_value
                delete(section_head)
            } else {
                strings.write_string(&sections, value.value)
            }

Directly modifying the section's value is a bad idea. This means serialising more than once will lead to repeated identifier names.