* Adds an attribute * @param ff flow file record * @param key key * @param value value to add * @param size size of value * @return 0 or -1 based on whether the attributed existed previously (-1) or not (0) */
| 369 | * @return 0 or -1 based on whether the attributed existed previously (-1) or not (0) |
| 370 | */ |
| 371 | int8_t add_attribute(flow_file_record *ff, const char *key, void *value, size_t size) { |
| 372 | NULL_CHECK(-1, ff, key, value); |
| 373 | NULL_CHECK(-1, ff->attributes); |
| 374 | auto attribute_map = static_cast<AttributeMap*>(ff->attributes); |
| 375 | const auto& ret = attribute_map->insert(std::pair<std::string, std::string>(key, std::string(static_cast<char*>(value), size))); |
| 376 | return ret.second ? 0 : -1; |
| 377 | } |
| 378 | |
| 379 | /** |
| 380 | * Updates (or adds) an attribute |