MCPcopy Create free account
hub / github.com/VerySleepy/verysleepy / hexStringTo64UInt

Function hexStringTo64UInt

src/utils/stringutils.cpp:68–107  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

66}
67
68unsigned long long hexStringTo64UInt(const std::wstring& s)
69{
70 assert(sizeof(unsigned long long) == 8);
71
72 if(s.size() < 3)
73 return 0;//too short, parse error
74 else if(s.size() > 18)
75 return 0;//too long, parse error
76
77 unsigned int i = 0;
78 unsigned long long x = 0;
79 unsigned int nibble;
80
81 //eat '0'
82 if(s[i++] != '0')
83 return 0;//parse error
84
85 //eat 'x'
86 if(s[i++] != 'x')
87 return 0;//parse error
88
89 while(i < s.size())
90 {
91 if(s[i] >= '0' && s[i] <= '9')
92 nibble = s[i] - '0';
93 else if(s[i] >= 'a' && s[i] <= 'f')
94 nibble = s[i] - 'a' + 10;
95 else if(s[i] >= 'A' && s[i] <= 'F')
96 nibble = s[i] - 'A' + 10;
97 else
98 return 0;//parse error
99
100 x <<= 4;
101 x |= nibble;//set lower 4 bits to nibble
102
103 i++;
104 }
105
106 return x;
107}
108
109
110/*const std::wstring toHexString(unsigned int i)

Callers 3

loadSymbolsMethod · 0.85
loadCallstacksMethod · 0.85
loadIpCountsMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected