src/cx/buffer.h

changeset 1576
7e19168d49d1
parent 1575
dde0c67a449b
--- a/src/cx/buffer.h	Thu Dec 11 23:47:46 2025 +0100
+++ b/src/cx/buffer.h	Fri Dec 12 15:07:38 2025 +0100
@@ -48,6 +48,7 @@
 
 #include "common.h"
 #include "allocator.h"
+#include "string.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -558,16 +559,48 @@
 CX_EXPORT int cxBufferTerminate(CxBuffer *buffer);
 
 /**
- * Writes a string to a buffer.
- *
- * This is a convenience function for <code>cxBufferWrite(str, 1, strlen(str), buffer)</code>.
+ * Internal function - do not use.
  *
  * @param buffer the buffer
- * @param str the zero-terminated string
+ * @param str the string
  * @return the number of bytes written
+ * @see cxBufferPutString()
+ */
+cx_attr_nonnull
+CX_EXPORT size_t cx_buffer_put_string(CxBuffer *buffer, cxstring str);
+
+/**
+ * Writes a string to a buffer with cxBufferWrite().
+ *
+ * @param buffer (@c CxBuffer*) the buffer
+ * @param str (any string) the zero-terminated string
+ * @return (@c size_t) the number of bytes written
+ * @see cxBufferWrite()
+ * @see cx_strcast()
  */
-cx_attr_nonnull cx_attr_cstr_arg(2)
-CX_EXPORT size_t cxBufferPutString(CxBuffer *buffer, const char *str);
+#define cxBufferPutString(buffer, str) cx_buffer_put_string(buffer, cx_strcast(str))
+
+/**
+ * Internal function - do not use.
+ *
+ * @param buffer the buffer
+ * @param str the string
+ * @return the number of bytes written
+ * @see cxBufferPutString()
+ */
+cx_attr_nonnull
+CX_EXPORT size_t cx_buffer_append_string(CxBuffer *buffer, cxstring str);
+
+/**
+ * Appends a string to a buffer with cxBufferAppend().
+ *
+ * @param buffer (@c CxBuffer*) the buffer
+ * @param str (any string) the zero-terminated string
+ * @return (@c size_t) the number of bytes written
+ * @see cxBufferAppend()
+ * @see cx_strcast()
+ */
+#define cxBufferAppendString(buffer, str) cx_buffer_append_string(buffer, cx_strcast(str))
 
 /**
  * Gets a character from a buffer.

mercurial