src/cx/properties.h

changeset 988
15b3ca7ee33f
parent 985
68754c7de906
--- a/src/cx/properties.h	Tue Nov 12 17:34:04 2024 +0100
+++ b/src/cx/properties.h	Mon Nov 18 22:05:42 2024 +0100
@@ -396,6 +396,74 @@
         size_t len
 );
 
+#ifdef __cplusplus
+} // extern "C"
+/**
+ * Fills the input buffer with a string.
+ *
+ * Currently unprocessed data is copied to a temporary buffer.
+ * This temporary buffer is allocated on the heap, unless you specified
+ * a buffer on the stack with #cxPropertiesUseStack().
+ * In that case, the stack buffer is used, until the capacity is not sufficient
+ * anymore.
+ *
+ * @param prop the properties interface
+ * @param str the string
+ * @return non-zero when a memory allocation was necessary but failed
+ */
+cx_attr_nonnull
+static inline int cxPropertiesFill(
+        CxProperties *prop,
+        cxstring str
+) {
+    return cxPropertiesFilln(prop, str.ptr, str.length);
+}
+
+/**
+ * Fills the input buffer with a string.
+ *
+ * Currently unprocessed data is copied to a temporary buffer.
+ * This temporary buffer is allocated on the heap, unless you specified
+ * a buffer on the stack with #cxPropertiesUseStack().
+ * In that case, the stack buffer is used, until the capacity is not sufficient
+ * anymore.
+ *
+ * @param prop the properties interface
+ * @param str the string
+ * @return non-zero when a memory allocation was necessary but failed
+ */
+cx_attr_nonnull
+static inline int cxPropertiesFill(
+        CxProperties *prop,
+        cxmutstr str
+) {
+    return cxPropertiesFilln(prop, str.ptr, str.length);
+}
+
+/**
+ * Fills the input buffer with a string.
+ *
+ * Currently unprocessed data is copied to a temporary buffer.
+ * This temporary buffer is allocated on the heap, unless you specified
+ * a buffer on the stack with #cxPropertiesUseStack().
+ * In that case, the stack buffer is used, until the capacity is not sufficient
+ * anymore.
+ *
+ * @param prop the properties interface
+ * @param str the string
+ * @return non-zero when a memory allocation was necessary but failed
+ */
+cx_attr_nonnull
+cx_attr_cstr_arg(2)
+static inline int cxPropertiesFill(
+        CxProperties *prop,
+        const char *str
+) {
+    return cxPropertiesFilln(prop, str, strlen(str));
+}
+
+extern "C" {
+#else // __cplusplus
 /**
  * Fills the input buffer with a string.
  *
@@ -461,6 +529,7 @@
 ) {
     return cxPropertiesFilln(prop, str, strlen(str));
 }
+#endif
 
 /**
  * Specifies stack memory that shall be used by #cxPropertiesFill().

mercurial