//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
// CommonHelpers satellite library | Author: Sergei Y.Kitáev
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
using System;
using System.Reflection;
using System.Globalization;

#if !WASM
namespace CommonHelpers {
#else
namespace CommonHelpers.WASM {
#endif

//**************************************************************************************************
partial class HNumParser {
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

public static bool TryParse<T>( string src, NumberStyles styles,
                                out T dst, out HParseValueException e ) where T: struct
   { return TryParse(src,styles,NumberFormatInfo.CurrentInfo,out dst,out e); }
public static bool TryParse<T>( string src, NumberStyles styles, T def,
                                out T dst, out HParseValueException e ) where T: struct
   { return TryParse(src,styles,NumberFormatInfo.CurrentInfo,def,out dst,out e); }

public static bool TryParse<T>( string src, NumberStyles styles, IFormatProvider provider,
                                out T dst, out HParseValueException e ) where T: struct
   { return HValueParser.TryParse(src,new object[]{styles,provider},out dst,out e); }
public static bool TryParse<T>( string src, NumberStyles styles,
                                IFormatProvider provider, T def,
                                out T dst, out HParseValueException e ) where T: struct
   { return HValueParser.TryParse(src,new object[]{styles,provider},def,out dst,out e); }

//--------------------------------------------------------------------------------------------------

public static bool TryParseInvariant<T>( string src, out T dst,
                                         out HParseValueException e ) where T: struct
   { return HValueParser.TryParse(src,NumberFormatInfo.InvariantInfo,out dst,out e); }
public static bool TryParseInvariant<T>( string src, T def, out T dst,
                                         out HParseValueException e ) where T: struct
   { return HValueParser.TryParse(src,NumberFormatInfo.InvariantInfo,def,out dst,out e); }

public static bool TryParseInvariant<T>( string src, NumberStyles styles, out T dst,
                                         out HParseValueException e ) where T: struct
   { return TryParse(src,styles,NumberFormatInfo.InvariantInfo,out dst,out e); }
public static bool TryParseInvariant<T>( string src, NumberStyles styles, T def, out T dst,
                                         out HParseValueException e ) where T: struct
   { return TryParse(src,styles,NumberFormatInfo.InvariantInfo,def,out dst,out e); }

//==================================================================================================

public static bool TryParseEx<T>( string src, NumberStyles styles,
                                  [HOptional] IFormatProvider provider, T? def,
                                  out T dst, out HParseValueException e ) where T: struct
{
   return HValueParser.TryParseWithParamsEx( src,
      provider!=null ? new object[]{ styles, provider } : new object[]{ styles },
      def, out dst, out e );
}

public static bool TryParseInvariantEx<T>( string src, NumberStyles styles, T? def,
                                           out T dst, out HParseValueException e ) where T: struct
{
   return HValueParser.TryParseWithParamsEx( src,
      new object[]{ styles, (IFormatProvider)null },
      def, out dst, out e );
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
} // HNumParser
//**************************************************************************************************

} // CommonHelpers (.WASM)
