Add support for poll data (anyOf and oneOf)

master
teknomunk 8 months ago
parent 70380d7600
commit 4257ba4541

@ -201,6 +201,20 @@ struct ap_object* ap_object_dup( struct ap_object* act )
array_append( &new_act->ordered_items, sizeof(item), &item );
}
// Question fields
for( int i = 0; i < act->one_of.count; ++i ) {
struct ap_object_ptr_or_ref item = ap_object_ptr_or_ref_dup(
act->one_of.items[i]
);
array_append( &new_act->one_of, sizeof(item), &item );
}
for( int i = 0; i < act->any_of.count; ++i ) {
struct ap_object_ptr_or_ref item = ap_object_ptr_or_ref_dup(
act->any_of.items[i]
);
array_append( &new_act->any_of, sizeof(item), &item );
}
return new_act;
}
void ap_public_key_free( struct ap_public_key* pk );
@ -313,6 +327,16 @@ void ap_object_free_composite( struct ap_object* act )
}
free( act->ordered_items.items );
// Question fields
for( int i = 0; i < act->one_of.count; ++i ) {
ap_object_ptr_or_ref_free_composite( &act->one_of.items[i] );
}
free( act->one_of.items );
for( int i = 0; i < act->any_of.count; ++i ) {
ap_object_ptr_or_ref_free_composite( &act->any_of.items[i] );
}
free( act->any_of.items );
}
void ap_object_ptr_or_ref_free( struct ap_object_ptr_or_ref* o )
{

@ -280,6 +280,17 @@ struct ap_object
int count;
} ordered_items;
// Question fields
struct {
struct ap_object_ptr_or_ref* items;
int count;
} one_of;
struct {
struct ap_object_ptr_or_ref* items;
int count;
} any_of;
time_t closed;
struct json_value extra;
};

@ -345,6 +345,28 @@ struct json_object_field ap_object_layout[] = {
.array_item_type = &ap_object_ptr_or_ref_type,
},
// Question fields
{
.key = "oneOf",
.offset = offsetof( OBJ_TYPE, one_of ),
.allow_drop_empty = true,
.type = &json_field_array_of,
.array_item_type = &ap_object_ptr_or_ref_type,
},
{
.key = "anyOf",
.offset = offsetof( OBJ_TYPE, any_of ),
.allow_drop_empty = true,
.type = &json_field_array_of,
.array_item_type = &ap_object_ptr_or_ref_type,
},
{
.key = "closed",
.offset = offsetof( OBJ_TYPE, closed ),
.allow_drop_empty = true,
.type = &json_field_date_time,
},
// Other
JSON_FIELD_STRING(state,false),
{

Loading…
Cancel
Save