1010 ****************************************************************************
1111 * HEADER
1212 *
13- * $Id: BufPrint.h 4915 2021-12-01 18:26:55Z wini $
13+ * $Id: BufPrint.h 5029 2022-01-16 21:32:09Z wini $
1414 *
1515 * COPYRIGHT: Real Time Logic LLC, 2008 - 2022
1616 *
@@ -85,25 +85,38 @@ BA_API int basnprintf(char* buf, int len, const char* fmt, ...);
8585
8686/* * BufPrint flush callback function.
8787
88- A BufPrint instance calls the flush callback function when buffer is
89- full. The callback can either extend the buffer or flush and reset the
90- buffer.
88+ A BufPrint instance calls the flush callback function when the buffer
89+ is full or when #BufPrint::flush is called. The callback can either
90+ extend the buffer or flush and reset the buffer.
91+
92+ The following default callback is set if no callback is installed when
93+ calling the BufPrint constructor:
94+
95+ \code
96+ BufPrint_defaultFlush(struct BufPrint* bp, int sizeRequired)
97+ {
98+ bp->cursor=0; // Reset
99+ baAssert(sizeRequired == 0); // Program error in code calling BufPrint_xxx
100+ return sizeRequired ? -1 : 0;
101+ }
102+ \endcode
91103
92104\param o the object. BufPrint is typically upcasted to the derived object.
93- \param sizeRequired the required expands size if the callback is
94- expanding the buffer. Not used when flushing and resetting the buffer.
105+ \param sizeRequired the minimum size the buffer must expand. Note that
106+ sizeRequired will be zero when the callback is called via
107+ BufPrint::flush
108+
95109*/
96110typedef int (*BufPrint_Flush)(struct BufPrint * o, int sizeRequired);
97111
98112/* * The BufPrint class, which implements an ANSI compatible printf
99- method, is an abstract class used as a base for many of the
100- Barracuda classes.
101-
102- The output from printf is formatted in an internal buffer. This
103- class does not allocate memory for the buffer. Thus, any class
104- using BufPrint must provide a buffer BufPrint can use. BufPrint
105- calls the callback function BufPrint_Flush when the buffer is
106- full.
113+ method, is a base class used by several other classes.
114+
115+ This class does not allocate memory for the buffer. Thus, any
116+ class using BufPrint must provide a buffer BufPrint can use. The
117+ output from printf is formatted in the buffer passed into the
118+ constructor. BufPrint calls the callback function BufPrint_Flush
119+ when the buffer is full. See #BufPrint_Flush for additional details.
107120 */
108121typedef struct BufPrint
109122{
@@ -114,7 +127,8 @@ typedef struct BufPrint
114127
115128 \param userData an optional argument stored in the BufPrint
116129 object and accessible in the flush callback.
117- \param flush a pointer to the flush callback function.
130+ \param flush a pointer to the flush callback function. See
131+ #BufPrint_Flush for details.
118132
119133 \sa setBuf(), getUserData()
120134 */
@@ -127,7 +141,8 @@ typedef struct BufPrint
127141 \param size the buffer size
128142 \param userData an optional argument stored in the BufPrint
129143 object and accessible in the flush callback.
130- \param flush a pointer to the flush callback function.
144+ \param flush a pointer to the flush callback function. See
145+ #BufPrint_Flush for details.
131146
132147 \sa setBuf(), getUserData()
133148 */
0 commit comments