| 19 | namespace { |
| 20 | |
| 21 | std::wstring Format_uint64_t_Normal( _In_ std::uint64_t n ) { |
| 22 | // Returns formatted number like "123.456.789". |
| 23 | // 18446744073709551615 is max |
| 24 | // ^ 20 characters |
| 25 | // 18,446,744,073,709,551,615 |
| 26 | // ^26 characters |
| 27 | // 26 + null terminator = 27 |
| 28 | //const rsize_t number_formatted_buffer_size = 28; |
| 29 | //wchar_t buffer[ number_formatted_buffer_size ] = { 0 }; |
| 30 | |
| 31 | std::wstring all_ws; |
| 32 | all_ws.reserve( 27 ); |
| 33 | |
| 34 | do |
| 35 | { |
| 36 | const auto rest = static_cast<INT>( n % 1000 ); |
| 37 | n /= 1000; |
| 38 | const rsize_t tempBuf_size = 10u; |
| 39 | _Null_terminated_ wchar_t tempBuf[ tempBuf_size ] = { 0 }; |
| 40 | if ( n > 0 ) { |
| 41 | const HRESULT fmt_res = StringCchPrintfW( tempBuf, tempBuf_size, L",%03d", rest ); |
| 42 | ASSERT( SUCCEEDED( fmt_res ) ); |
| 43 | if ( !SUCCEEDED( fmt_res ) ) { |
| 44 | return L"FORMATTING FAILED!"; |
| 45 | } |
| 46 | all_ws += tempBuf; |
| 47 | } |
| 48 | else { |
| 49 | all_ws += std::to_wstring( rest ); |
| 50 | //const HRESULT fmt_res = StringCchPrintfW( tempBuf, tempBuf_size, L"%d", rest ); |
| 51 | //ASSERT( SUCCEEDED( fmt_res ) ); |
| 52 | //if ( !SUCCEEDED( fmt_res ) ) { |
| 53 | // return L"FORMATTING FAILED!"; |
| 54 | // } |
| 55 | } |
| 56 | //all_ws += tempBuf; |
| 57 | } while ( n > 0 ); |
| 58 | return all_ws; |
| 59 | } |
| 60 | |
| 61 | //maximum representable integral component of a double SEEMS to be 15 characters long, so we need at least 17 |
| 62 | //The compiler will automatically inline if /Ob2 is on, so we'll ask anyways. |