[
https://issues.apache.org/jira/browse/MINIFICPP-638?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16652699#comment-16652699
]
ASF GitHub Bot commented on MINIFICPP-638:
------------------------------------------
Github user phrocker commented on a diff in the pull request:
https://github.com/apache/nifi-minifi-cpp/pull/417#discussion_r225492979
--- Diff: libminifi/src/capi/api.cpp ---
@@ -237,25 +239,58 @@ void update_attribute(flow_file_record *ff, char
*key, void *value, size_t size)
* @param caller_attribute caller supplied object in which we will copy
the data ptr
* @return 0 if successful, -1 if the key does not exist
*/
-uint8_t get_attribute(flow_file_record *ff, char *key, attribute
*caller_attribute) {
+uint8_t get_attribute(flow_file_record *ff, attribute *caller_attribute) {
+ if (ff == nullptr) {
+ return -1;
+ }
auto attribute_map = static_cast<string_map*>(ff->attributes);
- auto find = attribute_map->find(key);
+ if (!attribute_map) {
+ return -1;
+ }
+ auto find = attribute_map->find(caller_attribute->key);
if (find != attribute_map->end()) {
- caller_attribute->key = key;
caller_attribute->value =
static_cast<void*>(const_cast<char*>(find->second.data()));
caller_attribute->value_size = find->second.size();
return 0;
}
return -1;
}
+attribute_set *get_all_attributes(const flow_file_record* ff) {
+ if (ff == nullptr) {
+ return nullptr;
+ }
+ auto attribute_map = static_cast<string_map*>(ff->attributes);
+ if (!attribute_map || attribute_map->empty()) {
+ return nullptr;
+ }
+ attribute_set * attr_set = new attribute_set;
--- End diff --
Not sure all developers will pick up on const char in the attribute_set and
will instead be clouded by the fact that attribute set is returned as a new
object.
> C API: add unit tests
> ---------------------
>
> Key: MINIFICPP-638
> URL: https://issues.apache.org/jira/browse/MINIFICPP-638
> Project: NiFi MiNiFi C++
> Issue Type: Sub-task
> Reporter: Arpad Boda
> Assignee: Arpad Boda
> Priority: Minor
> Fix For: 0.6.0
>
>
> Add some C API unit tests.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)