//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
// UserRTX.NET satellite library | Author: Sergei Y.Kitáev
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
using System;

#if !WASM
namespace user_rtx { using u = user_rtx;
#else
namespace user_rtx.wasm { using u = user_rtx.wasm;
#endif

static partial class enum_val {
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

public static bool TryParse<EnumType>( out EnumType value, string src, EnumType? def=null )
where EnumType: struct =>
   TryParseX<EnumType>( out value, src, def, 0 );

public static bool TryParse<EnumType>( out EnumType value,
                                       string src, char? separator,
                                       EnumType? def=null )
where EnumType: struct =>
   TryParseX<EnumType>( out value, src, separator, def, 0 );

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

public static bool TryParseX<EnumType>( out EnumType value, string src, EnumType? def,
                                        u.enum_parse_options options )
where EnumType: struct
{
   try {
      value = ParseX( src, def, options );
   }
   catch ( Exception ) {
      value = default;
      return false;
   }
   return true;
}

public static bool TryParseX<EnumType>( out EnumType value,
                                        string src, char? separator, EnumType? def,
                                        u.enum_parse_options options )
where EnumType: struct
{
   try {
      value = ParseX( src, separator, def, options );
   }
   catch ( Exception ) {
      value = default;
      return false;
   }
   return true;
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
} // enum_val

} // user_rtx (.wasm)
