MCPcopy Create free account
hub / github.com/HaxeFoundation/hxcpp / __hxcpp_parse_int

Function __hxcpp_parse_int

src/hx/StdLibs.cpp:725–753  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

723}
724
725Dynamic __hxcpp_parse_int(const String &inString)
726{
727 if (!inString.raw_ptr())
728 return null();
729 hx::strbuf buf;
730 const char *str = inString.utf8_str(&buf);
731
732 // On the first non space char check to see if we've got a hex string
733 while (isspace(*str)) ++str;
734 bool isHex = is_hex_string(str, strlen(str));
735 char *end = 0;
736 long result;
737 if (isHex)
738 {
739 bool neg = str[0] == '-';
740 if (neg) str++;
741 result = strtoul(str,&end,16);
742 if (neg) result = -result;
743 }
744 else
745 result = strtol(str,&end,10);
746 #ifdef HX_WINDOWS
747 if (str==end && !isHex)
748 #else
749 if (str==end)
750 #endif
751 return null();
752 return (int)result;
753}
754
755
756double __hxcpp_parse_substr_float(const String &inString,int start, int length)

Callers

nothing calls this directly

Calls 3

is_hex_stringFunction · 0.85
utf8_strMethod · 0.80
nullClass · 0.50

Tested by

no test coverage detected