commit ecab079fd1cb92073a6cd9b985b276d86c254b74 parent ff172aba950dbe4e25ef505295d2d0c6580123e0 Author: Michael Savage <mikejsavage@gmail.com> Date: Mon Sep 11 23:24:40 +0300 DynamicString::append Diffstat:
dynstr.h | | | 12 | ++++++++++++ |
diff --git a/dynstr.h b/dynstr.h @@ -1,5 +1,7 @@ #pragma once +#include <string.h> + #include "array.h" #include "ggformat.h" @@ -17,6 +19,16 @@ public: appendf( "{}", x ); } + void append( const char * str ) { + append( str, strlen( str ) ); + } + + void append( const void * data, size_t n ) { + size_t old_len = length(); + buf.extend( old_len == 0 ? n + 1 : n ); + memmove( &buf[ old_len ], data, n ); + } + template< typename... Rest > void sprintf( const char * fmt, Rest... rest ) { size_t len = ggformat( NULL, 0, fmt, rest... );