Skip to content

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

Open
clockblocker wants to merge 1 commit into
munich-data-engineering:mainfrom
clockblocker:fix-xml-array-and-indent
Open

clockblocker wants to merge 1 commit into
munich-data-engineering:mainfrom
clockblocker:fix-xml-array-and-indent

Conversation

@clockblocker

@clockblocker clockblocker commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

AI-authored below this line.

Problem

Two one-line bugs affect basic rfl::xml helpers:

  1. rfl::xml::Reader::get_field_from_array never increments its sibling index i, so reading any element past index 0 always fails with an out-of-bounds error (with an "of of bounds." typo).
  2. rfl::xml::write(obj, indent) forwards to the std::ostream& overload without passing _indent, silently falling back to the default 4-space indentation.
// 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 indents with 4 spaces

// 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 ("" emits compact XML)

Summary

  • Increments the sibling counter i in rfl::xml::Reader::get_field_from_array and fixes the "of of bounds." typo to "out of bounds.".
  • Forwards _indent from the string-returning rfl::xml::write overload to the stream-based overload.

Testing

clockblocker added a commit to clockblocker/reflect-cpp that referenced this pull request Nov 29, 2026
… forwarding

Fixes two bugs in `rfl::xml`:
1. `rfl::xml::Reader::get_field_from_array` never incremented `i` in its
   sibling loop, causing any `_idx > 0` to always fail out-of-bounds (also
   fixes the `"of of bounds."` typo).
2. `rfl::xml::write(obj, _indent)` dropped `_indent` when forwarding to the
   `std::ostream&` overload.

Upstream PR: munich-data-engineering#800
clockblocker added a commit to clockblocker/reflect-cpp that referenced this pull request Nov 29, 2026
… forwarding

Fixes two bugs in `rfl::xml`:
1. `rfl::xml::Reader::get_field_from_array` never incremented `i` in its
   sibling loop, causing any `_idx > 0` to always fail out-of-bounds (also
   fixes the `"of of bounds."` typo).
2. `rfl::xml::write(obj, _indent)` dropped `_indent` when forwarding to the
   `std::ostream&` overload.

Upstream PR: munich-data-engineering#800
clockblocker added a commit to clockblocker/reflect-cpp that referenced this pull request Nov 30, 2026
… forwarding

Fixes two bugs in `rfl::xml`:
1. `rfl::xml::Reader::get_field_from_array` never incremented `i` in its
   sibling loop, causing any `_idx > 0` to always fail out-of-bounds (also
   fixes the `"of of bounds."` typo).
2. `rfl::xml::write(obj, _indent)` dropped `_indent` when forwarding to the
   `std::ostream&` overload.

Upstream PR: munich-data-engineering#800
@clockblocker
clockblocker force-pushed the fix-xml-array-and-indent branch from 1cd25fa to 46eecd7 Compare December 1, 2026 06:05
clockblocker added a commit to clockblocker/reflect-cpp that referenced this pull request Dec 1, 2026
… forwarding

Fixes two bugs in `rfl::xml`:
1. `rfl::xml::Reader::get_field_from_array` never incremented `i` in its
   sibling loop, causing any `_idx > 0` to always fail out-of-bounds (also
   fixes the `"of of bounds."` typo).
2. `rfl::xml::write(obj, _indent)` dropped `_indent` when forwarding to the
   `std::ostream&` overload.

Upstream PR: munich-data-engineering#800

This branch has not been deployed

No deployments
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