-
Notifications
You must be signed in to change notification settings - Fork 147
Closed
Description
I'm currently using rfl 0.19, but the change notes in the recent versions didnt indicate anything about this behaviour would have changed.
I'm working on a Qt based project trying to reflect QString. So I wrote this based on the example in the docs:
template <>
struct Reflector<QString> {
using ReflType = std::wstring;
static QString to(const ReflType& v) noexcept {
return QString::fromStdWString(v);
}
static ReflType from(const QString& v) {
return { v.toStdWString() };
}
};This works fine for parsing/writing, but does not seem to work for the schema generation:
struct RflTest {
QString test_string;
};
auto a = RflTest{ "AAAAAH" };
auto json_a = rfl::json::write(a);
qDebug() << QString::fromStdString(json_a); // Output: "{\"test_string\":\"AAAAAH\"}"
auto b = rfl::json::read<RflTest>(json_a);
qDebug() << b.value().test_string; // Output: "AAAAAH"
auto schema = rfl::json::to_schema<RflTest>(); // breaks during compilation: "static_assert failed: 'Unsupported type'"
qDebug() << QString::fromStdString(schema);Is there an additional function that can be overwritten for the Reflector? Or is extending the schema beyond the default types not supported as of now?
Thank you for your work, this library is wildly impressive
liuzicheng1987
Metadata
Metadata
Assignees
Labels
No labels