Changeset 66882 in vbox for trunk/src/VBox/Runtime/common
- Timestamp:
- May 12, 2017 5:58:26 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/string/strformatnum.cpp
r62477 r66882 172 172 173 173 174 RTDECL(ssize_t) RTStrFormatU256(char *pszBuf, size_t cbBuf, PCRTUINT256U pu256, unsigned int uiBase, 175 signed int cchWidth, signed int cchPrecision, uint32_t fFlags) 176 { 177 NOREF(cchWidth); NOREF(cchPrecision); 178 if (uiBase != 16) 179 fFlags |= RTSTR_F_SPECIAL; 180 fFlags &= ~RTSTR_F_BIT_MASK; 181 182 char szTmp[64+32+32+32]; 183 char *pszTmp = cbBuf >= sizeof(szTmp) ? pszBuf : szTmp; 184 size_t cchResult = RTStrFormatNumber(szTmp, pu256->QWords.qw3, 16, 0, 0, fFlags | RTSTR_F_64BIT); 185 cchResult += RTStrFormatNumber(&pszTmp[cchResult], pu256->QWords.qw2, 16, 8, 0, 186 (fFlags | RTSTR_F_64BIT | RTSTR_F_ZEROPAD) & ~RTSTR_F_SPECIAL); 187 cchResult += RTStrFormatNumber(&pszTmp[cchResult], pu256->QWords.qw1, 16, 8, 0, 188 (fFlags | RTSTR_F_64BIT | RTSTR_F_ZEROPAD) & ~RTSTR_F_SPECIAL); 189 cchResult += RTStrFormatNumber(&pszTmp[cchResult], pu256->QWords.qw0, 16, 8, 0, 190 (fFlags | RTSTR_F_64BIT | RTSTR_F_ZEROPAD) & ~RTSTR_F_SPECIAL); 191 if (pszTmp == pszBuf) 192 return cchResult; 193 int rc = RTStrCopy(pszBuf, cbBuf, pszTmp); 194 if (RT_SUCCESS(rc)) 195 return cchResult; 196 return rc; 197 } 198 199 200 RTDECL(ssize_t) RTStrFormatU512(char *pszBuf, size_t cbBuf, PCRTUINT512U pu512, unsigned int uiBase, 201 signed int cchWidth, signed int cchPrecision, uint32_t fFlags) 202 { 203 NOREF(cchWidth); NOREF(cchPrecision); 204 if (uiBase != 16) 205 fFlags |= RTSTR_F_SPECIAL; 206 fFlags &= ~RTSTR_F_BIT_MASK; 207 208 char szTmp[64+32+32+32 + 32+32+32+32]; 209 char *pszTmp = cbBuf >= sizeof(szTmp) ? pszBuf : szTmp; 210 size_t cchResult = RTStrFormatNumber(szTmp, pu512->QWords.qw7, 16, 0, 0, fFlags | RTSTR_F_64BIT); 211 cchResult += RTStrFormatNumber(&pszTmp[cchResult], pu512->QWords.qw6, 16, 8, 0, 212 (fFlags | RTSTR_F_64BIT | RTSTR_F_ZEROPAD) & ~RTSTR_F_SPECIAL); 213 cchResult += RTStrFormatNumber(&pszTmp[cchResult], pu512->QWords.qw5, 16, 8, 0, 214 (fFlags | RTSTR_F_64BIT | RTSTR_F_ZEROPAD) & ~RTSTR_F_SPECIAL); 215 cchResult += RTStrFormatNumber(&pszTmp[cchResult], pu512->QWords.qw4, 16, 8, 0, 216 (fFlags | RTSTR_F_64BIT | RTSTR_F_ZEROPAD) & ~RTSTR_F_SPECIAL); 217 cchResult += RTStrFormatNumber(&pszTmp[cchResult], pu512->QWords.qw3, 16, 8, 0, 218 (fFlags | RTSTR_F_64BIT | RTSTR_F_ZEROPAD) & ~RTSTR_F_SPECIAL); 219 cchResult += RTStrFormatNumber(&pszTmp[cchResult], pu512->QWords.qw2, 16, 8, 0, 220 (fFlags | RTSTR_F_64BIT | RTSTR_F_ZEROPAD) & ~RTSTR_F_SPECIAL); 221 cchResult += RTStrFormatNumber(&pszTmp[cchResult], pu512->QWords.qw1, 16, 8, 0, 222 (fFlags | RTSTR_F_64BIT | RTSTR_F_ZEROPAD) & ~RTSTR_F_SPECIAL); 223 cchResult += RTStrFormatNumber(&pszTmp[cchResult], pu512->QWords.qw0, 16, 8, 0, 224 (fFlags | RTSTR_F_64BIT | RTSTR_F_ZEROPAD) & ~RTSTR_F_SPECIAL); 225 if (pszTmp == pszBuf) 226 return cchResult; 227 int rc = RTStrCopy(pszBuf, cbBuf, pszTmp); 228 if (RT_SUCCESS(rc)) 229 return cchResult; 230 return rc; 231 } 232 233 174 234 RTDECL(ssize_t) RTStrFormatR80u2(char *pszBuf, size_t cbBuf, PCRTFLOAT80U2 pr80Value, signed int cchWidth, 175 235 signed int cchPrecision, uint32_t fFlags)
Note:
See TracChangeset
for help on using the changeset viewer.