#include <xtd/xtd>
namespace bit_converter_to_string_example {
class program {
public:
static void write_multi_line_byte_array(const read_only_span<byte>& bytes, const string& name) {
const auto row_size = 20_z;
const auto underLine = "--------------------------------"_s;
auto iter = 0_z;
console::write_line(name);
console::write_line(underLine.substring(0, math::min(name.length(), underLine.length())));
for(iter = 0; iter < bytes.length() - row_size; iter += row_size) {
console::write(bit_converter::to_string(bytes, iter, row_size));
console::write_line("-");
}
console::write_line(bit_converter::to_string(bytes, iter));
console::write_line();
}
static auto main() {
auto array_one = array<byte> {
0, 0, 0, 0, 128, 63, 0, 0, 112, 65,
0, 255, 127, 71, 0, 0, 128, 59, 0, 0,
128, 47, 73, 70, 131, 5, 75, 6, 158, 63,
77, 6, 158, 63, 80, 6, 158, 63, 30, 55,
190, 121, 255, 255, 127, 255, 255, 127, 127, 1,
0, 0, 0, 192, 255, 0, 0, 128, 255, 0,
0, 128, 127
};
auto array_two = array<byte> {
255, 255, 255, 0, 0, 20, 0, 33, 0, 0,
0, 1, 0, 0, 0, 100, 167, 179, 182, 224,
13, 0, 202, 154, 59, 0, 143, 91, 0, 170,
170, 170, 170, 170, 170, 0, 0, 232, 137, 4,
35, 199, 138, 255, 232, 244, 255, 252, 205, 255,
255, 129
};
auto array_three = array<byte> {
0, 222, 0, 0, 0, 224, 111, 64, 0, 0,
224, 255, 255, 255, 239, 65, 0, 0, 131, 0,
0, 0, 112, 63, 0, 143, 0, 100, 0, 0,
240, 61, 223, 136, 30, 28, 254, 116, 170, 1,
250, 89, 140, 66, 202, 192, 243, 63, 251, 89,
140, 66, 202, 192, 243, 63, 252, 89, 140, 66,
202, 192, 243, 63, 82, 211, 187, 188, 232, 126,
255, 255, 255, 244, 255, 239, 127, 1, 0, 0,
0, 10, 17, 0, 0, 248, 255, 0, 88, 0,
91, 0, 0, 240, 255, 0, 0, 240, 157
};
console::write_line("This example of the\n"
" xtd::bit_converter::to_string(const xtd::read_only_span<byte>&, xtd::usize) and\n"
" xtd::bit_converter::to_string(const xtd::read_only_span<byte>&, xtd::usize, xtd::usize)\n"
"methods generates the following output.\n");
write_multi_line_byte_array(array_one, "array_one");
write_multi_line_byte_array(array_two, "array_two");
write_multi_line_byte_array(array_three, "array_three");
}
};
}
startup_(bit_converter_to_string_example::program::main);
#define startup_(...)
Defines the entry point to be called when the application loads. Generally this is set either to the ...
Definition startup.hpp:152