MCPcopy Create free account
hub / github.com/NazaraEngine/NazaraEngine / ParseHexadecimal

Function ParseHexadecimal

src/Nazara/Network/AlgorithmNetwork.cpp:54–76  ·  view source on GitHub ↗

! * \brief Parses a hexadecimal number * \return true If successful * * \param str C-string symbolizing the string to parse * \param number Optional argument to return the number parsed * \param endOfRead Optional argument to determine where parsing stopped */

Source from the content-addressed store, hash-verified

52 * \param endOfRead Optional argument to determine where parsing stopped
53 */
54 bool ParseHexadecimal(const char* str, unsigned int* number, const char** endOfRead)
55 {
56 const char* ptr = str;
57 unsigned int val = 0;
58 while ((*ptr >= '0' && *ptr <= '9') || ((*ptr & 0x5F) >= 'A' && (*ptr & 0x5F) <= 'F'))
59 {
60 val *= 16;
61 val += (*ptr > '9') ? ((*ptr & 0x5F) - 'A' + 10) : *ptr - '0';
62
63 ++ptr;
64 }
65
66 if (str == ptr)
67 return false;
68
69 if (number)
70 *number = val;
71
72 if (endOfRead)
73 *endOfRead = ptr;
74
75 return true;
76 }
77 }
78
79

Callers 1

ParseIPAddressFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected