Problem/Opportunity
Currently there is no way to iterate list structures with the kvp part of UT-Control.
In certain scenarios, it would be highly usable, maybe even necessary to be able to do so in order to dynamically add things to test for without needing to rewrite/recompile any code.
Proposed Solution
Given something like:
myProfile:
- name: firstElement
description: |
Some element in a list that we would like to iterate
- name: secondElement
description: |
An additional element
...
We wish to be able to iterate though the elements in the list: myProfile one at a time, executing some function for each, halting if the execution returns false.
The suggestion is a couple of functions like:
// A type of the iterator
typedef void ut_kvp_iterator_t;
// A function to create an iterator
ut_kvp_iterator *ut_kvp_get_iterator(ut_kvp_instance_t *pInstance, char *pPath);
// A function that handles the iteration, calling the provided function for each element, halting if any call returns false
void ut_kvp_iter_iterate(ut_kvp_iterator *pIterator, bool (*callback)(ut_kvp_instance_t *pInstance, void *userData));
The reason for passing a ut_kvp_instance_t to the callback, is that it will allow the callback to make use of all existing functions for retrieving data. libfyaml has support for getting a node by path, creating a document struct, and setting it's root to be a specific node.
Acceptance Criteria (Optional)
No response
Additional Notes (Optional)
No response
Problem/Opportunity
Currently there is no way to iterate list structures with the kvp part of UT-Control.
In certain scenarios, it would be highly usable, maybe even necessary to be able to do so in order to dynamically add things to test for without needing to rewrite/recompile any code.
Proposed Solution
Given something like:
We wish to be able to iterate though the elements in the list:
myProfileone at a time, executing some function for each, halting if the execution returns false.The suggestion is a couple of functions like:
The reason for passing a
ut_kvp_instance_tto the callback, is that it will allow the callback to make use of all existing functions for retrieving data. libfyaml has support for getting a node by path, creating a document struct, and setting it's root to be a specific node.Acceptance Criteria (Optional)
No response
Additional Notes (Optional)
No response