-
Notifications
You must be signed in to change notification settings - Fork 164
Open
Description
When parsing XML text into a rfl::Generic, the result is a boolean with value false.
`
#include
#include <rfl/xml.hpp>
#include <rfl/generic.hpp>
#include <rfl.hpp>
int main() {
rfl::Generic::Object cat;
cat["name"] = "Cachou";
cat["colour"] = "black";
cat["species"] = "cat";
auto xmlString = rfl::xml::write<"cat">(cat);
auto genericCatVariant = rfl::xml::read<rfl::Generic>(xmlString).value().variant();
auto type = genericCatVariant.index();
std::cout << std::format("XML content:\n{}\n", xmlString);
/*
Shows this:
XML content:
<?xml version="1.0" encoding="UTF-8"?>
<cat>
<name>Cachou</name>
<colour>black</colour>
<species>cat</species>
</cat>
*/
std::cout << std::format("Type index {}\n", type);
/*
Shows this instead of 4 (Object):
Type index 0
*/
if (type == 0) {
std::cout << std::format("Boolean value {}\n", std::get<0>(genericCatVariant));
}
else {
std::cout << "Not a boolean.";
}
/*
Shows this:
Boolean value false
*/
return 0;
}
`
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels