Prevent generating pull method for non-default constructable classes

This commit is contained in:
Martchus 2017-12-24 01:07:52 +01:00
parent 0bb06d5190
commit bae7cf3414
2 changed files with 9 additions and 2 deletions

View File

@ -34,9 +34,11 @@ The following table shows the mapping of supported C++ types to supported JSON t
* For the same reason `const char *` strings are only supported for serialization.
* Enums are (de)serialized as their underlying integer value. When deserializing, it is currently *not* checked
whether the present integer value is a valid enumeration item.
* For deserialization, iteratables must provide an `emplace_back` method. So deserialization of eg. `std::forward_list`
is currently not supported.
* The JSON type for smart pointer depends on the type the pointer refers to. It can also be `null`.
* For deserialization
* iteratables must provide an `emplace_back` method. So deserialization of eg. `std::forward_list`
is currently not supported.
* custom types must provide a default constructor.
* For custom (de)serialization, see the section below.
## Usage

View File

@ -205,6 +205,11 @@ void JsonSerializationCodeGenerator::generate(ostream &os) const
}
os << "}\n";
// skip printing the pull method for classes without default constructor because deserializing those is currently not supported
if (!relevantClass.record->hasDefaultConstructor()) {
continue;
}
// print pull method
os << "template <> " << visibility << " void pull<::" << relevantClass.qualifiedName << ">(::" << relevantClass.qualifiedName
<< " &reflectable, const ::RAPIDJSON_NAMESPACE::GenericValue<::RAPIDJSON_NAMESPACE::UTF8<char>>::ConstObject &value, "