| 1 | #cxx . . $ `<file>/src/LibBGCode/cmd/main.cpp`/include "convert/convert.hpp"cxx . . $ `<file>/src/LibBGCode/convert/convert.hpp`/ |
| 2 | |
| 3 | #include <string> |
| 4 | #include <string_view> |
| 5 | #include <iostream> |
| 6 | #include <algorithm> |
| 7 | #include <stdexcept> |
| 8 | #include <stdlib.h> |
| 9 | #include <boost/nowide/cstdio.hpp> |
| 10 | |
| 11 | using namespace bgcodecxx . . $ bgcode/::core; |
| 12 | using namespace bgcodecxx . . $ bgcode/::binarize; |
| 13 | using namespace bgcodecxx . . $ bgcode/::convert; |
| 14 | |
| 15 | struct Parametercxx . . $ Parameter# |
| 16 | { |
| 17 | stdcxx . . $ std/::string_viewcxx . . $ std/string_view# namecxx . . $ Parameter#name.; |
| 18 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::string_viewcxx . . $ std/string_view#> valuescxx . . $ Parameter#values.; |
| 19 | size_t default_idcxx . . $ Parameter#default_id.; |
| 20 | }; |
| 21 | |
| 22 | using namespace stdcxx . . $ std/::literals; |
| 23 | |
| 24 | static const BinarizerConfigcxx . . $ bgcode/binarize/BinarizerConfig# DefaultBinarizerConfigcxx . . $ DefaultBinarizerConfig.; |
| 25 | |
| 26 | static const stdcxx . . $ std/::vectorcxx . . $ std/vector#<Parametercxx . . $ Parameter#> parameterscxx . . $ parameters. = {cxx . . $ std/vector#vector(9619226211e5a241). |
| 27 | { "checksum"svcxx . . $ std/literals/string_view_literals/`operator""sv`(1b6d6003074ba8ca)., { "None"svcxx . . $ std/literals/string_view_literals/`operator""sv`(1b6d6003074ba8ca)., "CRC32"svcxx . . $ std/literals/string_view_literals/`operator""sv`(1b6d6003074ba8ca). }, (size_t) DefaultBinarizerConfigcxx . . $ DefaultBinarizerConfig..checksumcxx . . $ bgcode/binarize/BinarizerConfig#checksum. }, |
| 28 | { "file_metadata_compression"svcxx . . $ std/literals/string_view_literals/`operator""sv`(1b6d6003074ba8ca)., { "None"svcxx . . $ std/literals/string_view_literals/`operator""sv`(1b6d6003074ba8ca)., "Deflate"svcxx . . $ std/literals/string_view_literals/`operator""sv`(1b6d6003074ba8ca)., "Heatshrink_11_4"svcxx . . $ std/literals/string_view_literals/`operator""sv`(1b6d6003074ba8ca)., "Heatshrink_12_4"svcxx . . $ std/literals/string_view_literals/`operator""sv`(1b6d6003074ba8ca). }, (size_t)DefaultBinarizerConfigcxx . . $ DefaultBinarizerConfig..compressioncxx . . $ bgcode/binarize/BinarizerConfig#compression..file_metadatacxx . . $ bgcode/binarize/BinarizerConfig#Compression#file_metadata. }, |
| 29 | { "print_metadata_compression"svcxx . . $ std/literals/string_view_literals/`operator""sv`(1b6d6003074ba8ca)., { "None"svcxx . . $ std/literals/string_view_literals/`operator""sv`(1b6d6003074ba8ca)., "Deflate"svcxx . . $ std/literals/string_view_literals/`operator""sv`(1b6d6003074ba8ca)., "Heatshrink_11_4"svcxx . . $ std/literals/string_view_literals/`operator""sv`(1b6d6003074ba8ca)., "Heatshrink_12_4"svcxx . . $ std/literals/string_view_literals/`operator""sv`(1b6d6003074ba8ca). }, (size_t)DefaultBinarizerConfigcxx . . $ DefaultBinarizerConfig..compressioncxx . . $ bgcode/binarize/BinarizerConfig#compression..print_metadatacxx . . $ bgcode/binarize/BinarizerConfig#Compression#print_metadata. }, |
| 30 | { "printer_metadata_compression"svcxx . . $ std/literals/string_view_literals/`operator""sv`(1b6d6003074ba8ca)., { "None"svcxx . . $ std/literals/string_view_literals/`operator""sv`(1b6d6003074ba8ca)., "Deflate"svcxx . . $ std/literals/string_view_literals/`operator""sv`(1b6d6003074ba8ca)., "Heatshrink_11_4"svcxx . . $ std/literals/string_view_literals/`operator""sv`(1b6d6003074ba8ca)., "Heatshrink_12_4"svcxx . . $ std/literals/string_view_literals/`operator""sv`(1b6d6003074ba8ca). }, (size_t)DefaultBinarizerConfigcxx . . $ DefaultBinarizerConfig..compressioncxx . . $ bgcode/binarize/BinarizerConfig#compression..printer_metadatacxx . . $ bgcode/binarize/BinarizerConfig#Compression#printer_metadata. }, |
| 31 | { "slicer_metadata_compression"svcxx . . $ std/literals/string_view_literals/`operator""sv`(1b6d6003074ba8ca)., { "None"svcxx . . $ std/literals/string_view_literals/`operator""sv`(1b6d6003074ba8ca)., "Deflate"svcxx . . $ std/literals/string_view_literals/`operator""sv`(1b6d6003074ba8ca)., "Heatshrink_11_4"svcxx . . $ std/literals/string_view_literals/`operator""sv`(1b6d6003074ba8ca)., "Heatshrink_12_4"svcxx . . $ std/literals/string_view_literals/`operator""sv`(1b6d6003074ba8ca). }, (size_t)DefaultBinarizerConfigcxx . . $ DefaultBinarizerConfig..compressioncxx . . $ bgcode/binarize/BinarizerConfig#compression..slicer_metadatacxx . . $ bgcode/binarize/BinarizerConfig#Compression#slicer_metadata. }, |
| 32 | { "gcode_compression"svcxx . . $ std/literals/string_view_literals/`operator""sv`(1b6d6003074ba8ca)., { "None"svcxx . . $ std/literals/string_view_literals/`operator""sv`(1b6d6003074ba8ca)., "Deflate"svcxx . . $ std/literals/string_view_literals/`operator""sv`(1b6d6003074ba8ca)., "Heatshrink_11_4"svcxx . . $ std/literals/string_view_literals/`operator""sv`(1b6d6003074ba8ca)., "Heatshrink_12_4"svcxx . . $ std/literals/string_view_literals/`operator""sv`(1b6d6003074ba8ca). }, (size_t)DefaultBinarizerConfigcxx . . $ DefaultBinarizerConfig..compressioncxx . . $ bgcode/binarize/BinarizerConfig#compression..gcodecxx . . $ bgcode/binarize/BinarizerConfig#Compression#gcode. }, |
| 33 | { "gcode_encoding"svcxx . . $ std/literals/string_view_literals/`operator""sv`(1b6d6003074ba8ca)., { "None"svcxx . . $ std/literals/string_view_literals/`operator""sv`(1b6d6003074ba8ca)., "MeatPack"svcxx . . $ std/literals/string_view_literals/`operator""sv`(1b6d6003074ba8ca)., "MeatPackComments"svcxx . . $ std/literals/string_view_literals/`operator""sv`(1b6d6003074ba8ca). }, (size_t)DefaultBinarizerConfigcxx . . $ DefaultBinarizerConfig..gcode_encodingcxx . . $ bgcode/binarize/BinarizerConfig#gcode_encoding. }, |
| 34 | { "metadata_encoding"svcxx . . $ std/literals/string_view_literals/`operator""sv`(1b6d6003074ba8ca)., { "INI"svcxx . . $ std/literals/string_view_literals/`operator""sv`(1b6d6003074ba8ca). }, (size_t) DefaultBinarizerConfigcxx . . $ DefaultBinarizerConfig..metadata_encodingcxx . . $ bgcode/binarize/BinarizerConfig#metadata_encoding. } |
| 35 | }; |
| 36 | |
| 37 | class ScopedFilecxx . . $ ScopedFile# |
| 38 | { |
| 39 | public: |
| 40 | explicit ScopedFilecxx . . $ ScopedFile#ScopedFile(8d4262d45fc644ab).(FILE* file) : m_filecxx . . $ ScopedFile#m_file.(file) {} |
| 41 | ~cxx . . $ ScopedFile#`~ScopedFile`(ced63f7c635d850d).ScopedFilecxx . . $ ScopedFile#() { if (m_filecxx . . $ ScopedFile#m_file. != nullptr) fclose(m_filecxx . . $ ScopedFile#m_file.); } |
| 42 | private: |
| 43 | FILE* m_filecxx . . $ ScopedFile#m_file.{ nullptr }; |
| 44 | }; |
| 45 | |
| 46 | void show_helpcxx . . $ show_help(49f6e7a06ebc5aa8).() { |
| 47 | stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Usage: bgcode filename [ Binarization parameters ]\n"; |
| 48 | stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\nBinarization parameters (used only when converting to binary format):\n"; |
| 49 | for (const Parametercxx . . $ Parameter#& p : parameterscxx . . $ parameters.) { |
| 50 | stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "--" <<cxx . . $ std/`operator<<`(cb6f908c4937f172). pcxx . . $ std/basic_string_view#basic_string_view(b419d9def655ef02)..namecxx . . $ Parameter#name. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "=X\n"; |
| 51 | stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " where X is one of:\n"; |
| 52 | size_t count = 0; |
| 53 | for (const stdcxx . . $ std/::string_viewcxx . . $ std/string_view#& v : p.valuescxx . . $ Parameter#values.) { |
| 54 | stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " " <<cxx . . $ std/basic_ostream#`operator<<`(b09cd8ec4365c7ed). count <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). ") " <<cxx . . $ std/`operator<<`(cb6f908c4937f172). vcxx . . $ std/basic_string_view#basic_string_view(b419d9def655ef02).; |
| 55 | if (count == p.default_idcxx . . $ Parameter#default_id.) |
| 56 | stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " (default)"; |
| 57 | stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\n"; |
| 58 | ++count; |
| 59 | } |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | bool parse_argscxx . . $ parse_args(53c8063f1942eba0).(int argc, const char* argv[], stdcxx . . $ std/::stringcxx . . $ std/string#& src_filename, bool& src_is_binary, BinarizerConfigcxx . . $ bgcode/binarize/BinarizerConfig#& config) |
| 64 | { |
| 65 | if (argc < 2) { |
| 66 | show_helpcxx . . $ show_help(49f6e7a06ebc5aa8).(); |
| 67 | return false; |
| 68 | } |
| 69 | |
| 70 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::string_viewcxx . . $ std/string_view#> argumentscxx . . $ std/vector#vector(49f6e7a06ebc5aa8).; |
| 71 | arguments.reservecxx . . $ std/vector#reserve(2c44cd906ae4e829).(argc); |
| 72 | for (int i = 0; i < argc; ++i) { |
| 73 | arguments.push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70).(argvcxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792).[i]); |
| 74 | } |
| 75 | |
| 76 | size_t pos = arguments[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).1].find_last_ofcxx . . $ std/basic_string_view#find_last_of(36b1ea5aa9fdc150).("."); |
| 77 | if (pos == stdcxx . . $ std/::stringcxx . . $ std/string#::nposcxx . . $ std/__cxx11/basic_string#npos.) { |
| 78 | stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Invalid filename " <<cxx . . $ std/`operator<<`(cb6f908c4937f172). argumentscxx . . $ std/basic_string_view#basic_string_view(b419d9def655ef02).[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).1] <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " (required extensions: .gcode or .bgcode or .bgc)\n"; |
| 79 | return false; |
| 80 | } |
| 81 | const stdcxx . . $ std/::string_viewcxx . . $ std/string_view# extension = arguments[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).1].substrcxx . . $ std/basic_string_view#substr(6f25e9449f081971).(pos); |
| 82 | if (extensioncxx . . $ std/basic_string_view#basic_string_view(b419d9def655ef02). !=cxx . . $ std/`operator!=`(f7aa9889d61a8d61). ".gcode"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792). && extensioncxx . . $ std/basic_string_view#basic_string_view(b419d9def655ef02). !=cxx . . $ std/`operator!=`(f7aa9889d61a8d61). ".GCODE"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792). && |
| 83 | extensioncxx . . $ std/basic_string_view#basic_string_view(b419d9def655ef02). !=cxx . . $ std/`operator!=`(f7aa9889d61a8d61). ".bgcode"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792). && extensioncxx . . $ std/basic_string_view#basic_string_view(b419d9def655ef02). !=cxx . . $ std/`operator!=`(f7aa9889d61a8d61). ".BGCODE"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792). && |
| 84 | extensioncxx . . $ std/basic_string_view#basic_string_view(b419d9def655ef02). !=cxx . . $ std/`operator!=`(f7aa9889d61a8d61). ".bgc"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792). && extensioncxx . . $ std/basic_string_view#basic_string_view(b419d9def655ef02). !=cxx . . $ std/`operator!=`(f7aa9889d61a8d61). ".BGC"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792).) { |
| 85 | stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Found invalid extension '" <<cxx . . $ std/`operator<<`(cb6f908c4937f172). extensioncxx . . $ std/basic_string_view#basic_string_view(b419d9def655ef02). <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "' (required extensions: .gcode or .bgcode or .bgc)\n"; |
| 86 | return false; |
| 87 | } |
| 88 | src_filename =cxx . . $ std/__cxx11/basic_string#`operator=`(d07e3dd77f70328a). arguments[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).1]; |
| 89 | |
| 90 | FILE* src_file = boostcxx . . $ boost/::nowidecxx . . $ boost/nowide/::fopencxx . . $ boost/nowide/fopen(82ec0787cd37e0a3).(src_filename.c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).(), "rb"); |
| 91 | if (src_file == nullptr) { |
| 92 | stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Unable to open file '" <<cxx . . $ std/`operator<<`(88df5bef833f7f83). src_filename <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "'\n"; |
| 93 | return false; |
| 94 | } |
| 95 | src_is_binary = is_valid_binary_gcodecxx . . $ bgcode/core/is_valid_binary_gcode(73bc5f1c782bc347).(*src_file) == EResultcxx . . $ bgcode/core/EResult#::Successcxx . . $ bgcode/core/EResult#Success.; |
| 96 | fclose(src_file); |
| 97 | |
| 98 | if (!src_is_binary) { |
| 99 | for (size_t i = 2; i < arguments.sizecxx . . $ std/vector#size(c9b1e749b64d5edc).(); ++i) { |
| 100 | const stdcxx . . $ std/::string_viewcxx . . $ std/string_view#& a = arguments[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).i]; |
| 101 | if (a.lengthcxx . . $ std/basic_string_view#length(c9b1e749b64d5edc).() < 2 || a[cxx . . $ std/basic_string_view#`operator[]`(c65000e556194d6f).0] != '-' || a[cxx . . $ std/basic_string_view#`operator[]`(c65000e556194d6f).1] != '-') { |
| 102 | stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Found invalid parameter '" <<cxx . . $ std/`operator<<`(cb6f908c4937f172). acxx . . $ std/basic_string_view#basic_string_view(b419d9def655ef02). <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "'\n"; |
| 103 | stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Required syntax: --parameter=value\n"; |
| 104 | return false; |
| 105 | } |
| 106 | |
| 107 | pos = a.findcxx . . $ std/basic_string_view#find(36b1ea5aa9fdc150).("="); |
| 108 | if (pos == stdcxx . . $ std/::string_viewcxx . . $ std/string_view#::nposcxx . . $ std/basic_string_view#npos.) { |
| 109 | stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Found invalid parameter '" <<cxx . . $ std/`operator<<`(cb6f908c4937f172). acxx . . $ std/basic_string_view#basic_string_view(b419d9def655ef02). <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "'\n"; |
| 110 | stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Required syntax: --parameter=value\n"; |
| 111 | return false; |
| 112 | } |
| 113 | |
| 114 | const stdcxx . . $ std/::string_viewcxx . . $ std/string_view# key = a.substrcxx . . $ std/basic_string_view#substr(6f25e9449f081971).(2, pos - 2); |
| 115 | auto it = stdcxx . . $ std/::find_ifcxx . . $ std/find_if(f0a0a4f94ee5cb00).(parameterscxx . . $ parameters..begincxx . . $ std/vector#begin(d1e1699016b9d7e6).(), parameterscxx . . $ parameters..endcxx . . $ std/vector#end(d1e1699016b9d7e6).(), |
| 116 | [&key](const Parametercxx . . $ Parameter#& item) { return itemcxx . . $ std/basic_string_view#basic_string_view(b419d9def655ef02)..namecxx . . $ Parameter#name. ==cxx . . $ std/`operator==`(9c5f1f2306f1a4b2). keycxx . . $ std/basic_string_view#basic_string_view(b419d9def655ef02).; }); |
| 117 | if (it ==cxx . . $ __gnu_cxx/`operator==`(3cd84a314b671a91). parameterscxx . . $ parameters..endcxx . . $ std/vector#end(d1e1699016b9d7e6).()) { |
| 118 | stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Found unknown parameter '" <<cxx . . $ std/`operator<<`(cb6f908c4937f172). keycxx . . $ std/basic_string_view#basic_string_view(b419d9def655ef02). <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "'\n"; |
| 119 | stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Accepted parameters:\n"; |
| 120 | for (const Parametercxx . . $ Parameter#& p : parameterscxx . . $ parameters.) { |
| 121 | stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(cb6f908c4937f172). pcxx . . $ std/basic_string_view#basic_string_view(b419d9def655ef02)..namecxx . . $ Parameter#name. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\n"; |
| 122 | } |
| 123 | return false; |
| 124 | } |
| 125 | |
| 126 | const Parametercxx . . $ Parameter#& parameter = parameterscxx . . $ parameters.[cxx . . $ std/vector#`operator[]`(c8255e0fa326ac32).stdcxx . . $ std/::distancecxx . . $ std/distance(4883b9d540cf40e9).(parameterscxx . . $ parameters..begincxx . . $ std/vector#begin(d1e1699016b9d7e6).(), it)]; |
| 127 | |
| 128 | const stdcxx . . $ std/::string_viewcxx . . $ std/string_view# value_str = a.substrcxx . . $ std/basic_string_view#substr(6f25e9449f081971).(pos + 1); |
| 129 | int value; |
| 130 | try { |
| 131 | value = stdcxx . . $ std/::stoicxx . . $ std/__cxx11/stoi(ffee248579a0a688).(stdcxx . . $ std/::stringcxx . . $ std/string#(value_str)); |
| 132 | if (value >= parameter.valuescxx . . $ Parameter#values..sizecxx . . $ std/vector#size(c9b1e749b64d5edc).()) |
| 133 | throw stdcxx . . $ std/::runtime_errorcxx . . $ std/runtime_error#("invalid value"); |
| 134 | } |
| 135 | catch (...) { |
| 136 | stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Found invalid value for parameter '" <<cxx . . $ std/`operator<<`(cb6f908c4937f172). parametercxx . . $ std/basic_string_view#basic_string_view(b419d9def655ef02)..namecxx . . $ Parameter#name. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "'\n"; |
| 137 | stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Accepted values:\n"; |
| 138 | for (size_t p = 0; p < parameter.valuescxx . . $ Parameter#values..sizecxx . . $ std/vector#size(c9b1e749b64d5edc).(); ++p) { |
| 139 | stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/basic_ostream#`operator<<`(b09cd8ec4365c7ed). p <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). ") " <<cxx . . $ std/`operator<<`(cb6f908c4937f172). parametercxx . . $ std/basic_string_view#basic_string_view(b419d9def655ef02)..valuescxx . . $ Parameter#values.[cxx . . $ std/vector#`operator[]`(c8255e0fa326ac32).p] <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\n"; |
| 140 | } |
| 141 | return false; |
| 142 | } |
| 143 | |
| 144 | if (parametercxx . . $ std/basic_string_view#basic_string_view(b419d9def655ef02)..namecxx . . $ Parameter#name. ==cxx . . $ std/`operator==`(f7aa9889d61a8d61). "checksum"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792).) |
| 145 | config.checksumcxx . . $ bgcode/binarize/BinarizerConfig#checksum. = (EChecksumTypecxx . . $ bgcode/core/EChecksumType#)value; |
| 146 | else if (parametercxx . . $ std/basic_string_view#basic_string_view(b419d9def655ef02)..namecxx . . $ Parameter#name. ==cxx . . $ std/`operator==`(f7aa9889d61a8d61). "file_metadata_compression"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792).) |
| 147 | config.compressioncxx . . $ bgcode/binarize/BinarizerConfig#compression..file_metadatacxx . . $ bgcode/binarize/BinarizerConfig#Compression#file_metadata. = (ECompressionTypecxx . . $ bgcode/core/ECompressionType#)value; |
| 148 | else if (parametercxx . . $ std/basic_string_view#basic_string_view(b419d9def655ef02)..namecxx . . $ Parameter#name. ==cxx . . $ std/`operator==`(f7aa9889d61a8d61). "print_metadata_compression"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792).) |
| 149 | config.compressioncxx . . $ bgcode/binarize/BinarizerConfig#compression..print_metadatacxx . . $ bgcode/binarize/BinarizerConfig#Compression#print_metadata. = (ECompressionTypecxx . . $ bgcode/core/ECompressionType#)value; |
| 150 | else if (parametercxx . . $ std/basic_string_view#basic_string_view(b419d9def655ef02)..namecxx . . $ Parameter#name. ==cxx . . $ std/`operator==`(f7aa9889d61a8d61). "printer_metadata_compression"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792).) |
| 151 | config.compressioncxx . . $ bgcode/binarize/BinarizerConfig#compression..printer_metadatacxx . . $ bgcode/binarize/BinarizerConfig#Compression#printer_metadata. = (ECompressionTypecxx . . $ bgcode/core/ECompressionType#)value; |
| 152 | else if (parametercxx . . $ std/basic_string_view#basic_string_view(b419d9def655ef02)..namecxx . . $ Parameter#name. ==cxx . . $ std/`operator==`(f7aa9889d61a8d61). "slicer_metadata_compression"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792).) |
| 153 | config.compressioncxx . . $ bgcode/binarize/BinarizerConfig#compression..slicer_metadatacxx . . $ bgcode/binarize/BinarizerConfig#Compression#slicer_metadata. = (ECompressionTypecxx . . $ bgcode/core/ECompressionType#)value; |
| 154 | else if (parametercxx . . $ std/basic_string_view#basic_string_view(b419d9def655ef02)..namecxx . . $ Parameter#name. ==cxx . . $ std/`operator==`(f7aa9889d61a8d61). "gcode_compression"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792).) |
| 155 | config.compressioncxx . . $ bgcode/binarize/BinarizerConfig#compression..gcodecxx . . $ bgcode/binarize/BinarizerConfig#Compression#gcode. = (ECompressionTypecxx . . $ bgcode/core/ECompressionType#)value; |
| 156 | else if (parametercxx . . $ std/basic_string_view#basic_string_view(b419d9def655ef02)..namecxx . . $ Parameter#name. ==cxx . . $ std/`operator==`(f7aa9889d61a8d61). "gcode_encoding"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792).) |
| 157 | config.gcode_encodingcxx . . $ bgcode/binarize/BinarizerConfig#gcode_encoding. = (EGCodeEncodingTypecxx . . $ bgcode/core/EGCodeEncodingType#)value; |
| 158 | else if (parametercxx . . $ std/basic_string_view#basic_string_view(b419d9def655ef02)..namecxx . . $ Parameter#name. ==cxx . . $ std/`operator==`(f7aa9889d61a8d61). "metadata_encoding"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792).) |
| 159 | config.metadata_encodingcxx . . $ bgcode/binarize/BinarizerConfig#metadata_encoding. = (EMetadataEncodingTypecxx . . $ bgcode/core/EMetadataEncodingType#)value; |
| 160 | } |
| 161 | } |
| 162 | return true; |
| 163 | } |
| 164 | |
| 165 | int maincxx . . $ main(d8e43b79a186046c).(int argc, const char* argv[]) |
| 166 | { |
| 167 | stdcxx . . $ std/::stringcxx . . $ std/string# src_filenamecxx . . $ std/__cxx11/basic_string#basic_string(925dcc5e17f50391).; |
| 168 | bool src_is_binary; |
| 169 | BinarizerConfigcxx . . $ bgcode/binarize/BinarizerConfig# config; |
| 170 | if (!parse_argscxx . . $ parse_args(53c8063f1942eba0).(argc, argv, src_filename, src_is_binary, config)) |
| 171 | return EXIT_FAILUREcxx . . $ `<external>/10696550936717951914/stdlib.h:96:9`!; |
| 172 | |
| 173 | // Open source file |
| 174 | FILE* src_file = boostcxx . . $ boost/::nowidecxx . . $ boost/nowide/::fopencxx . . $ boost/nowide/fopen(82ec0787cd37e0a3).(src_filename.c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).(), "rb"); |
| 175 | if (src_file == nullptr) { |
| 176 | stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Unable to open file '" <<cxx . . $ std/`operator<<`(88df5bef833f7f83). src_filename <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "'\n"; |
| 177 | return EXIT_FAILUREcxx . . $ `<external>/10696550936717951914/stdlib.h:96:9`!; |
| 178 | } |
| 179 | ScopedFilecxx . . $ ScopedFile# scoped_src_filecxx . . $ ScopedFile#ScopedFile(8d4262d45fc644ab).(src_file); |
| 180 | |
| 181 | const size_t pos = src_filename.find_last_ofcxx . . $ std/__cxx11/basic_string#find_last_of(b733e800f6f8fb8b).("."); |
| 182 | const stdcxx . . $ std/::stringcxx . . $ std/string# src_stem = src_filename.substrcxx . . $ std/__cxx11/basic_string#substr(149c655009c9bbd2).(0, pos); |
| 183 | const stdcxx . . $ std/::stringcxx . . $ std/string# src_extension = (pos != stdcxx . . $ std/::stringcxx . . $ std/string#::nposcxx . . $ std/__cxx11/basic_string#npos.) ? src_filename.substrcxx . . $ std/__cxx11/basic_string#substr(149c655009c9bbd2).(pos) : ""cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).; |
| 184 | const stdcxx . . $ std/::stringcxx . . $ std/string# dst_extension = src_is_binarycxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d). ? |
| 185 | (src_extension ==cxx . . $ std/`operator==`(4b17aa87c9f300c6). ".gcode") ? ".1.gcode" : ".gcode" : |
| 186 | (src_extension ==cxx . . $ std/`operator==`(4b17aa87c9f300c6). ".bgcode") ? ".1.bgcode" : ".bgcode"; |
| 187 | const stdcxx . . $ std/::stringcxx . . $ std/string# dst_filename = src_stem +cxx . . $ std/operator+(2764d1739bf7913d). dst_extension; |
| 188 | |
| 189 | // Open destination file |
| 190 | FILE* dst_file = boostcxx . . $ boost/::nowidecxx . . $ boost/nowide/::fopencxx . . $ boost/nowide/fopen(82ec0787cd37e0a3).(dst_filename.c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).(), "wb"); |
| 191 | if (dst_file == nullptr) { |
| 192 | stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Unable to open file '" <<cxx . . $ std/`operator<<`(88df5bef833f7f83). dst_filename <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "'\n"; |
| 193 | return EXIT_FAILUREcxx . . $ `<external>/10696550936717951914/stdlib.h:96:9`!; |
| 194 | } |
| 195 | ScopedFilecxx . . $ ScopedFile# scoped_dst_filecxx . . $ ScopedFile#ScopedFile(8d4262d45fc644ab).(dst_file); |
| 196 | |
| 197 | // Perform conversion |
| 198 | const EResultcxx . . $ bgcode/core/EResult# res = src_is_binary ? from_binary_to_asciicxx . . $ bgcode/convert/from_binary_to_ascii(b67601911a29e706).(*src_file, *dst_file, true) : from_ascii_to_binarycxx . . $ bgcode/convert/from_ascii_to_binary(7b65e296ceea934d).(*src_file, *dst_file, config); |
| 199 | if (res == EResultcxx . . $ bgcode/core/EResult#::Successcxx . . $ bgcode/core/EResult#Success.) { |
| 200 | if (!src_is_binary) { |
| 201 | stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Binarization parameters\n"; |
| 202 | for (const Parametercxx . . $ Parameter#& p : parameterscxx . . $ parameters.) { |
| 203 | stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(cb6f908c4937f172). pcxx . . $ std/basic_string_view#basic_string_view(b419d9def655ef02)..namecxx . . $ Parameter#name. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). ": "; |
| 204 | if (pcxx . . $ std/basic_string_view#basic_string_view(b419d9def655ef02)..namecxx . . $ Parameter#name. ==cxx . . $ std/`operator==`(f7aa9889d61a8d61). "checksum"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792).) |
| 205 | stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(cb6f908c4937f172). pcxx . . $ std/basic_string_view#basic_string_view(b419d9def655ef02)..valuescxx . . $ Parameter#values.[cxx . . $ std/vector#`operator[]`(c8255e0fa326ac32).(size_t)config.checksumcxx . . $ bgcode/binarize/BinarizerConfig#checksum.] <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\n"; |
| 206 | else if (pcxx . . $ std/basic_string_view#basic_string_view(b419d9def655ef02)..namecxx . . $ Parameter#name. ==cxx . . $ std/`operator==`(f7aa9889d61a8d61). "file_metadata_compression"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792).) |
| 207 | stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(cb6f908c4937f172). pcxx . . $ std/basic_string_view#basic_string_view(b419d9def655ef02)..valuescxx . . $ Parameter#values.[cxx . . $ std/vector#`operator[]`(c8255e0fa326ac32).(size_t)config.compressioncxx . . $ bgcode/binarize/BinarizerConfig#compression..file_metadatacxx . . $ bgcode/binarize/BinarizerConfig#Compression#file_metadata.] <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\n"; |
| 208 | else if (pcxx . . $ std/basic_string_view#basic_string_view(b419d9def655ef02)..namecxx . . $ Parameter#name. ==cxx . . $ std/`operator==`(f7aa9889d61a8d61). "print_metadata_compression"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792).) |
| 209 | stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(cb6f908c4937f172). pcxx . . $ std/basic_string_view#basic_string_view(b419d9def655ef02)..valuescxx . . $ Parameter#values.[cxx . . $ std/vector#`operator[]`(c8255e0fa326ac32).(size_t)config.compressioncxx . . $ bgcode/binarize/BinarizerConfig#compression..print_metadatacxx . . $ bgcode/binarize/BinarizerConfig#Compression#print_metadata.] <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\n"; |
| 210 | else if (pcxx . . $ std/basic_string_view#basic_string_view(b419d9def655ef02)..namecxx . . $ Parameter#name. ==cxx . . $ std/`operator==`(f7aa9889d61a8d61). "printer_metadata_compression"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792).) |
| 211 | stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(cb6f908c4937f172). pcxx . . $ std/basic_string_view#basic_string_view(b419d9def655ef02)..valuescxx . . $ Parameter#values.[cxx . . $ std/vector#`operator[]`(c8255e0fa326ac32).(size_t)config.compressioncxx . . $ bgcode/binarize/BinarizerConfig#compression..printer_metadatacxx . . $ bgcode/binarize/BinarizerConfig#Compression#printer_metadata.] <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\n"; |
| 212 | else if (pcxx . . $ std/basic_string_view#basic_string_view(b419d9def655ef02)..namecxx . . $ Parameter#name. ==cxx . . $ std/`operator==`(f7aa9889d61a8d61). "slicer_metadata_compression"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792).) |
| 213 | stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(cb6f908c4937f172). pcxx . . $ std/basic_string_view#basic_string_view(b419d9def655ef02)..valuescxx . . $ Parameter#values.[cxx . . $ std/vector#`operator[]`(c8255e0fa326ac32).(size_t)config.compressioncxx . . $ bgcode/binarize/BinarizerConfig#compression..slicer_metadatacxx . . $ bgcode/binarize/BinarizerConfig#Compression#slicer_metadata.] <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\n"; |
| 214 | else if (pcxx . . $ std/basic_string_view#basic_string_view(b419d9def655ef02)..namecxx . . $ Parameter#name. ==cxx . . $ std/`operator==`(f7aa9889d61a8d61). "gcode_compression"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792).) |
| 215 | stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(cb6f908c4937f172). pcxx . . $ std/basic_string_view#basic_string_view(b419d9def655ef02)..valuescxx . . $ Parameter#values.[cxx . . $ std/vector#`operator[]`(c8255e0fa326ac32).(size_t)config.compressioncxx . . $ bgcode/binarize/BinarizerConfig#compression..gcodecxx . . $ bgcode/binarize/BinarizerConfig#Compression#gcode.] <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\n"; |
| 216 | else if (pcxx . . $ std/basic_string_view#basic_string_view(b419d9def655ef02)..namecxx . . $ Parameter#name. ==cxx . . $ std/`operator==`(f7aa9889d61a8d61). "gcode_encoding"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792).) |
| 217 | stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(cb6f908c4937f172). pcxx . . $ std/basic_string_view#basic_string_view(b419d9def655ef02)..valuescxx . . $ Parameter#values.[cxx . . $ std/vector#`operator[]`(c8255e0fa326ac32).(size_t)config.gcode_encodingcxx . . $ bgcode/binarize/BinarizerConfig#gcode_encoding.] <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\n"; |
| 218 | else if (pcxx . . $ std/basic_string_view#basic_string_view(b419d9def655ef02)..namecxx . . $ Parameter#name. ==cxx . . $ std/`operator==`(f7aa9889d61a8d61). "metadata_encoding"cxx . . $ std/basic_string_view#basic_string_view(837a1ee5a10cb792).) |
| 219 | stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(cb6f908c4937f172). pcxx . . $ std/basic_string_view#basic_string_view(b419d9def655ef02)..valuescxx . . $ Parameter#values.[cxx . . $ std/vector#`operator[]`(c8255e0fa326ac32).(size_t)config.metadata_encodingcxx . . $ bgcode/binarize/BinarizerConfig#metadata_encoding.] <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\n"; |
| 220 | } |
| 221 | } |
| 222 | stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Succesfully generated file '" <<cxx . . $ std/`operator<<`(88df5bef833f7f83). dst_filename <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "'\n"; |
| 223 | } |
| 224 | else { |
| 225 | stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Unable to convert the file '" <<cxx . . $ std/`operator<<`(88df5bef833f7f83). src_filename <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "'\n"; |
| 226 | stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Error: " <<cxx . . $ std/`operator<<`(cb6f908c4937f172). translate_resultcxx . . $ bgcode/core/translate_result(a668d56a003f646e).(res) <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\n"; |
| 227 | return EXIT_FAILUREcxx . . $ `<external>/10696550936717951914/stdlib.h:96:9`!; |
| 228 | } |
| 229 | |
| 230 | return EXIT_SUCCESScxx . . $ `<external>/10696550936717951914/stdlib.h:97:9`!; |
| 231 | } |