mirror of https://github.com/tongzx/nt5src
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.1 KiB
61 lines
1.1 KiB
//+-------------------------------------------------------------------------
|
|
//
|
|
// Microsoft Windows
|
|
//
|
|
// Copyright (C) Microsoft Corporation, 1997 - 1997
|
|
//
|
|
// File: zstr.cpp
|
|
//
|
|
//--------------------------------------------------------------------------
|
|
|
|
//
|
|
// ZSTR.CPP
|
|
//
|
|
|
|
#include <iostream>
|
|
#include <fstream>
|
|
#include <stdarg.h>
|
|
#include <stdio.h>
|
|
#include "zstr.h"
|
|
|
|
void ZSTR :: Vsprintf ( SZC szcFmt, va_list valist )
|
|
{
|
|
// Attempt to "sprintf" the buffer. If it fails, reallocate
|
|
// a larger buffer and try again.
|
|
UINT cbMaxNew = 0;
|
|
char * psz = NULL;
|
|
INT cbOut;
|
|
do {
|
|
delete psz;
|
|
if ( cbMaxNew == 0 )
|
|
cbMaxNew = 256;
|
|
else
|
|
cbMaxNew += cbMaxNew / 2;
|
|
psz = new char[cbMaxNew];
|
|
} while ( (cbOut = ::_vsnprintf( psz, cbMaxNew-1, szcFmt, valist )) < 0 ) ;
|
|
psz[cbOut] = 0;
|
|
self = psz;
|
|
delete psz;
|
|
}
|
|
|
|
void ZSTR :: Format ( SZC szcFmt, ... )
|
|
{
|
|
va_list valist;
|
|
va_start( valist, szcFmt );
|
|
|
|
Vsprintf( szcFmt, valist ) ;
|
|
|
|
va_end( valist );
|
|
}
|
|
|
|
void ZSTR :: FormatAppend ( SZC szcFmt, ... )
|
|
{
|
|
ZSTR strTemp ;
|
|
va_list valist;
|
|
va_start( valist, szcFmt );
|
|
|
|
strTemp.Vsprintf( szcFmt, valist ) ;
|
|
va_end( valist );
|
|
|
|
self += strTemp;
|
|
}
|