//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
// 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 HValueParser {
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

public static bool TryParse<T>( string src, [HOptional] object[] additionalParams,
                                out T dst ) where T: struct
   { return TryParseEx(src,additionalParams,null,out dst); }

public static bool TryParse<T>( string src, [HOptional] object[] additionalParams, T def,
                                out T dst ) where T: struct
   { return TryParseEx(src,additionalParams,(T?)def,out dst); }

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

public static bool TryParse<T>(string src,out T dst) where T: struct
   { return TryParse(src,(object[])null,out dst); }
public static bool TryParse<T>(string src,T def,out T dst) where T: struct
   { return TryParse(src,(object[])null,def,out dst); }

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

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

public static bool TryParseInvariant<T>(string src,out T dst) where T: struct
   { return TryParse(src,new object[]{(IFormatProvider)null},out dst); }
public static bool TryParseInvariant<T>(string src,T def,out T dst) where T: struct
   { return TryParse(src,new object[]{(IFormatProvider)null},def,out dst); }

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

internal static bool TryParseEx<T>( string src,
                                    [HOptional] object[] additionalParams,
                                    T? def, out T dst )
   where T: struct
{
   HParseValueException e;
   return TryParseEx(src,additionalParams,def,out dst,out e);
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
} // HValueParser
//**************************************************************************************************

} // CommonHelpers (.WASM)
