[Yunq] Move repeated field parsing to the yunq library.
This commit is contained in:
parent
9e9ef21a3d
commit
30b220b2fb
4 changed files with 31 additions and 27 deletions
|
|
@ -53,20 +53,15 @@ glcr::Status {{message.name}}::ParseFromBytesInternal(const glcr::ByteBuffer& by
|
|||
|
||||
{%- for field in message.fields %}
|
||||
// Parse {{field.name}}.
|
||||
{%- if not field.repeated %}
|
||||
{%- if field.type != Type.CAPABILITY %}
|
||||
ASSIGN_OR_RETURN({{field.name}}_, view.ReadField<{{field.cpp_type()}}>({{loop.index0}}));
|
||||
{%- endif %}
|
||||
{%- else %}
|
||||
auto {{field.name}}_pointer = bytes.At<ExtPointer>(offset + header_size + (8 * {{loop.index0}}));
|
||||
|
||||
{{field.name}}_.Resize({{field.name}}_pointer.length / sizeof({{field.cpp_type()}}));
|
||||
for (uint64_t i = offset + {{field.name}}_pointer.offset;
|
||||
i < offset + {{field.name}}_pointer.offset + {{field.name}}_pointer.length;
|
||||
i += sizeof({{field.cpp_type()}})) {
|
||||
{{field.name}}_.PushBack(bytes.At<{{field.cpp_type()}}>(i));
|
||||
}
|
||||
{%- if not field.repeated %}
|
||||
ASSIGN_OR_RETURN({{field.name}}_, view.ReadField<{{field.cpp_type()}}>({{loop.index0}}));
|
||||
{%- else %}
|
||||
ASSIGN_OR_RETURN({{field.name}}_, view.ReadRepeated<{{field.cpp_type()}}>({{loop.index0}}));
|
||||
{% endif %}
|
||||
|
||||
{%- endif %}
|
||||
{%- endfor %}
|
||||
|
||||
return glcr::Status::Ok();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue