This is an automated email from the ASF dual-hosted git repository.
pnoltes pushed a commit to branch feature/cap_req_model_lib
in repository https://gitbox.apache.org/repos/asf/celix.git
The following commit(s) were added to refs/heads/feature/cap_req_model_lib by
this push:
new 6b0a12cb Add doxygen for rcm functions
6b0a12cb is described below
commit 6b0a12cbe4d262b41c07b32e2d17cf6006929081
Author: Pepijn Noltes <[email protected]>
AuthorDate: Sun Apr 9 19:12:37 2023 +0200
Add doxygen for rcm functions
---
CMakeLists.txt | 2 +-
.../src/RequirementCapabilityModelTestSuite.cc | 20 ++---
...ntCapabilityModelWithErrorInjectionTestSuite.cc | 12 +--
libs/rcm/include/celix_capability.h | 84 ++++++++++++++++++++
libs/rcm/include/celix_requirement.h | 90 ++++++++++++++++++++++
libs/rcm/include/celix_resource.h | 54 +++++++++++--
libs/rcm/src/celix_resource.c | 37 +++------
libs/utils/include/celix_errno.h | 8 +-
8 files changed, 258 insertions(+), 49 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a1fea218..f75072df 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -48,7 +48,7 @@ endif ()
if (NOT TARGET CURL::libcurl)
#Note more recent curl will create CURL::libcurl target
message("Note CURL::libcurl target not created by find_package(CURL).
Creating CURL::libcurl Target.")
- add_library(CURL::libcurl SHARED IMPORTED
libs/rcm/include/celix_requirement.h libs/rcm/include/celix_capability.h)
+ add_library(CURL::libcurl SHARED IMPORTED)
set_target_properties(CURL::libcurl PROPERTIES
IMPORTED_LOCATION "${CURL_LIBRARIES}"
INTERFACE_INCLUDE_DIRECTORIES "${CURL_INCLUDE_DIRS}"
diff --git a/libs/rcm/gtest/src/RequirementCapabilityModelTestSuite.cc
b/libs/rcm/gtest/src/RequirementCapabilityModelTestSuite.cc
index 216b6cbc..837c21ac 100644
--- a/libs/rcm/gtest/src/RequirementCapabilityModelTestSuite.cc
+++ b/libs/rcm/gtest/src/RequirementCapabilityModelTestSuite.cc
@@ -217,30 +217,30 @@ TEST_F(RequirementCapabilityModelTestSuite, TestResource)
{
EXPECT_EQ(0, celix_arrayList_size(celix_resource_getCapabilities(res,
nullptr)));
celix_requirement_t* req = celix_requirement_create(res, "test-namespace",
"(&(capability.attribute1=foo)(capability.attribute2=bar))");
- EXPECT_TRUE(celix_resource_addRequirement(res, req));
+ EXPECT_EQ(CELIX_SUCCESS, celix_resource_addRequirement(res, req));
EXPECT_EQ(res, celix_requirement_getResource(req));
EXPECT_EQ(1, celix_arrayList_size(celix_resource_getRequirements(res,
nullptr)));
req = celix_requirement_create(res, "test-namespace2", nullptr);
- EXPECT_TRUE(celix_resource_addRequirement(res, req));
+ EXPECT_EQ(CELIX_SUCCESS, celix_resource_addRequirement(res, req));
EXPECT_EQ(2, celix_arrayList_size(celix_resource_getRequirements(res,
nullptr)));
celix_capability_t *cap = celix_capability_create(res, "test-namespace");
- EXPECT_TRUE(celix_resource_addCapability(res, cap));
+ EXPECT_EQ(CELIX_SUCCESS, celix_resource_addCapability(res, cap));
EXPECT_EQ(res, celix_capability_getResource(cap));
EXPECT_EQ(1, celix_arrayList_size(celix_resource_getCapabilities(res,
nullptr)));
req = celix_requirement_create(res2, "test-namespace2", nullptr);
- EXPECT_TRUE(celix_resource_addRequirement(res2, req));
+ EXPECT_EQ(CELIX_SUCCESS, celix_resource_addRequirement(res2, req));
req = celix_requirement_create(res2, "test-namespace",
"(&(capability.attribute1=foo)(capability.attribute2=bar))");
- EXPECT_TRUE(celix_resource_addRequirement(res2, req));
+ EXPECT_EQ(CELIX_SUCCESS, celix_resource_addRequirement(res2, req));
cap = celix_capability_create(res2, "test-namespace");
- EXPECT_TRUE(celix_resource_addCapability(res2, cap));
+ EXPECT_EQ(CELIX_SUCCESS, celix_resource_addCapability(res2, cap));
//test get capabilities/requirements by namespace
req = celix_requirement_create(res, "test-namespace2", nullptr);
cap = celix_capability_create(res, "test-namespace2");
- EXPECT_TRUE(celix_resource_addRequirement(res, req));
- EXPECT_TRUE(celix_resource_addCapability(res, cap));
+ EXPECT_EQ(CELIX_SUCCESS, celix_resource_addRequirement(res, req));
+ EXPECT_EQ(CELIX_SUCCESS, celix_resource_addCapability(res, cap));
EXPECT_EQ(3, celix_arrayList_size(celix_resource_getRequirements(res,
nullptr)));
EXPECT_EQ(2, celix_arrayList_size(celix_resource_getCapabilities(res,
nullptr)));
const celix_array_list_t* caps = celix_resource_getCapabilities(res,
"test-namespace");
@@ -260,8 +260,8 @@ TEST_F(RequirementCapabilityModelTestSuite,
TestCapabilityAndRequirementWithWron
celix_requirement_t* req = celix_requirement_create(nullptr,
"test-namespace", nullptr);
celix_rcmErr_resetErrors();
- EXPECT_FALSE(celix_resource_addCapability(res, cap));
- EXPECT_FALSE(celix_resource_addRequirement(res, req));
+ EXPECT_EQ(CELIX_ILLEGAL_ARGUMENT, celix_resource_addCapability(res, cap));
+ EXPECT_EQ(CELIX_ILLEGAL_ARGUMENT, celix_resource_addRequirement(res, req));
EXPECT_EQ(2, celix_rcmErr_getErrorCount());
celix_requirement_destroy(req);
celix_capability_destroy(cap);
diff --git
a/libs/rcm/gtest/src/RequirementCapabilityModelWithErrorInjectionTestSuite.cc
b/libs/rcm/gtest/src/RequirementCapabilityModelWithErrorInjectionTestSuite.cc
index 1718e15c..21b52485 100644
---
a/libs/rcm/gtest/src/RequirementCapabilityModelWithErrorInjectionTestSuite.cc
+++
b/libs/rcm/gtest/src/RequirementCapabilityModelWithErrorInjectionTestSuite.cc
@@ -98,32 +98,32 @@
TEST_F(RequirementCapabilityModelWithErrorInjectionTestSuite, TestResourceErrorH
//inject error on first celix_arrayList_create call from
celix_resource_addCapability
celix_ei_expect_celix_arrayList_create((void*)celix_resource_addCapability, 0,
nullptr);
- EXPECT_FALSE(celix_resource_addCapability(res, cap));
+ EXPECT_EQ(CELIX_ENOMEM, celix_resource_addCapability(res, cap));
EXPECT_EQ(3, celix_rcmErr_getErrorCount());
//inject error on first celix_arrayList_add call from
celix_resource_addCapability
celix_ei_expect_celix_arrayList_add((void*)celix_resource_addCapability,
0, CELIX_ENOMEM);
- EXPECT_FALSE(celix_resource_addCapability(res, cap));
+ EXPECT_EQ(CELIX_ENOMEM, celix_resource_addCapability(res, cap));
EXPECT_EQ(4, celix_rcmErr_getErrorCount());
//inject error on second celix_arrayList_add call from
celix_resource_addCapability
celix_ei_expect_celix_arrayList_add((void*)celix_resource_addCapability,
0, CELIX_ENOMEM, 2);
- EXPECT_FALSE(celix_resource_addCapability(res, cap));
+ EXPECT_EQ(CELIX_ENOMEM, celix_resource_addCapability(res, cap));
EXPECT_EQ(5, celix_rcmErr_getErrorCount());
//inject error on first celix_arrayList_create call from
celix_resource_addRequirement
celix_ei_expect_celix_arrayList_create((void*)celix_resource_addRequirement, 0,
nullptr);
- EXPECT_FALSE(celix_resource_addRequirement(res, req));
+ EXPECT_EQ(CELIX_ENOMEM, celix_resource_addRequirement(res, req));
EXPECT_EQ(6, celix_rcmErr_getErrorCount());
//inject error on first celix_arrayList_add call from
celix_resource_addRequirement
celix_ei_expect_celix_arrayList_add((void*)celix_resource_addRequirement,
0, CELIX_ENOMEM);
- EXPECT_FALSE(celix_resource_addRequirement(res, req));
+ EXPECT_EQ(CELIX_ENOMEM, celix_resource_addRequirement(res, req));
EXPECT_EQ(7, celix_rcmErr_getErrorCount());
//inject error on second celix_arrayList_add call from
celix_resource_addRequirement
celix_ei_expect_celix_arrayList_add((void*)celix_resource_addRequirement,
0, CELIX_ENOMEM, 2);
- EXPECT_FALSE(celix_resource_addRequirement(res, req));
+ EXPECT_EQ(CELIX_ENOMEM, celix_resource_addRequirement(res, req));
EXPECT_EQ(8, celix_rcmErr_getErrorCount());
celix_capability_destroy(cap);
diff --git a/libs/rcm/include/celix_capability.h
b/libs/rcm/include/celix_capability.h
index 06ec7b41..4eab1f23 100644
--- a/libs/rcm/include/celix_capability.h
+++ b/libs/rcm/include/celix_capability.h
@@ -36,34 +36,118 @@ extern "C" {
* @thread_safety none
*/
+/**
+ * @brief Creates a new capability.
+ * @param[in] resource The resource which contains the capability. Can be NULL.
+ * @param[in] ns The namespace of the capability.
+ * @return The new capability or NULL if an error occurred.
+ */
celix_capability_t* celix_capability_create(
const celix_resource_t* resource,
const char* ns);
+/**
+ * @brief Destroys the capability.
+ * @param[in] capability The capability to destroy. Can be NULL.
+ */
void celix_capability_destroy(celix_capability_t* capability);
+/**
+ * @brief Check if 2 capabilities are equal.
+ */
bool celix_capability_equals(const celix_capability_t* cap1, const
celix_capability_t* cap2);
+/**
+ * @brief Returns the hash code of the capability.
+ */
unsigned int celix_capability_hashCode(const celix_capability_t* cap);
+/**
+ * @brief Returns the resource which contains the capability.
+ * @param[in] cap The capability.
+ * @return The resource or NULL if no resource is set.
+ */
const celix_resource_t* celix_capability_getResource(const celix_capability_t*
cap);
+/**
+ * @brief Returns the namespace of the capability.
+ * @param[in] cap The capability.
+ * @return The namespace of the capability.
+ */
const char* celix_capability_getNamespace(const celix_capability_t* cap);
+/**
+ * @brief Returns the attributes of the capability.
+ * @param[in] cap The capability.
+ * @return The attributes of the capability. Will be an empty properties if no
attributes are set.
+ */
const celix_properties_t* celix_capability_getAttributes(const
celix_capability_t* cap);
+/**
+ * @brief Returns the directives of the capability.
+ * @param[in] cap The capability.
+ * @return The directives of the capability. Will be an empty properties if no
directives are set.
+ */
const celix_properties_t* celix_capability_getDirectives(const
celix_capability_t* cap);
+/**
+ * @brief Returns the value of the attribute with the given key.
+ * @param[in] cap The capability.
+ * @param[in] key The key of the attribute.
+ * @return The value of the attribute or NULL if the attribute is not set.
+ */
const char* celix_capability_getAttribute(const celix_capability_t* cap, const
char* key);
+/**
+ * @brief Returns the value of the directive with the given key.
+ * @param[in] cap The capability.
+ * @param[in] key The key of the directive.
+ * @return The value of the directive or NULL if the directive is not set.
+ */
const char* celix_capability_getDirective(const celix_capability_t* cap, const
char* key);
+/**
+ * @brief Add a new attribute to the capability.
+ *
+ * Note replaces an existing attribute is the key is already set.
+ *
+ * @param[in] cap The capability.
+ * @param[in] key The key of the attribute.
+ * @param[in] value The value of the attribute.
+ */
void celix_capability_addAttribute(celix_capability_t* cap, const char* key,
const char* value);
+/**
+ * @brief Add a new attributes to the capability.
+ *
+ * Note replaces existing attributes is some of the provided keys are already
set.
+ *
+ * @param[in] cap The capability.
+ * @param[in] attributes The attributes to add.
+ * Note the attributes are copied, so the caller is
still owner of the properties.
+ */
void celix_capability_addAttributes(celix_capability_t* cap, const
celix_properties_t* attributes);
+/**
+ * @brief Add a new directive to the capability.
+ *
+ * Note replaces an existing directive is the key is already set.
+ *
+ * @param[in] cap The capability.
+ * @param[in] key The key of the directive.
+ * @param[in] value The value of the directive.
+ */
void celix_capability_addDirective(celix_capability_t* cap, const char* key,
const char* value);
+/**
+ * @brief Add a new directives to the capability.
+ *
+ * Note replaces existing directives is some of the provided keys are already
set.
+ *
+ * @param[in] cap The capability.
+ * @param[in] directives The directives to add.
+ * Note the directives are copied, so the caller is
still owner of the properties.
+ */
void celix_capability_addDirectives(celix_capability_t* cap, const
celix_properties_t* directives);
#ifdef __cplusplus
diff --git a/libs/rcm/include/celix_requirement.h
b/libs/rcm/include/celix_requirement.h
index 6c463bbf..5a59c518 100644
--- a/libs/rcm/include/celix_requirement.h
+++ b/libs/rcm/include/celix_requirement.h
@@ -40,38 +40,128 @@ extern "C" {
* @thread_safety none
*/
+/**
+ * @brief Creates a new requirement.
+ * @param[in] resource The resource which contains the requirement. Can be
NULL.
+ * @param[in] ns The namespace of the requirement.
+ * @param[in] filter The filter of the requirement. Can be NULL.
+ * @return The new requirement or NULL if an error occurred.
+ */
celix_requirement_t* celix_requirement_create(
celix_resource_t* resource,
const char* ns,
const char* filter);
+/**
+ * @brief Destroys the requirement.
+ * @param[in] requirement The requirement to destroy. Can be NULL.
+ */
void celix_requirement_destroy(celix_requirement_t* requirement);
+/**
+ * @brief Check if 2 requirements are equal.
+ */
bool celix_requirement_equals(const celix_requirement_t* req1, const
celix_requirement_t* req2);
+/**
+ * @brief Returns the hash code of the requirement.
+ */
unsigned int celix_requirement_hashCode(const celix_requirement_t* req);
+/**
+ * @brief Returns the resource which contains the requirement.
+ * @param[in] req The requirement.
+ * @return The resource which contains the requirement or NULL if the
requirement is not part of a resource.
+ */
const celix_resource_t* celix_requirement_getResource(const
celix_requirement_t* req);
+/**
+ * @brief Returns the namespace of the requirement.
+ * @param[in] req The requirement.
+ * @return The namespace of the requirement.
+ */
const char* celix_requirement_getNamespace(const celix_requirement_t* req);
+/**
+ * @brief Returns the filter of the requirement.
+ * @param[in] req The requirement.
+ * @return The filter of the requirement.
+ */
const char* celix_requirement_getFilter(const celix_requirement_t* req);
+/**
+ * @brief Returns the directives of the requirement.
+ * @param[in] req The requirement.
+ * @return The directives of the requirement. Will be an empty properties if
no directives are set.
+ */
const celix_properties_t* celix_requirement_getDirectives(const
celix_requirement_t* req);
+/**
+ * @brief Returns the value of the directive with the given key.
+ * @param[in] req The requirement.
+ * @param[in] key The key of the directive.
+ * @return The value of the directive or NULL if the directive is not set.
+ */
const char* celix_requirement_getDirective(const celix_requirement_t* req,
const char* key);
+/**
+ * @brief Returns the attributes of the requirement.
+ * @param[in] req The requirement.
+ * @return The attributes of the requirement. Will be an empty properties if
no attributes are set.
+ */
const celix_properties_t* celix_requirement_getAttributes(const
celix_requirement_t* req);
+/**
+ * @brief Returns the value of the attribute with the given key.
+ * @param[in] req The requirement.
+ * @param[in] key The key of the attribute.
+ * @return The value of the attribute or NULL if the attribute is not set.
+ */
const char* celix_requirement_getAttribute(const celix_requirement_t* req,
const char* key);
+/**
+ * @brief Add a new directive to the requirement.
+ *
+ * Note replaces an existing directive is the key is already set.
+ *
+ * @param[in] req The requirement.
+ * @param[in] key The key of the directive.
+ * @param[in] value The value of the directive.
+ */
void celix_requirement_addDirective(celix_requirement_t* req, const char* key,
const char* value);
+/**
+ * @brief Add a new directives to the requirement.
+ *
+ * Note replaces existing directives is some of the provided keys are already
set.
+ *
+ * @param[in] req The requirement.
+ * @param[in] directives The directives to add.
+ * Note the directives are copied, so the caller is
still owner of the properties.
+ */
void celix_requirement_addDirectives(celix_requirement_t* req, const
celix_properties_t* directives);
+/**
+ * @brief Add a new attribute to the requirement.
+ *
+ * Note replaces an existing attribute is the key is already set.
+ *
+ * @param[in] req The requirement.
+ * @param[in] key The key of the attribute.
+ * @param[in] value The value of the attribute.
+ */
void celix_requirement_addAttribute(celix_requirement_t* req, const char* key,
const char* value);
+/**
+ * @brief Add a new attributes to the requirement.
+ *
+ * Note replaces existing attributes is some of the provided keys are already
set.
+ *
+ * @param[in] req The requirement.
+ * @param[in] attributes The attributes to add.
+ * Note the attributes are copied, so the caller is
still owner of the properties.
+ */
void celix_requirement_addAttributes(celix_requirement_t* req, const
celix_properties_t* attributes);
#ifdef __cplusplus
diff --git a/libs/rcm/include/celix_resource.h
b/libs/rcm/include/celix_resource.h
index 99821f7a..5122edb3 100644
--- a/libs/rcm/include/celix_resource.h
+++ b/libs/rcm/include/celix_resource.h
@@ -38,21 +38,63 @@ extern "C" {
* @thread_safety none
*/
+/**
+ * @brief Creates a new resource.
+ * @return A new resource. Returns NULL if the resource could not be created.
+ */
celix_resource_t* celix_resource_create();
+/**
+ * @brief Destroys the resource.
+ * @param[in] resource The resource to destroy. Can be NULL.
+ */
void celix_resource_destroy(celix_resource_t* resource);
-//bool celix_resource_equals(const celix_resource_t* res1, const
celix_resource_t* res2);
-
-//unsigned int celix_resource_hashCode(const celix_resource_t* res);
-
+/**
+ * @brief Returns the capabilities of the resource.
+ *
+ * Will return all resource capabilities if the provided namespace is NULL.
+ *
+ * @param[in] res The resource.
+ * @param[in] ns The namespace of the capabilities. Can be NULL.
+ * @return The capabilities of the resource. Will be an empty list if the
resource has no capabilities or
+ * has no capabilities with the provided namespace.
+ */
const celix_array_list_t* celix_resource_getCapabilities(const
celix_resource_t* res, const char* ns);
+/**
+ * @brief Returns the requirements of the resource for the provided namespace.
+ *
+ * Will return all resource requirements if the provided namespace is NULL.
+ *
+ * @param[in] res The resource.
+ * @param[in] ns The namespace of the requirements. Can be NULL.
+ * @return The requirements of the resource. Will be an empty list if the
resource has no requirements or
+ * has no requirements with the provided namespace.
+ */
const celix_array_list_t* celix_resource_getRequirements(const
celix_resource_t* res, const char* ns);
-bool celix_resource_addCapability(celix_resource_t* res, celix_capability_t*
cap);
+/**
+ * @brief Adds a capability to the resource.
+ *
+ * The capability resource must be the same as this resource or a
CELIX_ILLEGAL_ARGUMENT error is returned.
+ *
+ * @param[in] res The resource.
+ * @param[in] cap The capability to add.
+ * @return CELIX_SUCCESS if the capability was added successfully.
+ */
+celix_status_t celix_resource_addCapability(celix_resource_t* res,
celix_capability_t* cap);
-bool celix_resource_addRequirement(celix_resource_t* res, celix_requirement_t*
req);
+/**
+ * @brief Adds a requirement to the resource.
+ *
+ * The requirement resource must be the same as this resource or a
CELIX_ILLEGAL_ARGUMENT error is returned.
+ *
+ * @param[in] res The resource.
+ * @param[in] req The requirement to add.
+ * @return CELIX_SUCCESS if the requirement was added successfully.
+ */
+celix_status_t celix_resource_addRequirement(celix_resource_t* res,
celix_requirement_t* req);
#ifdef __cplusplus
diff --git a/libs/rcm/src/celix_resource.c b/libs/rcm/src/celix_resource.c
index a3c2cf4b..795986f6 100644
--- a/libs/rcm/src/celix_resource.c
+++ b/libs/rcm/src/celix_resource.c
@@ -98,12 +98,12 @@ const celix_array_list_t*
celix_resource_getRequirements(const celix_resource_t*
return res->allRequirements;
}
-bool celix_resource_addCapability(celix_resource_t* res, celix_capability_t*
cap) {
+celix_status_t celix_resource_addCapability(celix_resource_t* res,
celix_capability_t* cap) {
if (celix_capability_getResource(cap) != res) {
celix_rcmErr_pushf(
"Capability is not added to the correct resource. (Capability
is added to resource %p, but resource %p is expected.)",
celix_capability_getResource(cap), res);
- return false;
+ return CELIX_ILLEGAL_ARGUMENT;
}
const char* ns = celix_capability_getNamespace(cap);
@@ -115,29 +115,23 @@ bool celix_resource_addCapability(celix_resource_t* res,
celix_capability_t* cap
}
celix_stringHashMap_put(res->capabilitiesByNamespace, ns, caps);
}
- celix_status_t status = celix_arrayList_add(caps, cap);
- if (status != CELIX_SUCCESS) {
- goto err_handling;
- }
- status = celix_arrayList_add(res->allCapabilities, cap);
- if (status != CELIX_SUCCESS) {
- goto err_handling;
- }
- return true;
+ CELIX_GOTO_IF_ERR(celix_arrayList_add(caps, cap), err_handling);
+ CELIX_GOTO_IF_ERR(celix_arrayList_add(res->allCapabilities, cap),
err_handling);
+ return CELIX_SUCCESS;
err_handling:
celix_rcmErr_push("Failed to add capability to resource. Out of memory.");
if (caps != NULL) {
celix_arrayList_remove(caps, cap);
}
- return false;
+ return CELIX_ENOMEM;
}
-bool celix_resource_addRequirement(celix_resource_t* res, celix_requirement_t*
req) {
+celix_status_t celix_resource_addRequirement(celix_resource_t* res,
celix_requirement_t* req) {
if (celix_requirement_getResource(req) != res) {
celix_rcmErr_pushf(
"Requirement is not added to the correct resource.
(Requirement is added to resource %p, but resource %p is expected.)",
celix_requirement_getResource(req), res);
- return false;
+ return CELIX_ILLEGAL_ARGUMENT;
}
const char* ns = celix_requirement_getNamespace(req);
@@ -149,20 +143,13 @@ bool celix_resource_addRequirement(celix_resource_t* res,
celix_requirement_t* r
}
celix_stringHashMap_put(res->requirementsByNamespace, ns, reqs);
}
- celix_status_t status = celix_arrayList_add(reqs, req);
- if (status != CELIX_SUCCESS) {
- goto err_handling;
- }
- status = celix_arrayList_add(res->allRequirements, req);
- if (status != CELIX_SUCCESS) {
- goto err_handling;
- }
-
- return true;
+ CELIX_GOTO_IF_ERR(celix_arrayList_add(reqs, req), err_handling);
+ CELIX_GOTO_IF_ERR(celix_arrayList_add(res->allRequirements, req),
err_handling);
+ return CELIX_SUCCESS;
err_handling:
celix_rcmErr_push("Failed to add requirement to resource. Out of memory.");
if (reqs != NULL) {
celix_arrayList_remove(reqs, req);
}
- return false;
+ return CELIX_ENOMEM;
}
diff --git a/libs/utils/include/celix_errno.h b/libs/utils/include/celix_errno.h
index 1fd0d6bf..d04b6f7e 100644
--- a/libs/utils/include/celix_errno.h
+++ b/libs/utils/include/celix_errno.h
@@ -48,7 +48,13 @@ extern "C" {
* Helper macro which check the current status and executes the provided
expression if the
* status is still CELIX_SUCCESS (0)
*/
-#define CELIX_DO_IF(status, expr) ((status) == CELIX_SUCCESS) ? (expr) :
(status)
+#define CELIX_DO_IF(__status, __expr) ((__status) == CELIX_SUCCESS) ? (__expr)
: (__status)
+
+/*!
+ * Helper macro which check the current status and executo goto the provided
label if the
+ * status is not CELIX_SUCCESS (0)
+ */
+#define CELIX_GOTO_IF_ERR(__status, __label) if ((__status) != CELIX_SUCCESS)
{ goto __label; }
/*!
* \defgroup celix_errno Error Codes