@@ -75,7 +75,11 @@ typedef enum line_sender_error_code
7575LINESENDER_API
7676line_sender_error_code line_sender_error_get_code (const line_sender_error * );
7777
78- /** ASCII encoded error message. Never returns NULL. */
78+ /**
79+ * UTF-8 encoded error message. Never returns NULL.
80+ * The `len_out` argument is set to the number of bytes in the string.
81+ * The string is NOT null-terminated.
82+ */
7983LINESENDER_API
8084const char * line_sender_error_msg (const line_sender_error * , size_t * len_out );
8185
@@ -86,7 +90,10 @@ void line_sender_error_free(line_sender_error*);
8690
8791/////////// Preparing strings and names
8892
89- /** Non-owning validated UTF-8 encoded string. */
93+ /**
94+ * Non-owning validated UTF-8 encoded string.
95+ * The string need not be null-terminated.
96+ */
9097typedef struct line_sender_utf8
9198{
9299 // Don't initialize fields directly.
@@ -100,7 +107,7 @@ typedef struct line_sender_utf8
100107 *
101108 * @param[out] str The object to be initialized.
102109 * @param[in] len Length in bytes of the buffer.
103- * @param[in] buf UTF-8 encoded buffer.
110+ * @param[in] buf UTF-8 encoded buffer. Need not be null-terminated.
104111 * @param[out] err_out Set on error.
105112 * @return true on success, false on error.
106113 */
@@ -124,7 +131,10 @@ line_sender_utf8 line_sender_utf8_assert(size_t len, const char* buf);
124131#define QDB_UTF8_LITERAL (literal ) \
125132 line_sender_utf8_assert(sizeof(literal) - 1, (literal))
126133
127- /** Non-owning validated table, symbol or column name. UTF-8 encoded. */
134+ /**
135+ * Non-owning validated table, symbol or column name. UTF-8 encoded.
136+ * Need not be null-terminated.
137+ */
128138typedef struct line_sender_table_name
129139{
130140 // Don't initialize fields directly.
@@ -139,7 +149,7 @@ typedef struct line_sender_table_name
139149 *
140150 * @param[out] name The object to be initialized.
141151 * @param[in] len Length in bytes of the buffer.
142- * @param[in] buf UTF-8 encoded buffer.
152+ * @param[in] buf UTF-8 encoded buffer. Need not be null-terminated.
143153 * @param[out] err_out Set on error.
144154 * @return true on success, false on error.
145155 */
@@ -166,7 +176,10 @@ line_sender_table_name line_sender_table_name_assert(
166176#define QDB_TABLE_NAME_LITERAL (literal ) \
167177 line_sender_table_name_assert(sizeof(literal) - 1, (literal))
168178
169- /** Non-owning validated table, symbol or column name. UTF-8 encoded. */
179+ /**
180+ * Non-owning validated table, symbol or column name. UTF-8 encoded.
181+ * Need not be null-terminated.
182+ */
170183typedef struct line_sender_column_name
171184{
172185 // Don't initialize fields directly.
@@ -181,7 +194,7 @@ typedef struct line_sender_column_name
181194 *
182195 * @param[out] name The object to be initialized.
183196 * @param[in] len Length in bytes of the buffer.
184- * @param[in] buf UTF-8 encoded buffer.
197+ * @param[in] buf UTF-8 encoded buffer. Need not be null-terminated.
185198 * @param[out] err_out Set on error.
186199 * @return true on success, false on error.
187200 */
@@ -236,6 +249,7 @@ line_sender_buffer* line_sender_buffer_clone(const line_sender_buffer* buffer);
236249/**
237250 * Pre-allocate to ensure the buffer has enough capacity for at least the
238251 * specified additional byte count. This may be rounded up.
252+ * This does not allocate if such additional capacity is already satisfied.
239253 * See: `capacity`.
240254 */
241255LINESENDER_API
@@ -247,6 +261,32 @@ void line_sender_buffer_reserve(
247261LINESENDER_API
248262size_t line_sender_buffer_capacity (const line_sender_buffer * buffer );
249263
264+ /**
265+ * Mark a rewind point.
266+ * This allows undoing accumulated changes to the buffer for one or more
267+ * rows by calling `rewind_to_marker`.
268+ * Any previous marker will be discarded.
269+ * Once the marker is no longer needed, call `clear_marker`.
270+ */
271+ LINESENDER_API
272+ bool line_sender_buffer_set_marker (
273+ line_sender_buffer * buffer ,
274+ line_sender_error * * err_out );
275+
276+ /**
277+ * Undo all changes since the last `set_marker` call.
278+ * As a side-effect, this also clears the marker.
279+ */
280+ LINESENDER_API
281+ bool line_sender_buffer_rewind_to_marker (
282+ line_sender_buffer * buffer ,
283+ line_sender_error * * err_out );
284+
285+ /** Discard the marker. */
286+ LINESENDER_API
287+ void line_sender_buffer_clear_marker (
288+ line_sender_buffer * buffer );
289+
250290/**
251291 * Remove all accumulated data and prepare the buffer for new lines.
252292 * This does not affect the buffer's capacity.
0 commit comments