|
@ -12,15 +12,15 @@ using klotski::BasicRanges; |
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
void short_code_enable() { |
|
|
void short_code_enable() noexcept { |
|
|
ShortCode::speed_up(ShortCode::NORMAL); |
|
|
ShortCode::speed_up(ShortCode::NORMAL); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void short_code_enable_fast() { |
|
|
void short_code_enable_fast() noexcept { |
|
|
ShortCode::speed_up(ShortCode::FAST); |
|
|
ShortCode::speed_up(ShortCode::FAST); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
bool is_short_code_available() { |
|
|
bool is_short_code_available() noexcept { |
|
|
if (BasicRanges::status() != BasicRanges::AVAILABLE) { |
|
|
if (BasicRanges::status() != BasicRanges::AVAILABLE) { |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
@ -28,7 +28,7 @@ bool is_short_code_available() { |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
bool is_short_code_available_fast() { |
|
|
bool is_short_code_available_fast() noexcept { |
|
|
if (AllCases::status() != AllCases::AVAILABLE) { |
|
|
if (AllCases::status() != AllCases::AVAILABLE) { |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
@ -38,21 +38,21 @@ bool is_short_code_available_fast() { |
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
bool raw_code_check(uint64_t raw_code) { |
|
|
bool raw_code_check(uint64_t raw_code) noexcept { |
|
|
return RawCode::check(raw_code); |
|
|
return RawCode::check(raw_code); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
bool short_code_check(uint32_t short_code) { |
|
|
bool short_code_check(uint32_t short_code) noexcept { |
|
|
return ShortCode::check(short_code); |
|
|
return ShortCode::check(short_code); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
bool common_code_check(uint64_t common_code) { |
|
|
bool common_code_check(uint64_t common_code) noexcept { |
|
|
return CommonCode::check(common_code); |
|
|
return CommonCode::check(common_code); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
bool raw_code_to_short_code(uint64_t raw_code, uint32_t *short_code) { |
|
|
bool raw_code_to_short_code(uint64_t raw_code, uint32_t *short_code) noexcept { |
|
|
if (!RawCode::check(raw_code)) { |
|
|
if (!RawCode::check(raw_code)) { |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
@ -62,7 +62,7 @@ bool raw_code_to_short_code(uint64_t raw_code, uint32_t *short_code) { |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
bool short_code_to_raw_code(uint32_t short_code, uint64_t *raw_code) { |
|
|
bool short_code_to_raw_code(uint32_t short_code, uint64_t *raw_code) noexcept { |
|
|
if (!ShortCode::check(short_code)) { |
|
|
if (!ShortCode::check(short_code)) { |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
@ -72,7 +72,7 @@ bool short_code_to_raw_code(uint32_t short_code, uint64_t *raw_code) { |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
bool raw_code_to_common_code(uint64_t raw_code, uint64_t *common_code) { |
|
|
bool raw_code_to_common_code(uint64_t raw_code, uint64_t *common_code) noexcept { |
|
|
if (!RawCode::check(raw_code)) { |
|
|
if (!RawCode::check(raw_code)) { |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
@ -82,7 +82,7 @@ bool raw_code_to_common_code(uint64_t raw_code, uint64_t *common_code) { |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
bool common_code_to_raw_code(uint64_t common_code, uint64_t *raw_code) { |
|
|
bool common_code_to_raw_code(uint64_t common_code, uint64_t *raw_code) noexcept { |
|
|
if (!CommonCode::check(common_code)) { |
|
|
if (!CommonCode::check(common_code)) { |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
@ -92,7 +92,7 @@ bool common_code_to_raw_code(uint64_t common_code, uint64_t *raw_code) { |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
bool short_code_to_common_code(uint32_t short_code, uint64_t *common_code) { |
|
|
bool short_code_to_common_code(uint32_t short_code, uint64_t *common_code) noexcept { |
|
|
if (!ShortCode::check(short_code)) { |
|
|
if (!ShortCode::check(short_code)) { |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
@ -102,7 +102,7 @@ bool short_code_to_common_code(uint32_t short_code, uint64_t *common_code) { |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
bool common_code_to_short_code(uint64_t common_code, uint32_t *short_code) { |
|
|
bool common_code_to_short_code(uint64_t common_code, uint32_t *short_code) noexcept { |
|
|
if (!CommonCode::check(common_code)) { |
|
|
if (!CommonCode::check(common_code)) { |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
@ -114,35 +114,35 @@ bool common_code_to_short_code(uint64_t common_code, uint32_t *short_code) { |
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
uint32_t raw_code_to_short_code_unsafe(uint64_t raw_code) { |
|
|
uint32_t raw_code_to_short_code_unsafe(uint64_t raw_code) noexcept { |
|
|
return RawCode::unsafe_create(raw_code) |
|
|
return RawCode::unsafe_create(raw_code) |
|
|
.to_common_code().to_short_code().unwrap(); |
|
|
.to_common_code().to_short_code().unwrap(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
uint64_t short_code_to_raw_code_unsafe(uint32_t short_code) { |
|
|
uint64_t short_code_to_raw_code_unsafe(uint32_t short_code) noexcept { |
|
|
return ShortCode::unsafe_create(short_code) |
|
|
return ShortCode::unsafe_create(short_code) |
|
|
.to_common_code().to_raw_code().unwrap(); |
|
|
.to_common_code().to_raw_code().unwrap(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
uint64_t raw_code_to_common_code_unsafe(uint64_t raw_code) { |
|
|
uint64_t raw_code_to_common_code_unsafe(uint64_t raw_code) noexcept { |
|
|
return RawCode::unsafe_create(raw_code).to_common_code().unwrap(); |
|
|
return RawCode::unsafe_create(raw_code).to_common_code().unwrap(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
uint64_t common_code_to_raw_code_unsafe(uint64_t common_code) { |
|
|
uint64_t common_code_to_raw_code_unsafe(uint64_t common_code) noexcept { |
|
|
return CommonCode::unsafe_create(common_code).to_raw_code().unwrap(); |
|
|
return CommonCode::unsafe_create(common_code).to_raw_code().unwrap(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
uint64_t short_code_to_common_code_unsafe(uint32_t short_code) { |
|
|
uint64_t short_code_to_common_code_unsafe(uint32_t short_code) noexcept { |
|
|
return ShortCode::unsafe_create(short_code).to_common_code().unwrap(); |
|
|
return ShortCode::unsafe_create(short_code).to_common_code().unwrap(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
uint32_t common_code_to_short_code_unsafe(uint64_t common_code) { |
|
|
uint32_t common_code_to_short_code_unsafe(uint64_t common_code) noexcept { |
|
|
return CommonCode::unsafe_create(common_code).to_short_code().unwrap(); |
|
|
return CommonCode::unsafe_create(common_code).to_short_code().unwrap(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
bool is_vertical_mirror(uint64_t raw_code, bool *result) { |
|
|
bool is_vertical_mirror(uint64_t raw_code, bool *result) noexcept { |
|
|
if (!RawCode::check(raw_code)) { |
|
|
if (!RawCode::check(raw_code)) { |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
@ -150,7 +150,7 @@ bool is_vertical_mirror(uint64_t raw_code, bool *result) { |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
bool is_horizontal_mirror(uint64_t raw_code, bool *result) { |
|
|
bool is_horizontal_mirror(uint64_t raw_code, bool *result) noexcept { |
|
|
if (!RawCode::check(raw_code)) { |
|
|
if (!RawCode::check(raw_code)) { |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
@ -158,7 +158,7 @@ bool is_horizontal_mirror(uint64_t raw_code, bool *result) { |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
bool to_vertical_mirror(uint64_t raw_code, uint64_t *result) { |
|
|
bool to_vertical_mirror(uint64_t raw_code, uint64_t *result) noexcept { |
|
|
if (!RawCode::check(raw_code)) { |
|
|
if (!RawCode::check(raw_code)) { |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
@ -166,7 +166,7 @@ bool to_vertical_mirror(uint64_t raw_code, uint64_t *result) { |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
bool to_horizontal_mirror(uint64_t raw_code, uint64_t *result) { |
|
|
bool to_horizontal_mirror(uint64_t raw_code, uint64_t *result) noexcept { |
|
|
if (!RawCode::check(raw_code)) { |
|
|
if (!RawCode::check(raw_code)) { |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
@ -176,19 +176,19 @@ bool to_horizontal_mirror(uint64_t raw_code, uint64_t *result) { |
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
bool is_vertical_mirror_unsafe(uint64_t raw_code) { |
|
|
bool is_vertical_mirror_unsafe(uint64_t raw_code) noexcept { |
|
|
return RawCode::unsafe_create(raw_code).is_vertical_mirror(); |
|
|
return RawCode::unsafe_create(raw_code).is_vertical_mirror(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
bool is_horizontal_mirror_unsafe(uint64_t raw_code) { |
|
|
bool is_horizontal_mirror_unsafe(uint64_t raw_code) noexcept { |
|
|
return RawCode::unsafe_create(raw_code).is_horizontal_mirror(); |
|
|
return RawCode::unsafe_create(raw_code).is_horizontal_mirror(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
uint64_t to_vertical_mirror_unsafe(uint64_t raw_code) { |
|
|
uint64_t to_vertical_mirror_unsafe(uint64_t raw_code) noexcept { |
|
|
return RawCode::unsafe_create(raw_code).to_vertical_mirror().unwrap(); |
|
|
return RawCode::unsafe_create(raw_code).to_vertical_mirror().unwrap(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
uint64_t to_horizontal_mirror_unsafe(uint64_t raw_code) { |
|
|
uint64_t to_horizontal_mirror_unsafe(uint64_t raw_code) noexcept { |
|
|
return RawCode::unsafe_create(raw_code).to_horizontal_mirror().unwrap(); |
|
|
return RawCode::unsafe_create(raw_code).to_horizontal_mirror().unwrap(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -196,7 +196,7 @@ uint64_t to_horizontal_mirror_unsafe(uint64_t raw_code) { |
|
|
|
|
|
|
|
|
const uint32_t SHORT_CODE_STR_SIZE = 6; |
|
|
const uint32_t SHORT_CODE_STR_SIZE = 6; |
|
|
|
|
|
|
|
|
bool short_code_to_string(uint32_t short_code, char short_code_str[]) { |
|
|
bool short_code_to_string(uint32_t short_code, char short_code_str[]) noexcept { |
|
|
if (!ShortCode::check(short_code)) { |
|
|
if (!ShortCode::check(short_code)) { |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
@ -205,7 +205,7 @@ bool short_code_to_string(uint32_t short_code, char short_code_str[]) { |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
bool short_code_from_string(const char short_code_str[], uint32_t *short_code) { |
|
|
bool short_code_from_string(const char short_code_str[], uint32_t *short_code) noexcept { |
|
|
try { |
|
|
try { |
|
|
*short_code = ShortCode::from_string(short_code_str).unwrap(); |
|
|
*short_code = ShortCode::from_string(short_code_str).unwrap(); |
|
|
} catch (...) { |
|
|
} catch (...) { |
|
@ -218,7 +218,7 @@ bool short_code_from_string(const char short_code_str[], uint32_t *short_code) { |
|
|
|
|
|
|
|
|
const uint32_t COMMON_CODE_STR_SIZE = 10; |
|
|
const uint32_t COMMON_CODE_STR_SIZE = 10; |
|
|
|
|
|
|
|
|
bool common_code_to_string(uint64_t common_code, char common_code_str[]) { |
|
|
bool common_code_to_string(uint64_t common_code, char common_code_str[]) noexcept { |
|
|
if (!CommonCode::check(common_code)) { |
|
|
if (!CommonCode::check(common_code)) { |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
@ -227,7 +227,7 @@ bool common_code_to_string(uint64_t common_code, char common_code_str[]) { |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
bool common_code_to_string_shorten(uint64_t common_code, char common_code_str[]) { |
|
|
bool common_code_to_string_shorten(uint64_t common_code, char common_code_str[]) noexcept { |
|
|
if (!CommonCode::check(common_code)) { |
|
|
if (!CommonCode::check(common_code)) { |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
@ -236,7 +236,7 @@ bool common_code_to_string_shorten(uint64_t common_code, char common_code_str[]) |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
bool common_code_from_string(const char common_code_str[], uint64_t *common_code) { |
|
|
bool common_code_from_string(const char common_code_str[], uint64_t *common_code) noexcept { |
|
|
try { |
|
|
try { |
|
|
*common_code = CommonCode::from_string(common_code_str).unwrap(); |
|
|
*common_code = CommonCode::from_string(common_code_str).unwrap(); |
|
|
} catch (...) { |
|
|
} catch (...) { |
|
|