2020-07-10 07:30:10 +00:00
# include "../src/Random.hpp"
2020-07-19 09:08:05 +00:00
# include "Core.hpp"
2020-07-10 07:30:10 +00:00
2020-09-25 10:31:37 +00:00
/// @file
/// @brief Constructs a random class.
2020-07-19 08:44:54 +00:00
export ArbUt : : Random * Arbutils_Random_Construct ( ) { return new ArbUt : : Random ( ) ; }
2020-09-25 10:31:37 +00:00
/// @brief Constructs a random class with a specific seed.
2020-07-19 08:44:54 +00:00
export ArbUt : : Random * Arbutils_Random_ConstructWithSeed ( uint_fast32_t seed ) { return new ArbUt : : Random ( seed ) ; }
2020-07-10 07:30:10 +00:00
2020-09-25 10:31:37 +00:00
/// @brief Call the destructor on a random object.
2020-07-19 08:44:54 +00:00
export void Arbutils_Random_Destruct ( ArbUt : : Random * p ) { delete p ; }
2020-07-10 07:30:10 +00:00
2020-09-25 10:31:37 +00:00
/// @brief Returns a random float between 0.0 and 1.0 using a random object.
2020-07-19 08:44:54 +00:00
export float Arbutils_Random_GetFloat ( ArbUt : : Random * p ) { return p - > GetFloat ( ) ; }
2020-09-25 10:31:37 +00:00
/// @brief Returns a random double between 0.0 and 1.0 using a random object.
2020-07-19 08:44:54 +00:00
export double Arbutils_Random_GetDouble ( ArbUt : : Random * p ) { return p - > GetDouble ( ) ; }
2020-09-25 10:31:37 +00:00
/// @brief Returns a random a random 32 bit integer using a random object.
2022-03-23 11:56:12 +00:00
export i32 Arbutils_Random_Get ( ArbUt : : Random * p ) { return p - > Get ( ) ; }
2020-09-25 10:31:37 +00:00
/// @brief Gets a random 32 bit integer with a given max. Returns a status code where 0 is Ok, and passes the output to the out parameter.
2022-03-23 11:56:12 +00:00
export u8 Arbutils_Random_GetWithMax ( ArbUt : : Random * p , i32 max , i32 & out ) { Try ( out = p - > Get ( max ) ; ) }
2020-09-25 10:31:37 +00:00
/// @brief Gets a random 32 bit integer with a given min and max. Returns a status code where 0 is Ok, and passes the output to the out parameter.
2022-03-23 11:56:12 +00:00
export u8 Arbutils_Random_GetInLimits ( ArbUt : : Random * p , i32 min , i32 max , i32 & out ) {
2020-07-19 09:08:05 +00:00
Try ( out = p - > Get ( min , max ) ; )
}
2020-09-25 10:31:37 +00:00
/// @brief Returns a random a random 32 bit unsigned integer using a random object.
2022-03-23 11:56:12 +00:00
export u32 Arbutils_Random_GetUnsigned ( ArbUt : : Random * p ) { return p - > GetUnsigned ( ) ; }
2020-09-25 10:31:37 +00:00
/// @brief Gets a random 32 bit unsigned integer with a given max. Returns a status code where 0 is Ok, and passes the output to the out parameter.
2022-03-23 11:56:12 +00:00
export u8 Arbutils_Random_GetUnsignedWithMax ( ArbUt : : Random * p , u32 max , u32 & out ) {
2020-07-19 09:08:05 +00:00
Try ( out = p - > GetUnsigned ( max ) ; )
}
2020-09-25 10:31:37 +00:00
/// @brief Gets a random 32 bit unsigned integer with a given min and max. Returns a status code where 0 is Ok, and passes the output to the out parameter.
2022-03-23 11:56:12 +00:00
export u8 Arbutils_Random_GetUnsignedInLimits ( ArbUt : : Random * p , u32 min , u32 max , u32 & out ) {
2020-07-19 09:08:05 +00:00
Try ( out = p - > GetUnsigned ( min , max ) ; )
2020-07-10 07:30:10 +00:00
}
2020-09-25 10:31:37 +00:00
/// @brief Returns the seed of the random object.
2020-07-19 08:44:54 +00:00
export uint_fast32_t Arbutils_Random_GetSeed ( ArbUt : : Random * p ) { return p - > GetSeed ( ) ; }