| 35 | typedef map<string, string> opt_t; |
| 36 | |
| 37 | void print_usage() { |
| 38 | cout << R"delimiter(BIN2CPP |
| 39 | Converts files from a binary file to C++ headers. It is similar to bin2c and |
| 40 | xxd but adds support for namespaces. |
| 41 | |
| 42 | | --name | name of the variable (default: var) | |
| 43 | | --file | input file | |
| 44 | | --output | output file (If no output is specified then it prints to stdout | |
| 45 | | --type | Type of variable (default: char) | |
| 46 | | --binary | If the file contents are in binary form | |
| 47 | | --nullterm | Add a null character to the end of the file | |
| 48 | | --namespace | A space seperated list of namespaces | |
| 49 | | --formatted | Tabs for formatting | |
| 50 | | --version | Prints my name | |
| 51 | | --help | Prints usage info | |
| 52 | |
| 53 | Example |
| 54 | ------- |
| 55 | Command: |
| 56 | ./bin2cpp --file blah.txt --namespace blah detail --formatted --name blah_var |
| 57 | |
| 58 | Will produce: |
| 59 | #pragma once |
| 60 | #include <common/util.hpp> |
| 61 | #include <cstddef> |
| 62 | namespace blah { |
| 63 | namespace detail { |
| 64 | static const unsigned char blah_var_uchar [] = { |
| 65 | 0x2f, 0x2f, 0x20, 0x62, 0x6c, 0x61, 0x68, 0x2e, 0x74, 0x78, |
| 66 | 0x74, 0xa, 0x62, 0x6c, 0x61, 0x68, 0x20, 0x62, 0x6c, 0x61, |
| 67 | 0x68, 0x20, 0x62, 0x6c, 0x61, 0x68, 0xa, }; |
| 68 | static const char *blah_var = (const char*)blah_var_uchar; |
| 69 | static const size_t blah_var_len = 27; |
| 70 | static const size_t blah_var_hash = 12345678901234567890ULL; |
| 71 | static const common::Source blah_var_src = { |
| 72 | blah_var, |
| 73 | blah_var_len, |
| 74 | blah_var_hash |
| 75 | }; |
| 76 | } |
| 77 | })delimiter"; |
| 78 | exit(0); |
| 79 | } |
| 80 | |
| 81 | static bool formatted; |
| 82 | static bool binary = false; |
no outgoing calls
no test coverage detected