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

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

//**************************************************************************************************
public static partial class HType {
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

public static bool IsStdValue(Type type)
{
   HArgChecking.VerifyNotNull(type);

   return Type.GetTypeCode(type)!=TypeCode.Object;
}

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

public static bool IsIntegral(Type type)
{
   HArgChecking.VerifyNotNull(type);

   return HOps.IsOneOf( type,
      typeof(SByte), typeof(Int16), typeof(Int32), typeof(Int64),
      typeof(Byte), typeof(UInt16), typeof(UInt32), typeof(UInt64),
      typeof(Char) );
}

public static bool IsIntegralNumber(Type type)
{
   HArgChecking.VerifyNotNull(type);

   return IsIntegral(type) && type!=typeof(Char);
}

public static bool IsIntegralSignedNumber(Type type)
{
   HArgChecking.VerifyNotNull(type);

   return HOps.IsOneOf( type,
      typeof(SByte), typeof(Int16), typeof(Int32), typeof(Int64) );
}

public static bool IsIntegralUnsignedNumber(Type type)
{
   HArgChecking.VerifyNotNull(type);

   return HOps.IsOneOf( type,
      typeof(Byte), typeof(UInt16), typeof(UInt32), typeof(UInt64) );
}

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

public static bool IsStdNumber(Type type)
{
   HArgChecking.VerifyNotNull(type);

   return IsStdSignedNumber(type) || IsStdUnsignedNumber(type);
}

public static bool IsStdSignedNumber(Type type)
{
   HArgChecking.VerifyNotNull(type);
   return
      IsIntegralSignedNumber(type) ||
      HOps.IsOneOf( type,
         typeof(Single), typeof(Double), typeof(Decimal) );
}

public static bool IsStdUnsignedNumber(Type type)
{
   return IsIntegralUnsignedNumber(type);
}

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

public static bool IsNullable(Type type)
{
   HArgChecking.VerifyNotNull(type);
   return type.IsGenericType && type.GetGenericTypeDefinition().Equals( typeof(Nullable<>) );
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
} // HType
//**************************************************************************************************

} // CommonHelpers (.WASM)
