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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 | 42 |
43 template<typename T> | 43 template<typename T> |
44 inline void appendByteAsHex(unsigned char byte, T& destination, HexConversionMod
e mode = Uppercase) | 44 inline void appendByteAsHex(unsigned char byte, T& destination, HexConversionMod
e mode = Uppercase) |
45 { | 45 { |
46 const LChar* hexDigits = Internal::hexDigitsForMode(mode); | 46 const LChar* hexDigits = Internal::hexDigitsForMode(mode); |
47 destination.append(hexDigits[byte >> 4]); | 47 destination.append(hexDigits[byte >> 4]); |
48 destination.append(hexDigits[byte & 0xF]); | 48 destination.append(hexDigits[byte & 0xF]); |
49 } | 49 } |
50 | 50 |
51 template<typename T> | 51 template<typename T> |
52 inline void placeByteAsHex(unsigned char byte, T& destination, HexConversionMode
mode = Uppercase) | |
53 { | |
54 const LChar* hexDigits = Internal::hexDigitsForMode(mode); | |
55 *destination++ = hexDigits[byte >> 4]; | |
56 *destination++ = hexDigits[byte & 0xF]; | |
57 } | |
58 | |
59 template<typename T> | |
60 inline void appendUnsignedAsHex(unsigned number, T& destination, HexConversionMo
de mode = Uppercase) | 52 inline void appendUnsignedAsHex(unsigned number, T& destination, HexConversionMo
de mode = Uppercase) |
61 { | 53 { |
62 const LChar* hexDigits = Internal::hexDigitsForMode(mode); | 54 const LChar* hexDigits = Internal::hexDigitsForMode(mode); |
63 Vector<LChar, 8> result; | 55 Vector<LChar, 8> result; |
64 do { | 56 do { |
65 result.prepend(hexDigits[number % 16]); | 57 result.prepend(hexDigits[number % 16]); |
66 number >>= 4; | 58 number >>= 4; |
67 } while (number > 0); | 59 } while (number > 0); |
68 | 60 |
69 destination.append(result.data(), result.size()); | 61 destination.append(result.data(), result.size()); |
(...skipping 14 matching lines...) Expand all Loading... |
84 | 76 |
85 ASSERT(result.size() == desiredDigits); | 77 ASSERT(result.size() == desiredDigits); |
86 destination.append(result.data(), result.size()); | 78 destination.append(result.data(), result.size()); |
87 } | 79 } |
88 | 80 |
89 } // namespace WTF | 81 } // namespace WTF |
90 | 82 |
91 using WTF::appendByteAsHex; | 83 using WTF::appendByteAsHex; |
92 using WTF::appendUnsignedAsHex; | 84 using WTF::appendUnsignedAsHex; |
93 using WTF::appendUnsignedAsHexFixedSize; | 85 using WTF::appendUnsignedAsHexFixedSize; |
94 using WTF::placeByteAsHex; | |
95 using WTF::Lowercase; | 86 using WTF::Lowercase; |
96 | 87 |
97 #endif // HexNumber_h | 88 #endif // HexNumber_h |
OLD | NEW |