-
大小: 6.18MB文件类型: .zip金币: 1下载: 0 次发布日期: 2023-10-12
- 语言: 其他
- 标签:
资源简介
stm32移植protobuf(nanopb-0.3.8-windows-x86)操作说明
代码片段和文件信息
/* pb_common.c: Common support functions for pb_encode.c and pb_decode.c.
*
* 2014 Petteri Aimonen
*/
#include “pb_common.h“
bool pb_field_iter_begin(pb_field_iter_t *iter const pb_field_t *fields void *dest_struct)
{
iter->start = fields;
iter->pos = fields;
iter->required_field_index = 0;
iter->dest_struct = dest_struct;
iter->pData = (char*)dest_struct + iter->pos->data_offset;
iter->pSize = (char*)iter->pData + iter->pos->size_offset;
return (iter->pos->tag != 0);
}
bool pb_field_iter_next(pb_field_iter_t *iter)
{
const pb_field_t *prev_field = iter->pos;
if (prev_field->tag == 0)
{
/* Handle empty message types where the first field is already the terminator.
* In other cases the iter->pos never points to the terminator. */
return false;
}
iter->pos++;
if (iter->pos->tag == 0)
{
/* Wrapped back to beginning reinitialize */
(void)pb_field_iter_begin(iter iter->start iter->dest_struct);
return false;
}
else
{
/* Increment the pointers based on previous field size */
size_t prev_size = prev_field->data_size;
if (PB_HTYPE(prev_field->type) == PB_HTYPE_ONEOF &&
PB_HTYPE(iter->pos->type) == PB_HTYPE_ONEOF &&
iter->pos->data_offset == PB_SIZE_MAX)
{
/* Don‘t advance pointers inside unions */
return true;
}
else if (PB_ATYPE(prev_field->type) == PB_ATYPE_STATIC &&
PB_HTYPE(prev_field->type) == PB_HTYPE_REPEATED)
{
/* In static arrays the data_size tells the size of a single entry and
* array_size is the number of entries */
prev_size *= prev_field->array_size;
}
else if (PB_ATYPE(prev_field->type) == PB_ATYPE_POINTER)
{
/* Pointer fields always have a constant size in the main structure.
* The data_size only applies to the dynamically allocated area. */
prev_size = sizeof(void*);
}
if (PB_HTYPE(prev_field->type) == PB_HTYPE_REQUIRED)
{
/* Count the required fields in order to check their presence in the
* decoder. */
iter->required_field_index++;
}
iter->pData = (char*)iter->pData + prev_size + iter->pos->data_offset;
iter->pSize = (char*)iter->pData + iter->pos->size_offset;
return true;
}
}
bool pb_field_iter_find(pb_field_iter_t *iter uint32_t tag)
{
const pb_field_t *start = iter->pos;
do {
if (iter->pos->tag == tag &&
PB_LTYPE(iter->pos->type) != PB_LTYPE_EXTENSION)
{
/* Found the wanted field */
return true;
}
(void)pb_field_iter_next(iter);
} while (iter->pos != start);
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-01-19 10:15 protobuf\
目录 0 2018-01-19 10:13 protobuf\nanopb-0.3.8-windows-x86\
文件 521 2017-03-06 00:28 protobuf\nanopb-0.3.8-windows-x86\.gitignore
文件 1520 2017-03-06 00:28 protobuf\nanopb-0.3.8-windows-x86\.travis.yml
文件 1199 2017-03-06 00:28 protobuf\nanopb-0.3.8-windows-x86\AUTHORS
文件 361 2017-03-06 00:28 protobuf\nanopb-0.3.8-windows-x86\BUILD
文件 11923 2017-03-06 00:28 protobuf\nanopb-0.3.8-windows-x86\CHANGELOG.txt
文件 3098 2017-03-06 00:28 protobuf\nanopb-0.3.8-windows-x86\CMakeLists.txt
文件 1259 2017-03-06 00:28 protobuf\nanopb-0.3.8-windows-x86\CONTRIBUTING.md
文件 918 2017-03-06 00:28 protobuf\nanopb-0.3.8-windows-x86\LICENSE.txt
文件 3048 2017-03-06 00:28 protobuf\nanopb-0.3.8-windows-x86\README.md
目录 0 2017-04-25 09:01 protobuf\nanopb-0.3.8-windows-x86\docs\
文件 302 2017-03-06 00:28 protobuf\nanopb-0.3.8-windows-x86\docs\Makefile
文件 16812 2017-03-06 00:28 protobuf\nanopb-0.3.8-windows-x86\docs\concepts.rst
文件 117174 2017-03-06 00:28 protobuf\nanopb-0.3.8-windows-x86\docs\generator_flow.svg
文件 5512 2017-03-06 00:28 protobuf\nanopb-0.3.8-windows-x86\docs\index.rst
目录 0 2017-04-25 09:01 protobuf\nanopb-0.3.8-windows-x86\docs\logo\
文件 14973 2017-03-06 00:28 protobuf\nanopb-0.3.8-windows-x86\docs\logo\logo.png
文件 105375 2017-03-06 00:28 protobuf\nanopb-0.3.8-windows-x86\docs\logo\logo.svg
文件 854 2017-03-06 00:28 protobuf\nanopb-0.3.8-windows-x86\docs\logo\logo16px.png
文件 2577 2017-03-06 00:28 protobuf\nanopb-0.3.8-windows-x86\docs\logo\logo48px.png
文件 3836 2017-03-06 00:28 protobuf\nanopb-0.3.8-windows-x86\docs\lsr.css
文件 361 2017-03-06 00:28 protobuf\nanopb-0.3.8-windows-x86\docs\menu.rst
文件 11827 2017-03-06 00:28 protobuf\nanopb-0.3.8-windows-x86\docs\migration.rst
文件 35845 2017-03-06 00:28 protobuf\nanopb-0.3.8-windows-x86\docs\reference.rst
文件 3938 2017-03-06 00:28 protobuf\nanopb-0.3.8-windows-x86\docs\security.rst
目录 0 2017-04-25 09:01 protobuf\nanopb-0.3.8-windows-x86\examples\
目录 0 2017-04-25 09:01 protobuf\nanopb-0.3.8-windows-x86\examples\cmake_simple\
文件 614 2017-03-06 00:28 protobuf\nanopb-0.3.8-windows-x86\examples\cmake_simple\CMakeLists.txt
文件 551 2017-03-06 00:28 protobuf\nanopb-0.3.8-windows-x86\examples\cmake_simple\README.txt
文件 2284 2017-03-06 00:28 protobuf\nanopb-0.3.8-windows-x86\examples\cmake_simple\simple.c
............此处省略504个文件信息
评论
共有 条评论