Skip to content

Fix XML get_field_from_array index increment and write() indent forwarding - #71

Open
clockblocker wants to merge 1 commit into
mainfrom
fix-xml-array-and-indent
Open

clockblocker wants to merge 1 commit into
mainfrom
fix-xml-array-and-indent

Conversation

@clockblocker

@clockblocker clockblocker commented Nov 27, 2026 •

Copy link
Copy Markdown
Owner

AI-authored below this line.

Upstream PR: munich-data-engineering/reflect-cpp#800

Problem

Reading any XML array element past index 0 always failed out-of-bounds because the loop counter was never incremented.

Separately, rfl::xml::write(obj, indent) silently ignored the custom indent string and always emitted 4 spaces.

// XML: <root><item>a</item><item>b</item><item>c</item></root>

// Before:
reader.get_field_from_array(1, arr);  // Error: "Index 1 of of bounds."
rfl::xml::write(person, "  ");        // ignores "  "; always uses default 4-space indent

// After:
reader.get_field_from_array(1, arr);  // Ok: "b" (index 3 -> "Index 3 out of bounds.")
rfl::xml::write(person, "  ");        // indents with 2 spaces ("" produces compact XML)

Summary

  • Increments the sibling counter in the XML array lookup loop and fixes the "of of bounds." typo in its error message.
  • Forwards the caller's indentation string to the stream-based XML writer overload and adds unit tests for both fixes.
For Agents

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant