OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Research In Motion Limited. All rights reserved. | 2 * Copyright (C) 2011 Research In Motion Limited. All rights reserved. |
3 * | 3 * |
4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
8 * | 8 * |
9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 destination.append(result.data(), result.size()); | 59 destination.append(result.data(), result.size()); |
60 } | 60 } |
61 | 61 |
62 // Same as appendUnsignedAsHex, but using exactly 'desiredDigits' for the | 62 // Same as appendUnsignedAsHex, but using exactly 'desiredDigits' for the |
63 // conversion. | 63 // conversion. |
64 template <typename T> | 64 template <typename T> |
65 inline void appendUnsignedAsHexFixedSize(unsigned number, | 65 inline void appendUnsignedAsHexFixedSize(unsigned number, |
66 T& destination, | 66 T& destination, |
67 unsigned desiredDigits, | 67 unsigned desiredDigits, |
68 HexConversionMode mode = Uppercase) { | 68 HexConversionMode mode = Uppercase) { |
69 ASSERT(desiredDigits); | 69 DCHECK(desiredDigits); |
70 | 70 |
71 const LChar* hexDigits = Internal::hexDigitsForMode(mode); | 71 const LChar* hexDigits = Internal::hexDigitsForMode(mode); |
72 Vector<LChar, 8> result; | 72 Vector<LChar, 8> result; |
73 do { | 73 do { |
74 result.prepend(hexDigits[number % 16]); | 74 result.prepend(hexDigits[number % 16]); |
75 number >>= 4; | 75 number >>= 4; |
76 } while (result.size() < desiredDigits); | 76 } while (result.size() < desiredDigits); |
77 | 77 |
78 ASSERT(result.size() == desiredDigits); | 78 DCHECK_EQ(result.size(), desiredDigits); |
79 destination.append(result.data(), result.size()); | 79 destination.append(result.data(), result.size()); |
80 } | 80 } |
81 | 81 |
82 } // namespace WTF | 82 } // namespace WTF |
83 | 83 |
84 using WTF::appendByteAsHex; | 84 using WTF::appendByteAsHex; |
85 using WTF::appendUnsignedAsHex; | 85 using WTF::appendUnsignedAsHex; |
86 using WTF::appendUnsignedAsHexFixedSize; | 86 using WTF::appendUnsignedAsHexFixedSize; |
87 using WTF::Lowercase; | 87 using WTF::Lowercase; |
88 | 88 |
89 #endif // HexNumber_h | 89 #endif // HexNumber_h |
OLD | NEW |