From 4683ee3d32ea076af92be7573d1b3a05faab2a5b Mon Sep 17 00:00:00 2001 From: Dnomd343 Date: Mon, 9 Jan 2023 21:26:38 +0800 Subject: [PATCH] feat: RawCode framework --- src/CMakeLists.txt | 6 ++++++ src/main.cc | 13 +++++++++---- src/raw_code/CMakeLists.txt | 4 ++++ src/raw_code/raw_code.cc | 5 +++++ src/raw_code/raw_code.h | 19 +++++++++++++++++++ 5 files changed, 43 insertions(+), 4 deletions(-) create mode 100644 src/raw_code/CMakeLists.txt create mode 100644 src/raw_code/raw_code.cc create mode 100644 src/raw_code/raw_code.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e0ec603..d214276 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -2,16 +2,22 @@ cmake_minimum_required(VERSION 3.0) include_directories(common) include_directories(all_cases) + +include_directories(raw_code) include_directories(short_code) include_directories(common_code) add_subdirectory(common) add_subdirectory(all_cases) + +add_subdirectory(raw_code) add_subdirectory(short_code) add_subdirectory(common_code) add_executable(klotski main.cc) target_link_libraries(klotski all_cases) + +target_link_libraries(klotski raw_code) target_link_libraries(klotski short_code) target_link_libraries(klotski common_code) diff --git a/src/main.cc b/src/main.cc index a91bd59..004f63f 100644 --- a/src/main.cc +++ b/src/main.cc @@ -3,6 +3,7 @@ #include "basic_ranges.h" #include "common_code.h" #include "short_code.h" +#include "raw_code.h" #include @@ -119,11 +120,15 @@ int main() { // std::cout << CommonCode(0x6EC0F8800).to_short_code().to_string() << std::endl; - std::cout << CommonCode(ShortCode(14323231)).to_string() << std::endl; - std::cout << ShortCode(14323231).to_common_code().to_string() << std::endl; +// std::cout << CommonCode(ShortCode(14323231)).to_string() << std::endl; +// std::cout << ShortCode(14323231).to_common_code().to_string() << std::endl; +// +// std::cout << ShortCode(CommonCode(0x6EC0F8800)).to_string() << std::endl; +// std::cout << CommonCode(0x6EC0F8800).to_short_code().to_string() << std::endl; + - std::cout << ShortCode(CommonCode(0x6EC0F8800)).to_string() << std::endl; - std::cout << CommonCode(0x6EC0F8800).to_short_code().to_string() << std::endl; + auto r = RawCode(0x0E58FC85FFEBC4DB); + printf("%016lX\n", r.unwrap()); return 0; } diff --git a/src/raw_code/CMakeLists.txt b/src/raw_code/CMakeLists.txt new file mode 100644 index 0000000..7462462 --- /dev/null +++ b/src/raw_code/CMakeLists.txt @@ -0,0 +1,4 @@ +cmake_minimum_required(VERSION 3.0) + +add_library(raw_code raw_code.cc) +target_link_libraries(raw_code common_code) diff --git a/src/raw_code/raw_code.cc b/src/raw_code/raw_code.cc new file mode 100644 index 0000000..b5b77a4 --- /dev/null +++ b/src/raw_code/raw_code.cc @@ -0,0 +1,5 @@ +#include "raw_code.h" + +uint64_t RawCode::unwrap() const { // get raw uint64_t code + return code; +} diff --git a/src/raw_code/raw_code.h b/src/raw_code/raw_code.h new file mode 100644 index 0000000..3888010 --- /dev/null +++ b/src/raw_code/raw_code.h @@ -0,0 +1,19 @@ +#pragma once + +#include +#include "common_code.h" + +class RawCode { +public: + uint64_t unwrap() const; + std::string dump_case() const; + CommonCode to_common_code() const; + + RawCode(const CommonCode &common_code); + + explicit RawCode(uint64_t raw_code) : code(raw_code) {} + +private: + uint64_t code; + +};