aboutsummaryrefslogtreecommitdiffstats
path: root/pb_encode.c
diff options
context:
space:
mode:
authorPetteri Aimonen <jpa@git.mail.kapsi.fi>2015-01-04 19:39:37 +0200
committerPetteri Aimonen <jpa@git.mail.kapsi.fi>2015-01-04 19:39:37 +0200
commit7713d43bc3d448358a04393c4e44dd12a768bdea (patch)
tree140573b1d78947739e5f46721d681a580a4d3030 /pb_encode.c
parenta0f0440394ac3b38105dfad09366f95011c5d8d3 (diff)
Implement support for oneofs (C unions).
Basic test included, should probably add an oneof to the AllTypes test also. Update issue 131 Status: Started
Diffstat (limited to 'pb_encode.c')
-rw-r--r--pb_encode.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/pb_encode.c b/pb_encode.c
index cef98861..cc372b8f 100644
--- a/pb_encode.c
+++ b/pb_encode.c
@@ -250,6 +250,17 @@ static bool checkreturn encode_basic_field(pb_ostream_t *stream,
return false;
break;
+ case PB_HTYPE_ONEOF:
+ if (*(const pb_size_t*)pSize == field->tag)
+ {
+ if (!pb_encode_tag_for_field(stream, field))
+ return false;
+
+ if (!func(stream, field, pData))
+ return false;
+ }
+ break;
+
default:
PB_RETURN_ERROR(stream, "invalid field type");
}