| 1932 | String String::createHex (uint64 n) { return hexToString (n); } |
| 1933 | |
| 1934 | String String::toHexString (const void* const d, const int size, const int groupSize) |
| 1935 | { |
| 1936 | if (size <= 0) |
| 1937 | return {}; |
| 1938 | |
| 1939 | int numChars = (size * 2) + 2; |
| 1940 | if (groupSize > 0) |
| 1941 | numChars += size / groupSize; |
| 1942 | |
| 1943 | String s (PreallocationBytes ((size_t) numChars * sizeof (CharPointerType::CharType))); |
| 1944 | |
| 1945 | auto* data = static_cast<const unsigned char*> (d); |
| 1946 | auto dest = s.text; |
| 1947 | |
| 1948 | for (int i = 0; i < size; ++i) |
| 1949 | { |
| 1950 | const unsigned char nextByte = *data++; |
| 1951 | dest.write ((juce_wchar) hexDigits [nextByte >> 4]); |
| 1952 | dest.write ((juce_wchar) hexDigits [nextByte & 0xf]); |
| 1953 | |
| 1954 | if (groupSize > 0 && (i % groupSize) == (groupSize - 1) && i < (size - 1)) |
| 1955 | dest.write ((juce_wchar) ' '); |
| 1956 | } |
| 1957 | |
| 1958 | dest.writeNull(); |
| 1959 | return s; |
| 1960 | } |
| 1961 | |
| 1962 | int String::getHexValue32() const noexcept { return CharacterFunctions::HexParser<int> ::parse (text); } |
| 1963 | int64 String::getHexValue64() const noexcept { return CharacterFunctions::HexParser<int64>::parse (text); } |
no test coverage detected