pnoltes commented on code in PR #721: URL: https://github.com/apache/celix/pull/721#discussion_r1468916894
########## libs/utils/src/properties.c: ########## @@ -809,11 +910,518 @@ celix_properties_setVersion(celix_properties_t* props, const char* key, const ce return celix_properties_createAndSetEntry(props, key, &prototype); } -celix_status_t celix_properties_setVersionWithoutCopy(celix_properties_t* props, const char* key, celix_version_t* version) { +celix_status_t +celix_properties_assignVersion(celix_properties_t* properties, const char* key, celix_version_t* version) { + assert(version != NULL); celix_properties_entry_t prototype = {0}; prototype.valueType = CELIX_PROPERTIES_VALUE_TYPE_VERSION; prototype.typed.versionValue = version; - return celix_properties_createAndSetEntry(props, key, &prototype); + return celix_properties_createAndSetEntry(properties, key, &prototype); +} + +celix_status_t celix_properties_getAsLongArrayList(const celix_properties_t* properties, + const char* key, + const celix_array_list_t* defaultValue, + celix_array_list_t** list) { + const celix_properties_entry_t* entry = celix_properties_getEntry(properties, key); + if (entry != NULL && entry->valueType == CELIX_PROPERTIES_VALUE_TYPE_LONG_ARRAY) { + celix_array_list_t* copy = celix_arrayList_copy(entry->typed.arrayValue); + if (!copy) { + return CELIX_ENOMEM; + } + *list = copy; + return CELIX_SUCCESS; + } + if (entry != NULL && entry->valueType == CELIX_PROPERTIES_VALUE_TYPE_STRING) { + celix_status_t convertStatus = celix_utils_convertStringToLongArrayList(entry->value, defaultValue, list); + if (convertStatus == CELIX_ILLEGAL_ARGUMENT) { + // conversion failed, but no memory error so defaultValue is copied and set Review Comment: Correct. An other option could be to return the CELIX_ILLEGAL_ARGUMENT and let the user handle it. But does mean an additional backward incompatible update (the semantics of the properties `_getAs` functions changed). But I do think this make more sense, e.g with: ``` long port = celix_properties_getAsLong(props, "RSA_PORT", 8888); ``` an RSA_PORT not configured as a value parse as long is an configuration error. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@celix.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org