IndieGame/config/Table/Tools/Luban/Templates/cpp-sharedptr-bin/schema_cpp.sbn
DOBEST\zhaoyingjie f242607587 初始化工程
2024-10-11 10:12:15 +08:00

51 lines
1.3 KiB
Plaintext

#include "{{__schema_header_file}}"
{{namespace_with_grace_begin __top_module}}
{{~for bean in __beans~}}
bool {{make_cpp_name bean.full_name}}::deserialize(::luban::ByteBuf& _buf)
{
{{~if bean.parent_def_type~}}
if (!{{make_cpp_name bean.parent_def_type.full_name}}::deserialize(_buf))
{
return false;
}
{{~end~}}
{{~ for field in bean.export_fields ~}}
{{deserialize '_buf' (format_field_name __code_style field.name) field.ctype}}
{{~end~}}
return true;
}
bool {{make_cpp_name bean.full_name}}::deserialize{{bean.name}}(::luban::ByteBuf& _buf, ::luban::SharedPtr<{{make_cpp_name bean.full_name}}>& _out)
{
{{~if bean.is_abstract_type~}}
int32_t id;
if (!_buf.readInt(id)) return false;
switch (id)
{
{{~for child in bean.hierarchy_not_abstract_children~}}
case {{make_type_cpp_name child}}::__ID__: { _out.reset(LUBAN_NEW({{make_type_cpp_name child}})); if (_out->deserialize(_buf)) { return true; } else { _out.reset(); return false;} }
{{~end~}}
default: { _out = nullptr; return false;}
}
{{~else~}}
_out.reset(LUBAN_NEW({{make_type_cpp_name bean}}));
if (_out->deserialize(_buf))
{
return true;
}
else
{
_out.reset();
return false;
}
{{~end~}}
}
{{~end~}}
{{namespace_with_grace_end __top_module}}