//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
// DataHelpers.SQL satellite library | Author: Sergei Y.Kitáev
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
using System;
using System.Data.SqlClient;
using u = user_rtx;

namespace DataHelpers.SQL {

partial class HSPOutputReader {
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

/// <exception cref="InvalidOperationException" />
/// <exception cref="InvalidCastException" />
/// <exception cref="HDatabaseException" />
[u.async_local]
public static T? VAL_N<T>( SqlParameter parameter )
where T: struct =>
   HSP.GetOutputParameterValue<T?>( parameter );

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

/// <exception cref="InvalidOperationException" />
/// <exception cref="InvalidCastException" />
/// <exception cref="HDatabaseException" />
[u.async_local]
public static string? STR_N( SqlParameter parameter ) =>
   GET<string?>( parameter, true );
/// <exception cref="InvalidOperationException" />
/// <exception cref="InvalidCastException" />
/// <exception cref="HDatabaseException" />
[u.async_local]
public static string? NS_N( SqlParameter parameter )
{
   string? str = GET<string?>( parameter, true );
   return str!=null ? HDbQuery.NormalizeStrValue( str ) : null;
}

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

/// <exception cref="InvalidOperationException" />
/// <exception cref="InvalidCastException" />
/// <exception cref="HDatabaseException" />
[u.async_local]
public static int? INT_N( SqlParameter parameter ) =>
   VAL_N<int>( parameter );
/// <exception cref="InvalidOperationException" />
/// <exception cref="InvalidCastException" />
/// <exception cref="HDatabaseException" />
[u.async_local]
public static long? BIGINT_N( SqlParameter parameter ) =>
   VAL_N<long>( parameter );

/// <exception cref="InvalidOperationException" />
/// <exception cref="InvalidCastException" />
/// <exception cref="HDatabaseException" />
[u.async_local]
public static double? FP_N( SqlParameter parameter ) =>
   VAL_N<double>( parameter );

/// <exception cref="InvalidOperationException" />
/// <exception cref="InvalidCastException" />
/// <exception cref="HDatabaseException" />
[u.async_local]
public static decimal? DEC_N( SqlParameter parameter ) =>
   VAL_N<decimal>( parameter );

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

/// <exception cref="InvalidOperationException" />
/// <exception cref="InvalidCastException" />
/// <exception cref="HDatabaseException" />
[u.async_local]
public static bool? BOOL_N( SqlParameter parameter ) =>
   VAL_N<bool>( parameter );

/// <exception cref="InvalidOperationException" />
/// <exception cref="InvalidCastException" />
/// <exception cref="HDatabaseException" />
[u.async_local]
public static DateTime? DT_N( SqlParameter parameter ) =>
   VAL_N<DateTime>( parameter );
/// <exception cref="InvalidOperationException" />
/// <exception cref="InvalidCastException" />
/// <exception cref="HDatabaseException" />
[u.async_local]
public static DateTime? UTC_N( SqlParameter parameter )
{
   var dt = VAL_N<DateTime>( parameter );
   return dt.HasValue ? (DateTime?)dt.Value.ToUniversalTime() : null;
}

/// <exception cref="InvalidOperationException" />
/// <exception cref="InvalidCastException" />
/// <exception cref="HDatabaseException" />
[u.async_local]
public static Guid? GUID_N( SqlParameter parameter ) =>
   VAL_N<Guid>( parameter );

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

/// <exception cref="InvalidOperationException" />
/// <exception cref="InvalidCastException" />
/// <exception cref="HDatabaseException" />
[u.async_local]
public static byte[]? BINARY_N( SqlParameter parameter ) =>
   GET<byte[]?>( parameter, true );

//--------------------------------------------------------------------------------------------------
/*
/// <exception cref="InvalidOperationException" />
/// <exception cref="InvalidCastException" />
/// <exception cref="HDatabaseException" />
[u.async_local]
public static ? _N( SqlParameter parameter ) =>
   VAL_N<>( parameter );
   GET<?>( parameter );
*/
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
} // HSPOutputReader

} // DataHelpers.SQL
