diff --git a/include/cowl_manager.h b/include/cowl_manager.h index 723b35c..de56681 100644 --- a/include/cowl_manager.h +++ b/include/cowl_manager.h @@ -172,6 +172,7 @@ CowlOntology *cowl_manager_new_ontology(CowlManager *manager); * @note You can pass NULL as the IRI and version, in which case the function returns * a new anonymous ontology. */ +COWL_DEPRECATED(Use @func{cowl_manager_retrieve_ontology()} or @func{cowl_manager_new_ontology()}.) COWL_API COWL_RETAINED CowlOntology *cowl_manager_get_ontology(CowlManager *manager, CowlIRI *iri, CowlIRI *version); @@ -183,6 +184,9 @@ CowlOntology *cowl_manager_get_ontology(CowlManager *manager, CowlIRI *iri, Cowl * @param iri The ontology IRI. * @param version The ontology version. * @return Ontology with the specified IRI and version, or NULL if it does not exist. + * + * @note Passing NULL as the version retrieves the ontology with the specified IRI + * and either NULL version (if it exists) or any other version. */ COWL_API CowlOntology *cowl_manager_retrieve_ontology(CowlManager *manager, CowlIRI *iri, CowlIRI *version); diff --git a/src/cowl_manager.c b/src/cowl_manager.c index 6551bfb..287396e 100644 --- a/src/cowl_manager.c +++ b/src/cowl_manager.c @@ -252,13 +252,13 @@ CowlOntology *cowl_manager_get_ontology(CowlManager *manager, CowlIRI *iri, Cowl } CowlOntology *cowl_manager_retrieve_ontology(CowlManager *manager, CowlIRI *iri, CowlIRI *version) { + CowlOntology *match = NULL; uvec_foreach (CowlObjectPtr, &manager->ontos, onto) { - if (cowl_ontology_get_iri(*onto.item) == iri && - cowl_ontology_get_version(*onto.item) == version) { - return *onto.item; - } + if (cowl_ontology_get_iri(*onto.item) != iri) continue; + match = *onto.item; + if (cowl_ontology_get_version(*onto.item) == version) break; } - return NULL; + return match; } cowl_ret cowl_manager_add_ontology(CowlManager *manager, CowlOntology *onto) {