aboutsummaryrefslogtreecommitdiff
path: root/src/fstring.h
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2007-11-08 06:56:58 +0000
committerMike Buland <eichlan@xagasoft.com>2007-11-08 06:56:58 +0000
commit414328563a8c3972e8d053fb770741eb0123d826 (patch)
tree5988aa86d29c9cdc848b829e67034ec151c8f5df /src/fstring.h
parentef5e980ae9ab4ddb47e79783455b78de4b90366a (diff)
downloadlibbu++-414328563a8c3972e8d053fb770741eb0123d826.tar.gz
libbu++-414328563a8c3972e8d053fb770741eb0123d826.tar.bz2
libbu++-414328563a8c3972e8d053fb770741eb0123d826.tar.xz
libbu++-414328563a8c3972e8d053fb770741eb0123d826.zip
Bu::FString now has the functions format, formatAppend, and formatPrepend, all
of which use printf style formatting and accept the same parameters as printf.
Diffstat (limited to '')
-rw-r--r--src/fstring.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/fstring.h b/src/fstring.h
index de34cb0..2a18362 100644
--- a/src/fstring.h
+++ b/src/fstring.h
@@ -681,6 +681,50 @@ namespace Bu
681 appendChunk( pNew ); 681 appendChunk( pNew );
682 } 682 }
683 683
684 void format( const char *sFrmt, ...)
685 {
686 clear();
687
688 va_list ap;
689 va_start( ap, sFrmt );
690
691 long iLen = vsnprintf( NULL, 0, sFrmt, ap );
692
693 Chunk *pNew = newChunk( iLen );
694 vsnprintf( pNew->pData, iLen+1, sFrmt, ap );
695 appendChunk( pNew );
696
697 va_end( ap );
698 }
699
700 void formatAppend( const char *sFrmt, ...)
701 {
702 va_list ap;
703 va_start( ap, sFrmt );
704
705 long iLen = vsnprintf( NULL, 0, sFrmt, ap );
706
707 Chunk *pNew = newChunk( iLen );
708 vsnprintf( pNew->pData, iLen+1, sFrmt, ap );
709 appendChunk( pNew );
710
711 va_end( ap );
712 }
713
714 void formatPrepend( const char *sFrmt, ...)
715 {
716 va_list ap;
717 va_start( ap, sFrmt );
718
719 long iLen = vsnprintf( NULL, 0, sFrmt, ap );
720
721 Chunk *pNew = newChunk( iLen );
722 vsnprintf( pNew->pData, iLen+1, sFrmt, ap );
723 prependChunk( pNew );
724
725 va_end( ap );
726 }
727
684 /** 728 /**
685 * Function the archiver calls to archive your FString. 729 * Function the archiver calls to archive your FString.
686 *@param ar (Archive) The archive which is archiving your FString. 730 *@param ar (Archive) The archive which is archiving your FString.