The backend classes actually implement the vappendf()
base function receiving va_list args object.
The Printf() implementations are all duplicate code. So
provide that function in terms of a virtual vappendf().
vappendf() is incidentally the name used by SBuf API for
this operation and avoids the global vprintf() libc
definition.
}
void
-Packer::Printf(const char *fmt,...)
+Packer::vappendf(const char *fmt, va_list args)
{
- va_list args;
- va_start(args, fmt);
-
assert(real_handler && packer_vprintf);
packer_vprintf(real_handler, fmt, args);
- va_end(args);
}
/* Packable API */
virtual void append(const char *buf, int size);
- virtual void Printf(const char *fmt,...) PRINTF_FORMAT_ARG2;
+ virtual void vappendf(const char *fmt, va_list ap);
/* protected, use interface functions instead */
append_f append_;
* \note we use Printf instead of printf so the compiler won't
* think we're calling the libc printf()
*/
- virtual void Printf(const char *fmt,...) PRINTF_FORMAT_ARG2 = 0;
+ void Printf(const char *fmt,...) PRINTF_FORMAT_ARG2
+ {
+ va_list args;
+ va_start(args, fmt);
+ vappendf(fmt, args);
+ va_end(args);
+ }
+
+ /** Append operation, with vsprintf(3)-style arguments.
+ *
+ * \note arguments may be evaluated more than once, be careful
+ * of side-effects
+ */
+ virtual void vappendf(const char *fmt, va_list ap) = 0;
};
#endif /* SQUID_SRC_BASE_PACKABLE_H */