コード例 #1
0
ファイル: pnUtStr.cpp プロジェクト: GPNMilano/Plasma
//===========================================================================
unsigned StrPrintf (wchar_t * dest, unsigned count, const wchar_t format[], ...) {
    va_list argList;
    va_start(argList, format);
    int result = hsVsnwprintf(dest, count, format, argList);
    va_end(argList);
    return IStrPrintfValidate(dest, count, result);
}
コード例 #2
0
ファイル: hsStlUtils.cpp プロジェクト: branan/Plasma-nobink
bool formatv(std::wstring & out, const wchar_t * fmt, va_list args)
{
#define kBufSz 2048
    
    wchar_t buf[kBufSz];
    wchar_t * pbuf = buf;
    int len = 0;
    int attempts = 0;
    bool success = false;
    const int kMaxAttempts = 40;
    
    do
    {
        int maxlen = kBufSz*attempts+kBufSz-1;
        len = hsVsnwprintf(pbuf,maxlen,fmt,args);
        attempts++;
        success = (len>=0 && len<maxlen);
        if (!success)
        {
            if (pbuf!=buf)
                delete [] pbuf;
            pbuf = new wchar_t[kBufSz+kBufSz*attempts];
        }
    }
    while (!success && attempts<kMaxAttempts);
    
    if (success)
    {
        pbuf[len] = L'\0';
        out = pbuf;
    }
    
    if (success)
    {
        pbuf[len] = L'\0';
        out = pbuf;
    }
    else
    {
        out = L"";
        if ( attempts==kMaxAttempts )
        {
            hsDebugMessage( "xtl::formatv - Max reallocs occurred while formatting wstring. Result is likely truncated!", 0 );
        }
    }
    
    if (pbuf!=buf)
        delete [] pbuf;
    
    return success;
}
コード例 #3
0
ファイル: pnUtStr.cpp プロジェクト: GPNMilano/Plasma
//===========================================================================
unsigned StrPrintfV (wchar_t * dest, unsigned count, const wchar_t format[], va_list args) {
    int result = hsVsnwprintf(dest, count, format, args);
    return IStrPrintfValidate(dest, count, result);
}