This is an automated email from the ASF dual-hosted git repository.

pnoltes pushed a commit to branch feature/674-improve-properties
in repository https://gitbox.apache.org/repos/asf/celix.git

commit 4a4e53d24d05df1ba1a4d111aa00eb16919fa10e
Author: Pepijn Noltes <[email protected]>
AuthorDate: Sun Jan 21 16:33:37 2024 +0100

    Add filter/properties type header with only a typedef
---
 libs/utils/include/celix_filter.h          |  5 ++--
 libs/utils/include/celix_filter_type.h     | 41 +++++++++++++++++++++++++++++
 libs/utils/include/celix_properties.h      | 10 ++-----
 libs/utils/include/celix_properties_type.h | 41 +++++++++++++++++++++++++++++
 libs/utils/src/properties.c                | 42 +++++++++++++++---------------
 5 files changed, 108 insertions(+), 31 deletions(-)

diff --git a/libs/utils/include/celix_filter.h 
b/libs/utils/include/celix_filter.h
index fcb4c3d0..9c898632 100644
--- a/libs/utils/include/celix_filter.h
+++ b/libs/utils/include/celix_filter.h
@@ -101,6 +101,7 @@
 #ifndef CELIX_FILTER_H_
 #define CELIX_FILTER_H_
 
+#include "celix_filter_type.h"
 #include "celix_array_list.h"
 #include "celix_cleanup.h"
 #include "celix_properties.h"
@@ -135,7 +136,7 @@ typedef struct celix_filter_internal 
celix_filter_internal_t; // opaque struct f
 /**
  * @brief The Apache Celix filter struct.
  */
