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 placeByteAsHexCompressIfPossible(unsigned char byte, T& destination,
unsigned& index, HexConversionMode mode = Uppercase) | |
53 { | |
54 const LChar* hexDigits = Internal::hexDigitsForMode(mode); | |
55 if (byte >= 0x10) | |
56 destination[index++] = hexDigits[byte >> 4]; | |
57 destination[index++] = hexDigits[byte & 0xF]; | |
58 } | |
59 | |
60 template<typename T> | |
61 inline void placeByteAsHex(unsigned char byte, T& destination, HexConversionMode
mode = Uppercase) | 52 inline void placeByteAsHex(unsigned char byte, T& destination, HexConversionMode
mode = Uppercase) |
62 { | 53 { |
63 const LChar* hexDigits = Internal::hexDigitsForMode(mode); | 54 const LChar* hexDigits = Internal::hexDigitsForMode(mode); |
64 *destination++ = hexDigits[byte >> 4]; | 55 *destination++ = hexDigits[byte >> 4]; |
65 *destination++ = hexDigits[byte & 0xF]; | 56 *destination++ = hexDigits[byte & 0xF]; |
66 } | 57 } |
67 | 58 |
68 template<typename T> | 59 template<typename T> |
69 inline void appendUnsignedAsHex(unsigned number, T& destination, HexConversionMo
de mode = Uppercase) | 60 inline void appendUnsignedAsHex(unsigned number, T& destination, HexConversionMo
de mode = Uppercase) |
70 { | 61 { |
(...skipping 23 matching lines...) Expand all Loading... |
94 ASSERT(result.size() == desiredDigits); | 85 ASSERT(result.size() == desiredDigits); |
95 destination.append(result.data(), result.size()); | 86 destination.append(result.data(), result.size()); |
96 } | 87 } |
97 | 88 |
98 } // namespace WTF | 89 } // namespace WTF |
99 | 90 |
100 using WTF::appendByteAsHex; | 91 using WTF::appendByteAsHex; |
101 using WTF::appendUnsignedAsHex; | 92 using WTF::appendUnsignedAsHex; |
102 using WTF::appendUnsignedAsHexFixedSize; | 93 using WTF::appendUnsignedAsHexFixedSize; |
103 using WTF::placeByteAsHex; | 94 using WTF::placeByteAsHex; |
104 using WTF::placeByteAsHexCompressIfPossible; | |
105 using WTF::Lowercase; | 95 using WTF::Lowercase; |
106 | 96 |
107 #endif // HexNumber_h | 97 #endif // HexNumber_h |
OLD | NEW |