Browse Source

feat: ostream for RawCode

master
Dnomd343 1 year ago
parent
commit
9ca2320b86
  1. 2
      src/main.cc
  2. 7
      src/raw_code/raw_code.cc
  3. 2
      src/raw_code/raw_code.h

2
src/main.cc

@ -425,7 +425,7 @@ int main() {
// std::cout << RawCode(RawCode::extract(0x0000FF004)).dump_case() << std::endl;
// std::cout << RawCode::extract(0x555a4001) << std::endl;
std::cout << RawCode::create(CommonCode(0x4FEA13400).to_raw_code().unwrap()).dump_case() << std::endl;
std::cout << RawCode::create(CommonCode(0x4FEA13400).to_raw_code().unwrap()) << std::endl;
std::cerr << (clock() - start_time) / CLOCKS_PER_SEC << "s" << std::endl;
// std::cerr << (clock() - start_time) * 1000 / CLOCKS_PER_SEC << "ms" << std::endl;

7
src/raw_code/raw_code.cc

@ -23,6 +23,13 @@ RawCode::RawCode(uint64_t raw_code) {
code = raw_code;
}
std::ostream& operator<<(std::ostream &out, const RawCode &self) {
char str[16];
sprintf(str, "%015lX", self.code);
out << str;
return out;
}
std::string RawCode::dump_case() const {
// TODO: using stack char *
std::string result;

2
src/raw_code/raw_code.h

@ -14,7 +14,7 @@ public:
CommonCode to_common_code() const;
static bool check(uint64_t raw_code);
// friend std::ostream& operator<<(std::ostream &out, const RawCode &self);
friend std::ostream& operator<<(std::ostream &out, const RawCode &self);
explicit RawCode(uint64_t raw_code);
explicit RawCode(const CommonCode &common_code);

Loading…
Cancel
Save