32 [[nodiscard]] uint64_t
row() const noexcept {
return m_row; }
33 [[nodiscard]] std::string_view name() const noexcept;
34 [[nodiscard]]
std::optional<
std::string_view> attribute(
std::string_view name) const noexcept;
40 template <typename Fn>
41 bool for_each_field(Fn&& visitor) const;
48 const
Kakshya::ForestIndex& forest,
size_t row) noexcept
76 for (
size_t index =
m_row + 1; index < end; index +=
m_forest->subtree_size(index)) {
77 const auto source =
m_rows->at(index);
81 const auto kind = source->text(
"kind");
82 if (!kind || (*kind !=
"attribute" && *kind !=
"element"))
85 const auto field_name = source->text(
"name");
92 .value = source->text(
"value").value_or(std::string_view {}),
93 .
row =
static_cast<uint64_t
>(index),
94 .element = *kind ==
"element"
98 if constexpr (std::same_as<std::invoke_result_t<Fn&, const XmlFieldView&>,
bool>) {
99 if (!std::invoke(visitor, field))
102 std::invoke(visitor, field);
135 [[nodiscard]]
bool can_read(
const std::string& filepath)
const override;
141 bool open(
const std::string& filepath,
145 void close()
override;
151 [[nodiscard]] std::optional<FileMetadata> get_metadata()
const override;
154 [[nodiscard]] std::vector<FileRegion>
get_regions()
const override {
return {}; }
157 [[nodiscard]] std::optional<Kakshya::CompositeArray> read_composite()
override;
163 [[nodiscard]] std::optional<Kakshya::CompositeArray> read_next(
size_t max_elements)
override;
166 [[nodiscard]] std::optional<Kakshya::CompositeLayout> get_layout()
const override;
169 [[nodiscard]] std::optional<XmlElementView> root_element() const noexcept;
172 [[nodiscard]]
std::optional<
XmlElementView> element_at(uint64_t row) const noexcept;
185 [[nodiscard]] std::optional<Kakshya::CompositeArray> take_rows();
191 bool seek(
const std::vector<uint64_t>& position)
override;
206 [[nodiscard]] std::vector<uint64_t> get_dimension_sizes()
const override;
209 std::optional<Kakshya::CompositeArray>
m_rows;
Typed FileReader boundary for schema-bearing Composite data.
const Kakshya::CompositeArray * m_rows
XmlElementView(const Kakshya::CompositeArray &rows, const Kakshya::ForestIndex &forest, size_t row) noexcept
uint64_t row() const noexcept
bool for_each_field(Fn &&visitor) const
Visit attributes and immediate child elements in document order.
const Kakshya::ForestIndex * m_forest
Borrowed XML element with named attributes and immediate child elements.
std::vector< uint64_t > get_read_position() const override
Global index of the next row.
const Kakshya::CompositeArray * rows_view() const noexcept
Borrow the parsed XML rows while the reader remains open.
uint64_t get_preferred_chunk_size() const override
Suggested size for bounded Composite copies.
std::vector< FileRegion > get_regions() const override
XML nodes do not declare FileRegion values.
bool can_read(const std::string &filepath) const override
Accept paths with the .xml extension.
std::vector< std::string > get_supported_extensions() const override
Supported extension without a dot.
bool open(const std::string &filepath, FileReadOptions options=FileReadOptions::ALL) override
Parse an XML file and establish the fixed node layout.
size_t get_num_dimensions() const override
The document is exposed as one row axis.
void close() override
Release parsed rows and reset the read position.
std::optional< Kakshya::CompositeArray > m_rows
std::optional< Kakshya::ForestIndex > m_forest
bool supports_streaming() const override
The parser loads the complete XML document on open().
bool is_open() const override
Whether parsed rows are available.
Read an XML document into preorder Composite rows.
Owns a sequence of values that share a CompositeLayout.
Parent, child, depth and subtree structure over rows linked by parent index.
FileReadOptions
Generic options for file reading behavior.
@ ALL
All options enabled.
Kakshya::CompositeLayout xml_composite_layout()
Composite row layout used by the XML reader and writer.
std::optional< XmlElementView > element
One attribute or immediate child element borrowed from an XML element.