Add TlStorerToString::store_object_field method.
This commit is contained in:
parent
a4592bd522
commit
5e43075d3b
@ -404,8 +404,8 @@ std::string TD_TL_writer_cpp::gen_type_store(const std::string &field_name, cons
|
||||
return gen_vector_store(field_name, child, vars, storer_type);
|
||||
} else {
|
||||
assert(tree_type->children.empty());
|
||||
return "if (" + field_name + " == nullptr) { s.store_field(\"" + get_pretty_field_name(field_name) +
|
||||
"\", \"null\"); } else { " + field_name + "->store(s, \"" + get_pretty_field_name(field_name) + "\"); }";
|
||||
return "s.store_object_field(\"" + get_pretty_field_name(field_name) + "\", static_cast<const BaseObject *>(" +
|
||||
field_name + ".get()));";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -322,8 +322,8 @@ std::string TD_TL_writer_jni_cpp::gen_type_store(const std::string &field_name,
|
||||
res = gen_vector_store(field_name, child, vars, storer_type);
|
||||
} else {
|
||||
if (storer_type == 1) {
|
||||
res = "if (" + field_name + " == nullptr) { s.store_field(\"" + get_pretty_field_name(field_name) +
|
||||
"\", \"null\"); } else { " + field_name + "->store(s, \"" + get_pretty_field_name(field_name) + "\"); }";
|
||||
res = "s.store_object_field(\"" + get_pretty_field_name(field_name) + "\", static_cast<const BaseObject *>(" +
|
||||
field_name + ".get()));";
|
||||
} else {
|
||||
res = "if (" + field_name + " != nullptr) { jobject next; " + field_name +
|
||||
"->store(env, next); if (next) { env->SetObjectField(s, " + field_name +
|
||||
|
@ -257,6 +257,15 @@ class TlStorerToString {
|
||||
store_field_end();
|
||||
}
|
||||
|
||||
template <class ObjectT>
|
||||
void store_object_field(const char *name, const ObjectT *value) {
|
||||
if (value == nullptr) {
|
||||
store_field(name, "null");
|
||||
} else {
|
||||
value->store(*this, name);
|
||||
}
|
||||
}
|
||||
|
||||
void store_field(const char *name, const UInt128 &value) {
|
||||
store_field_begin(name);
|
||||
store_binary(as_slice(value));
|
||||
|
Loading…
x
Reference in New Issue
Block a user