src/cx/buffer.h

changeset 1576
7e19168d49d1
parent 1575
dde0c67a449b
equal deleted inserted replaced
1575:dde0c67a449b 1576:7e19168d49d1
46 #ifndef UCX_BUFFER_H 46 #ifndef UCX_BUFFER_H
47 #define UCX_BUFFER_H 47 #define UCX_BUFFER_H
48 48
49 #include "common.h" 49 #include "common.h"
50 #include "allocator.h" 50 #include "allocator.h"
51 #include "string.h"
51 52
52 #ifdef __cplusplus 53 #ifdef __cplusplus
53 extern "C" { 54 extern "C" {
54 #endif 55 #endif
55 56
556 */ 557 */
557 cx_attr_nonnull 558 cx_attr_nonnull
558 CX_EXPORT int cxBufferTerminate(CxBuffer *buffer); 559 CX_EXPORT int cxBufferTerminate(CxBuffer *buffer);
559 560
560 /** 561 /**
561 * Writes a string to a buffer. 562 * Internal function - do not use.
562 * 563 *
563 * This is a convenience function for <code>cxBufferWrite(str, 1, strlen(str), buffer)</code>. 564 * @param buffer the buffer
564 * 565 * @param str the string
565 * @param buffer the buffer
566 * @param str the zero-terminated string
567 * @return the number of bytes written 566 * @return the number of bytes written
568 */ 567 * @see cxBufferPutString()
569 cx_attr_nonnull cx_attr_cstr_arg(2) 568 */
570 CX_EXPORT size_t cxBufferPutString(CxBuffer *buffer, const char *str); 569 cx_attr_nonnull
570 CX_EXPORT size_t cx_buffer_put_string(CxBuffer *buffer, cxstring str);
571
572 /**
573 * Writes a string to a buffer with cxBufferWrite().
574 *
575 * @param buffer (@c CxBuffer*) the buffer
576 * @param str (any string) the zero-terminated string
577 * @return (@c size_t) the number of bytes written
578 * @see cxBufferWrite()
579 * @see cx_strcast()
580 */
581 #define cxBufferPutString(buffer, str) cx_buffer_put_string(buffer, cx_strcast(str))
582
583 /**
584 * Internal function - do not use.
585 *
586 * @param buffer the buffer
587 * @param str the string
588 * @return the number of bytes written
589 * @see cxBufferPutString()
590 */
591 cx_attr_nonnull
592 CX_EXPORT size_t cx_buffer_append_string(CxBuffer *buffer, cxstring str);
593
594 /**
595 * Appends a string to a buffer with cxBufferAppend().
596 *
597 * @param buffer (@c CxBuffer*) the buffer
598 * @param str (any string) the zero-terminated string
599 * @return (@c size_t) the number of bytes written
600 * @see cxBufferAppend()
601 * @see cx_strcast()
602 */
603 #define cxBufferAppendString(buffer, str) cx_buffer_append_string(buffer, cx_strcast(str))
571 604
572 /** 605 /**
573 * Gets a character from a buffer. 606 * Gets a character from a buffer.
574 * 607 *
575 * The current position of the buffer is increased after a successful read. 608 * The current position of the buffer is increased after a successful read.

mercurial