mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-16 07:14:09 +02:00
Rework hex parsing flags. New 'Hex' flag, 'AllowHexSpecifier' allows hex
This commit is contained in:
parent
4ab140a4f4
commit
269716c0d4
11 changed files with 23 additions and 22 deletions
|
@ -506,11 +506,11 @@ namespace Beefy.utils
|
|||
case typeof(Int64): return (.)(int64)val;
|
||||
case typeof(Int): return (.)(int)val;
|
||||
case typeof(String):
|
||||
if (int32.Parse((String)val) case .Ok(var fVal))
|
||||
if (int32.Parse((String)val, .AllowHexSpecifier) case .Ok(var fVal))
|
||||
return (.)fVal;
|
||||
return defaultVal;
|
||||
case typeof(StringView):
|
||||
if (int32.Parse((StringView)val) case .Ok(var fVal))
|
||||
if (int32.Parse((StringView)val, .AllowHexSpecifier) case .Ok(var fVal))
|
||||
return (.)fVal;
|
||||
return defaultVal;
|
||||
default: return defaultVal;
|
||||
|
@ -529,11 +529,11 @@ namespace Beefy.utils
|
|||
case typeof(Int64): return (.)(int64)val;
|
||||
case typeof(Int): return (.)(int)val;
|
||||
case typeof(String):
|
||||
if (int64.Parse((String)val) case .Ok(var parsedVal))
|
||||
if (int64.Parse((String)val, .AllowHexSpecifier) case .Ok(var parsedVal))
|
||||
return (.)parsedVal;
|
||||
return defaultVal;
|
||||
case typeof(StringView):
|
||||
if (int64.Parse((StringView)val) case .Ok(var parsedVal))
|
||||
if (int64.Parse((StringView)val, .AllowHexSpecifier) case .Ok(var parsedVal))
|
||||
return (.)parsedVal;
|
||||
return defaultVal;
|
||||
default: return defaultVal;
|
||||
|
@ -552,11 +552,11 @@ namespace Beefy.utils
|
|||
case typeof(Int64): return (.)(int64)val;
|
||||
case typeof(Int): return (.)(int)val;
|
||||
case typeof(String):
|
||||
if (int64.Parse((String)val) case .Ok(var parsedVal))
|
||||
if (int64.Parse((String)val, .AllowHexSpecifier) case .Ok(var parsedVal))
|
||||
return (.)parsedVal;
|
||||
return defaultVal;
|
||||
case typeof(StringView):
|
||||
if (int64.Parse((StringView)val) case .Ok(var parsedVal))
|
||||
if (int64.Parse((StringView)val, .AllowHexSpecifier) case .Ok(var parsedVal))
|
||||
return (.)parsedVal;
|
||||
return defaultVal;
|
||||
default: return defaultVal;
|
||||
|
@ -1841,7 +1841,7 @@ namespace Beefy.utils
|
|||
}
|
||||
else
|
||||
{
|
||||
var parseVal = int64.Parse(strView);
|
||||
var parseVal = int64.Parse(strView, .AllowHexSpecifier);
|
||||
if (parseVal case .Ok(var intVal))
|
||||
aValue = new:mBumpAllocator box intVal;
|
||||
else
|
||||
|
@ -2242,7 +2242,7 @@ namespace Beefy.utils
|
|||
}
|
||||
}
|
||||
|
||||
switch (Int64.Parse(value))
|
||||
switch (Int64.Parse(value, .AllowHexSpecifier))
|
||||
{
|
||||
case .Err: return null;
|
||||
case .Ok(let num): return new:mBumpAllocator box num;
|
||||
|
|
|
@ -692,11 +692,11 @@ namespace System.Globalization {
|
|||
}
|
||||
|
||||
// private const NumberStyles InvalidNumberStyles = unchecked((NumberStyles) 0xFFFFFC00);
|
||||
private const NumberStyles InvalidNumberStyles = ~(NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite
|
||||
| NumberStyles.AllowLeadingSign | NumberStyles.AllowTrailingSign
|
||||
| NumberStyles.AllowParentheses | NumberStyles.AllowDecimalPoint
|
||||
| NumberStyles.AllowThousands | NumberStyles.AllowExponent
|
||||
| NumberStyles.AllowCurrencySymbol | NumberStyles.AllowHexSpecifier);
|
||||
private const NumberStyles InvalidNumberStyles = ~(.AllowLeadingWhite | .AllowTrailingWhite
|
||||
| .AllowLeadingSign | .AllowTrailingSign
|
||||
| .AllowParentheses | .AllowDecimalPoint
|
||||
| .AllowThousands | .AllowExponent
|
||||
| .AllowCurrencySymbol | .AllowHexSpecifier | .Hex);
|
||||
|
||||
/*internal static void ValidateParseStyleInteger(NumberStyles style) {
|
||||
// Check for undefined flags
|
||||
|
|
|
@ -45,10 +45,11 @@ namespace System.Globalization
|
|||
AllowHexSpecifier = 0x00000200, //Allow specifiying hexadecimal.
|
||||
//Common uses. These represent some of the most common combinations of these flags.
|
||||
|
||||
Hex = 0x00000400,
|
||||
|
||||
Integer = AllowLeadingWhite | AllowTrailingWhite | AllowLeadingSign,
|
||||
|
||||
HexNumber = AllowLeadingWhite | AllowTrailingWhite | AllowHexSpecifier,
|
||||
HexNumber = AllowLeadingWhite | AllowTrailingWhite | AllowHexSpecifier | Hex,
|
||||
|
||||
Number = AllowLeadingWhite | AllowTrailingWhite | AllowLeadingSign | AllowTrailingSign |
|
||||
AllowDecimalPoint | AllowThousands,
|
||||
|
|
|
@ -85,7 +85,7 @@ namespace System
|
|||
bool isNeg = false;
|
||||
int16 result = 0;
|
||||
|
||||
int16 radix = style.HasFlag(.AllowHexSpecifier) ? 0x10 : 10;
|
||||
int16 radix = style.HasFlag(.Hex) ? 0x10 : 10;
|
||||
|
||||
for (int32 i = 0; i < val.Length; i++)
|
||||
{
|
||||
|
|
|
@ -134,7 +134,7 @@ namespace System
|
|||
bool isNeg = false;
|
||||
int32 result = 0;
|
||||
|
||||
int32 radix = style.HasFlag(.AllowHexSpecifier) ? 0x10 : 10;
|
||||
int32 radix = style.HasFlag(.Hex) ? 0x10 : 10;
|
||||
|
||||
for (int32 i = 0; i < val.Length; i++)
|
||||
{
|
||||
|
|
|
@ -115,7 +115,7 @@ namespace System
|
|||
bool isNeg = false;
|
||||
int64 result = 0;
|
||||
|
||||
int64 radix = style.HasFlag(.AllowHexSpecifier) ? 0x10 : 10;
|
||||
int64 radix = style.HasFlag(.Hex) ? 0x10 : 10;
|
||||
|
||||
for (int32 i = 0; i < val.Length; i++)
|
||||
{
|
||||
|
|
|
@ -85,7 +85,7 @@ namespace System
|
|||
bool isNeg = false;
|
||||
int8 result = 0;
|
||||
|
||||
int8 radix = style.HasFlag(.AllowHexSpecifier) ? 0x10 : 10;
|
||||
int8 radix = style.HasFlag(.Hex) ? 0x10 : 10;
|
||||
|
||||
for (int32 i = 0; i < val.Length; i++)
|
||||
{
|
||||
|
|
|
@ -85,7 +85,7 @@ namespace System
|
|||
uint16 result = 0;
|
||||
uint16 prevResult = 0;
|
||||
|
||||
uint16 radix = style.HasFlag(.AllowHexSpecifier) ? 0x10 : 10;
|
||||
uint16 radix = style.HasFlag(.Hex) ? 0x10 : 10;
|
||||
|
||||
for (int32 i = 0; i < val.Length; i++)
|
||||
{
|
||||
|
|
|
@ -113,7 +113,7 @@ namespace System
|
|||
uint32 result = 0;
|
||||
uint32 prevResult = 0;
|
||||
|
||||
uint32 radix = style.HasFlag(.AllowHexSpecifier) ? 0x10 : 10;
|
||||
uint32 radix = style.HasFlag(.Hex) ? 0x10 : 10;
|
||||
|
||||
for (int32 i = 0; i < val.Length; i++)
|
||||
{
|
||||
|
|
|
@ -97,7 +97,7 @@ namespace System
|
|||
uint64 result = 0;
|
||||
uint64 prevResult = 0;
|
||||
|
||||
uint64 radix = style.HasFlag(.AllowHexSpecifier) ? 0x10 : 10;
|
||||
uint64 radix = style.HasFlag(.Hex) ? 0x10 : 10;
|
||||
|
||||
for (int32 i = 0; i < val.Length; i++)
|
||||
{
|
||||
|
|
|
@ -85,7 +85,7 @@ namespace System
|
|||
uint8 result = 0;
|
||||
uint8 prevResult = 0;
|
||||
|
||||
uint8 radix = style.HasFlag(.AllowHexSpecifier) ? 0x10 : 10;
|
||||
uint8 radix = style.HasFlag(.Hex) ? 0x10 : 10;
|
||||
|
||||
for (int32 i = 0; i < val.Length; i++)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue