MCPcopy Create free account
hub / github.com/DaedalusX64/daedalus / ParseU32

Function ParseU32

Source/Utility/StringUtil.cpp:60–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58}
59
60u32 ParseU32(ConstStringRef str, u32 base)
61{
62 u32 val = 0;
63 for (const char * p = str.Begin; p < str.End; ++p)
64 {
65 char c = *p;
66
67 // Bail as soon as we see a non-decimal value.
68 u32 digit = base;
69 if (c >= '0' && c <= '9')
70 digit = c - '0';
71 else if (c >= 'a' && c <= 'z')
72 digit = 10 + (c - 'a');
73 else if (c >= 'A' && c <= 'Z')
74 digit = 10 + (c - 'A');
75
76 if (digit >= base)
77 break;
78
79 val *= base;
80 val += c - '0';
81 }
82
83 return val;
84}
85
86// void Print(const std::vector<ConstStringRef> & pieces)
87// {

Callers 1

DLDebugHandlerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected