Chromium Code Reviews| 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 27 matching lines...) Expand all Loading... | |
| 38 | 38 |
| 39 template <typename T> | 39 template <typename T> |
| 40 inline void appendByteAsHex(unsigned char byte, | 40 inline void appendByteAsHex(unsigned char byte, |
| 41 T& destination, | 41 T& destination, |
| 42 HexConversionMode mode = Uppercase) { | 42 HexConversionMode mode = Uppercase) { |
| 43 const LChar* hexDigits = Internal::hexDigitsForMode(mode); | 43 const LChar* hexDigits = Internal::hexDigitsForMode(mode); |
| 44 destination.append(hexDigits[byte >> 4]); | 44 destination.append(hexDigits[byte >> 4]); |
| 45 destination.append(hexDigits[byte & 0xF]); | 45 destination.append(hexDigits[byte & 0xF]); |
| 46 } | 46 } |
| 47 | 47 |
| 48 template <> | |
| 49 inline void appendByteAsHex<Vector<LChar>>(unsigned char byte, | |
|
Yuta Kitamura
2017/01/13 07:32:09
Is just specializing for Vector<LChar> sufficient?
| |
| 50 Vector<LChar>& destination, | |
| 51 HexConversionMode mode) { | |
| 52 const LChar* hexDigits = Internal::hexDigitsForMode(mode); | |
| 53 destination.push_back(hexDigits[byte >> 4]); | |
| 54 destination.push_back(hexDigits[byte & 0xF]); | |
| 55 } | |
| 56 | |
| 48 template <typename T> | 57 template <typename T> |
| 49 inline void appendUnsignedAsHex(unsigned number, | 58 inline void appendUnsignedAsHex(unsigned number, |
| 50 T& destination, | 59 T& destination, |
| 51 HexConversionMode mode = Uppercase) { | 60 HexConversionMode mode = Uppercase) { |
| 52 const LChar* hexDigits = Internal::hexDigitsForMode(mode); | 61 const LChar* hexDigits = Internal::hexDigitsForMode(mode); |
| 53 Vector<LChar, 8> result; | 62 Vector<LChar, 8> result; |
| 54 do { | 63 do { |
| 55 result.prepend(hexDigits[number % 16]); | 64 result.prepend(hexDigits[number % 16]); |
| 56 number >>= 4; | 65 number >>= 4; |
| 57 } while (number > 0); | 66 } while (number > 0); |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 80 } | 89 } |
| 81 | 90 |
| 82 } // namespace WTF | 91 } // namespace WTF |
| 83 | 92 |
| 84 using WTF::appendByteAsHex; | 93 using WTF::appendByteAsHex; |
| 85 using WTF::appendUnsignedAsHex; | 94 using WTF::appendUnsignedAsHex; |
| 86 using WTF::appendUnsignedAsHexFixedSize; | 95 using WTF::appendUnsignedAsHexFixedSize; |
| 87 using WTF::Lowercase; | 96 using WTF::Lowercase; |
| 88 | 97 |
| 89 #endif // HexNumber_h | 98 #endif // HexNumber_h |
| OLD | NEW |