-typedef struct celix_filter_struct {
+struct celix_filter_struct {
     celix_filter_operand_t operand; /**< The filter operand. */
     const char* attribute;          /**< The filter attribute; NULL for 
operands `AND`, `OR` or `NOT`. */
     const char* value;              /**< The filter value; NULL for operands 
`AND`, `OR` or `NOT`. */
@@ -145,7 +146,7 @@ typedef struct celix_filter_struct {
                                      the value is NULL. */
 
     celix_filter_internal_t* internal; /**< Internal use only. */
-} celix_filter_t;
+};
 
 /**
  * @brief Create a filter based on the provided filter string.
diff --git a/libs/utils/include/celix_filter_type.h 
b/libs/utils/include/celix_filter_type.h
new file mode 100644
index 00000000..147fe787
--- /dev/null
+++ b/libs/utils/include/celix_filter_type.h
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * @file celix_filter_type.h
+ * @brief Header file for celix_filter_t opaque type. Can be used for forward 
declaration.
+ */
+
+#ifndef CELIX_FILTER_TYPE_H_
+#define CELIX_FILTER_TYPE_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @brief The Apache Celix filter type.
+ */
+typedef struct celix_filter_struct celix_filter_t;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CELIX_FILTER_TYPE_H_ */
diff --git a/libs/utils/include/celix_properties.h 
b/libs/utils/include/celix_properties.h
index 875aad04..5bd06ce2 100644
--- a/libs/utils/include/celix_properties.h
+++ b/libs/utils/include/celix_properties.h
@@ -40,6 +40,7 @@
 
 #include <stdio.h>
 
+#include "celix_properties_type.h"
 #include "celix_cleanup.h"
 #include "celix_compiler.h"
 #include "celix_errno.h"
@@ -51,13 +52,6 @@
 extern "C" {
 #endif
 
-/**
- * @brief celix_properties_t is a type that represents a set of key-value 
pairs called properties.
- *
- * @note Not thread safe.
- */
-typedef struct celix_properties celix_properties_t;
-
 /**
  * @brief Enum representing the possible types of a property value.
  */
@@ -193,7 +187,7 @@ CELIX_UTILS_EXPORT celix_status_t 
celix_properties_store(celix_properties_t* pro
  * @param[in] key The key to search for.
  * @return The entry for the given key, or a NULL if the key is not found.
  */
-CELIX_UTILS_EXPORT celix_properties_entry_t* celix_properties_getEntry(const 
celix_properties_t* properties,
+CELIX_UTILS_EXPORT const celix_properties_entry_t* 
celix_properties_getEntry(const celix_properties_t* properties,
                                                                        const 
char* key);
 
 /**
diff --git a/libs/utils/include/celix_properties_type.h 
b/libs/utils/include/celix_properties_type.h
new file mode 100644
index 00000000..4c8a4344
--- /dev/null
+++ b/libs/utils/include/celix_properties_type.h
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * @file celix_properties_type.h
+ * @brief Header file for celix_properties_t opaque type. Can be used for 
forward declaration.
+ */
+
+#ifndef CELIX_PROPERTIES_TYPE_H_
+#define CELIX_PROPERTIES_TYPE_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @brief The Apache Celix properties type.
+ */
+typedef struct celix_properties celix_properties_t;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CELIX_PROPERTIES_TYPE_H_ */
diff --git a/libs/utils/src/properties.c b/libs/utils/src/properties.c
index 3ad83f68..436493cd 100644
--- a/libs/utils/src/properties.c
+++ b/libs/utils/src/properties.c
@@ -644,14 +644,14 @@ bool celix_properties_hasKey(const celix_properties_t* 
properties, const char* k
 }
 
 const char* celix_properties_get(const celix_properties_t* properties, const 
char* key, const char* defaultValue) {
-    celix_properties_entry_t* entry = celix_properties_getEntry(properties, 
key);
+    const celix_properties_entry_t* entry = 
celix_properties_getEntry(properties, key);
     if (entry != NULL) {
         return entry->value;
     }
     return defaultValue;
 }
 
-celix_properties_entry_t* celix_properties_getEntry(const celix_properties_t* 
properties, const char* key) {
+const celix_properties_entry_t* celix_properties_getEntry(const 
celix_properties_t* properties, const char* key) {
     celix_properties_entry_t* entry = NULL;
     if (properties) {
         entry = celix_stringHashMap_get(properties->map, key);
@@ -742,7 +742,7 @@ void celix_properties_unset(celix_properties_t* properties, 
const char* key) {
 }
 
 long celix_properties_getLong(const celix_properties_t* properties, const 
char* key, long defaultValue) {
-    celix_properties_entry_t* entry = celix_properties_getEntry(properties, 
key);
+    const celix_properties_entry_t* entry = 
celix_properties_getEntry(properties, key);
     if (entry != NULL && entry->valueType == CELIX_PROPERTIES_VALUE_TYPE_LONG) 
{
         return entry->typed.longValue;
     }
@@ -750,7 +750,7 @@ long celix_properties_getLong(const celix_properties_t* 
properties, const char*
 }
 
 long celix_properties_getAsLong(const celix_properties_t* props, const char* 
key, long defaultValue) {
-    celix_properties_entry_t* entry = celix_properties_getEntry(props, key);
+    const celix_properties_entry_t* entry = celix_properties_getEntry(props, 
key);
     if (entry != NULL && entry->valueType == CELIX_PROPERTIES_VALUE_TYPE_LONG) 
{
         return entry->typed.longValue;
     } else if (entry != NULL && entry->valueType == 
CELIX_PROPERTIES_VALUE_TYPE_DOUBLE) {
@@ -769,7 +769,7 @@ celix_status_t celix_properties_setLong(celix_properties_t* 
props, const char* k
 }
 
 double celix_properties_getDouble(const celix_properties_t* properties, const 
char* key, double defaultValue) {
-    celix_properties_entry_t* entry = celix_properties_getEntry(properties, 
key);
+    const celix_properties_entry_t* entry = 
celix_properties_getEntry(properties, key);
     if (entry != NULL && entry->valueType == 
CELIX_PROPERTIES_VALUE_TYPE_DOUBLE) {
         return entry->typed.doubleValue;
     }
@@ -777,7 +777,7 @@ double celix_properties_getDouble(const celix_properties_t* 
properties, const ch
 }
 
 double celix_properties_getAsDouble(const celix_properties_t* props, const 
char* key, double defaultValue) {
-    celix_properties_entry_t* entry = celix_properties_getEntry(props, key);
+    const celix_properties_entry_t* entry = celix_properties_getEntry(props, 
key);
     if (entry != NULL && entry->valueType == 
CELIX_PROPERTIES_VALUE_TYPE_DOUBLE) {
         return entry->typed.doubleValue;
     } else if (entry != NULL) {
@@ -794,7 +794,7 @@ celix_status_t 
celix_properties_setDouble(celix_properties_t* props, const char*
 }
 
 bool celix_properties_getBool(const celix_properties_t* properties, const 
char* key, bool defaultValue) {
-    celix_properties_entry_t* entry = celix_properties_getEntry(properties, 
key);
+    const celix_properties_entry_t* entry = 
celix_properties_getEntry(properties, key);
     if (entry != NULL && entry->valueType == CELIX_PROPERTIES_VALUE_TYPE_BOOL) 
{
         return entry->typed.boolValue;
     }
@@ -802,7 +802,7 @@ bool celix_properties_getBool(const celix_properties_t* 
properties, const char*
 }
 
 bool celix_properties_getAsBool(const celix_properties_t* props, const char* 
key, bool defaultValue) {
-    celix_properties_entry_t* entry = celix_properties_getEntry(props, key);
+    const celix_properties_entry_t* entry = celix_properties_getEntry(props, 
key);
     if (entry != NULL && entry->valueType == CELIX_PROPERTIES_VALUE_TYPE_BOOL) 
{
         return entry->typed.boolValue;
     } else if (entry != NULL) {
@@ -821,7 +821,7 @@ celix_status_t celix_properties_setBool(celix_properties_t* 
props, const char* k
 const celix_version_t* celix_properties_getVersion(const celix_properties_t* 
properties,
                                                    const char* key,
                                                    const celix_version_t* 
defaultValue) {
-    celix_properties_entry_t* entry = celix_properties_getEntry(properties, 
key);
+    const celix_properties_entry_t* entry = 
celix_properties_getEntry(properties, key);
     if (entry != NULL && entry->valueType == 
CELIX_PROPERTIES_VALUE_TYPE_VERSION) {
         return entry->typed.versionValue;
     }
@@ -832,7 +832,7 @@ celix_status_t celix_properties_getAsVersion(const 
celix_properties_t* propertie
                                                const char* key,
                                                const celix_version_t* 
defaultValue,
                                                celix_version_t** version) {
-    celix_properties_entry_t* entry = celix_properties_getEntry(properties, 
key);
+    const celix_properties_entry_t* entry = 
celix_properties_getEntry(properties, key);
     if (entry != NULL && entry->valueType == 
CELIX_PROPERTIES_VALUE_TYPE_VERSION) {
         celix_version_t* copy = celix_version_copy(entry->typed.versionValue);
         if (!copy) {
@@ -886,7 +886,7 @@ celix_status_t celix_properties_getAsLongArrayList(const 
celix_properties_t* pro
                                                    const char* key,
                                                    const celix_array_list_t* 
defaultValue,
                                                    celix_array_list_t** list) {
-    celix_properties_entry_t* entry = celix_properties_getEntry(properties, 
key);
+    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) {
@@ -958,7 +958,7 @@ celix_properties_setLongs(celix_properties_t* properties, 
const char* key, const
 const celix_array_list_t* celix_properties_getLongArrayList(const 
celix_properties_t* properties,
                                                             const char* key,
                                                             const 
celix_array_list_t* defaultValue) {
-    celix_properties_entry_t* entry = celix_properties_getEntry(properties, 
key);
+    const celix_properties_entry_t* entry = 
celix_properties_getEntry(properties, key);
     if (entry != NULL && entry->valueType == 
CELIX_PROPERTIES_VALUE_TYPE_LONG_ARRAY) {
         return entry->typed.arrayValue;
     }
@@ -1012,7 +1012,7 @@ celix_status_t 
celix_properties_getAsDoubleArrayList(const celix_properties_t* p
                                                      const char* key,
                                                      const celix_array_list_t* 
defaultValue,
                                                      celix_array_list_t** 
list) {
-    celix_properties_entry_t* entry = celix_properties_getEntry(properties, 
key);
+    const celix_properties_entry_t* entry = 
celix_properties_getEntry(properties, key);
     if (entry != NULL && entry->valueType == 
CELIX_PROPERTIES_VALUE_TYPE_DOUBLE_ARRAY) {
         celix_array_list_t* copy = 
celix_arrayList_copy(entry->typed.arrayValue);
         if (!copy) {
@@ -1040,7 +1040,7 @@ celix_status_t 
celix_properties_getAsDoubleArrayList(const celix_properties_t* p
 const celix_array_list_t* celix_properties_getDoubleArrayList(const 
celix_properties_t* properties,
                                                               const char* key,
                                                               const 
celix_array_list_t* defaultValue) {
-    celix_properties_entry_t* entry = celix_properties_getEntry(properties, 
key);
+    const celix_properties_entry_t* entry = 
celix_properties_getEntry(properties, key);
     if (entry != NULL && entry->valueType == 
CELIX_PROPERTIES_VALUE_TYPE_DOUBLE_ARRAY) {
         return entry->typed.arrayValue;
     }
@@ -1093,7 +1093,7 @@ celix_status_t celix_properties_getAsBoolArrayList(const 
celix_properties_t* pro
                                                      const char* key,
                                                      const celix_array_list_t* 
defaultValue,
                                                      celix_array_list_t** 
list) {
-    celix_properties_entry_t* entry = celix_properties_getEntry(properties, 
key);
+    const celix_properties_entry_t* entry = 
celix_properties_getEntry(properties, key);
     if (entry != NULL && entry->valueType == 
CELIX_PROPERTIES_VALUE_TYPE_BOOL_ARRAY) {
         celix_array_list_t* copy = 
celix_arrayList_copy(entry->typed.arrayValue);
         if (!copy) {
@@ -1121,7 +1121,7 @@ celix_status_t celix_properties_getAsBoolArrayList(const 
celix_properties_t* pro
 const celix_array_list_t* celix_properties_getBoolArrayList(const 
celix_properties_t* properties,
                                                               const char* key,
                                                               const 
celix_array_list_t* defaultValue) {
-    celix_properties_entry_t* entry = celix_properties_getEntry(properties, 
key);
+    const celix_properties_entry_t* entry = 
celix_properties_getEntry(properties, key);
     if (entry != NULL && entry->valueType == 
CELIX_PROPERTIES_VALUE_TYPE_BOOL_ARRAY) {
         return entry->typed.arrayValue;
     }
@@ -1224,7 +1224,7 @@ celix_status_t 
celix_properties_getAsStringArrayList(const celix_properties_t* p
                                                    const char* key,
                                                    const celix_array_list_t* 
defaultValue,
                                                    celix_array_list_t** list) {
-    celix_properties_entry_t* entry = celix_properties_getEntry(properties, 
key);
+    const celix_properties_entry_t* entry = 
celix_properties_getEntry(properties, key);
     if (entry != NULL && entry->valueType == 
CELIX_PROPERTIES_VALUE_TYPE_STRING_ARRAY) {
         *list = 
celix_properties_deepCopyStringArrayList(entry->typed.arrayValue);
         return *list ? CELIX_SUCCESS : CELIX_ENOMEM;
@@ -1248,7 +1248,7 @@ celix_status_t 
celix_properties_getAsStringArrayList(const celix_properties_t* p
 const celix_array_list_t* celix_properties_getStringArrayList(const 
celix_properties_t* properties,
                                                             const char* key,
                                                             const 
celix_array_list_t* defaultValue) {
-    celix_properties_entry_t* entry = celix_properties_getEntry(properties, 
key);
+    const celix_properties_entry_t* entry = 
celix_properties_getEntry(properties, key);
     if (entry != NULL && entry->valueType == 
CELIX_PROPERTIES_VALUE_TYPE_STRING_ARRAY) {
         return entry->typed.arrayValue;
     }
@@ -1354,7 +1354,7 @@ celix_status_t 
celix_properties_getAsVersionArrayList(const celix_properties_t*
                                                      const char* key,
                                                      const celix_array_list_t* 
defaultValue,
                                                      celix_array_list_t** 
list) {
-    celix_properties_entry_t* entry = celix_properties_getEntry(properties, 
key);
+    const celix_properties_entry_t* entry = 
celix_properties_getEntry(properties, key);
     if (entry != NULL && entry->valueType == 
CELIX_PROPERTIES_VALUE_TYPE_VERSION_ARRAY) {
         *list = 
celix_properties_deepCopyVersionArrayList(entry->typed.arrayValue);
         return *list ? CELIX_SUCCESS : CELIX_ENOMEM;
@@ -1378,7 +1378,7 @@ celix_status_t 
celix_properties_getAsVersionArrayList(const celix_properties_t*
 const celix_array_list_t* celix_properties_getVersionArrayList(const 
celix_properties_t* properties,
                                                               const char* key,
                                                               const 
celix_array_list_t* defaultValue) {
-    celix_properties_entry_t* entry = celix_properties_getEntry(properties, 
key);
+    const celix_properties_entry_t* entry = 
celix_properties_getEntry(properties, key);
     if (entry != NULL && entry->valueType == 
CELIX_PROPERTIES_VALUE_TYPE_VERSION_ARRAY) {
         return entry->typed.arrayValue;
     }
@@ -1403,7 +1403,7 @@ bool celix_properties_equals(const celix_properties_t* 
props1, const celix_prope
         return false;
     }
     CELIX_PROPERTIES_ITERATE(props1, iter) {
-        celix_properties_entry_t* entry2 = celix_properties_getEntry(props2, 
iter.key);
+        const celix_properties_entry_t* entry2 = 
celix_properties_getEntry(props2, iter.key);
         if (entry2 == NULL || !celix_properties_entryEquals(&iter.entry, 
entry2)) {
             return false;
         }

Reply via email to