feisty meow concerns codebase
2.140
|
Provides functions for manipulating arrays of bytes. More...
#include <byte_formatter.h>
Public Member Functions | |
virtual | ~byte_formatter () |
DEFINE_CLASS_NAME ("byte_formatter") | |
Static Public Member Functions | |
static void | print_char (basis::abyte to_print, basis::astring &out, char replace='_') |
prints the byte "to_print" into "out" as long as "to_print" is readable. More... | |
static void | print_chars (const basis::abyte *to_print, int length, basis::astring &out, char replace='_') |
sends the bytes in "to_print" of "length" bytes into the string "out". More... | |
static void | text_dump (basis::astring &output, const basis::abyte *location, basis::un_int length, basis::un_int label=0, const char *eol="\n") |
prints out a block of memory in a human readable form. More... | |
static basis::astring | text_dump (const basis::abyte *location, basis::un_int length, basis::un_int label=0, const char *eol="\n") |
this is a less efficient version of text_dump that returns a string. More... | |
static void | text_dump (basis::astring &output, const basis::byte_array &to_dump, basis::un_int label=0, const char *eol="\n") |
a version that operates on a byte_array and stores into a string. More... | |
static basis::astring | text_dump (const basis::byte_array &to_dump, basis::un_int label=0, const char *eol="\n") |
a version that operates on a byte_array and returns a string. More... | |
static void | parse_dump (const basis::astring &dumped_form, basis::byte_array &bytes_found) |
this operation performs the inverse of a text_dump. More... | |
static void | bytes_to_string (const basis::byte_array &to_convert, basis::astring &as_string, bool space_delimited=true) |
converts a byte_array into a string. More... | |
static void | string_to_bytes (const basis::astring &to_convert, basis::byte_array &as_array) |
wrangles the string "to_convert" into an equivalent byte form "as_array". More... | |
static void | bytes_to_string (const basis::abyte *to_convert, int length, basis::astring &as_string, bool space_delimited=true) |
a version that accepts a byte pointer and length, rather than byte_array. More... | |
static void | string_to_bytes (const char *to_convert, basis::byte_array &as_array) |
a version that works with the char pointer rather than an astring. More... | |
static void | bytes_to_shifted_string (const basis::byte_array &to_convert, basis::astring &as_string) |
this is a special purpose converter from bytes to character strings. More... | |
static void | shifted_string_to_bytes (const basis::astring &to_convert, basis::byte_array &as_array) |
unshifts a string "to_convert" back into a byte_array. More... | |
static void | make_eight (basis::un_int num, basis::astring &out) |
static bool | in_hex_range (char to_check) |
Provides functions for manipulating arrays of bytes.
Definition at line 25 of file byte_formatter.h.
|
inlinevirtual |
Definition at line 28 of file byte_formatter.h.
|
static |
this is a special purpose converter from bytes to character strings.
it merely ensures that the "as_string" version has no zero bytes besides the end of string null byte. this packs 7 bits of data into each character, resulting in an 87.5% efficient string packing of the array. the resulting string is not readable. the "as_string" parameter is not reset; any data will be appended to it.
Definition at line 259 of file byte_formatter.cpp.
References structures::bit_vector::bits(), FUNCDEF, basis::array< contents >::length(), basis::astring::length(), LOG, basis::array< contents >::observe(), structures::bit_vector::on(), and basis::astring::s().
|
static |
a version that accepts a byte pointer and length, rather than byte_array.
Definition at line 161 of file byte_formatter.cpp.
References basis::negative(), basis::astring::s(), and basis::astring::SPRINTF.
|
static |
converts a byte_array into a string.
takes an array of bytes "to_convert" and spits out the equivalent form "as_string". if "space_delimited" is true, then the bytes are separated by spaces.
Definition at line 249 of file byte_formatter.cpp.
References basis::array< contents >::length(), and basis::array< contents >::observe().
textual::byte_formatter::DEFINE_CLASS_NAME | ( | "byte_formatter" | ) |
|
static |
Definition at line 179 of file byte_formatter.cpp.
|
static |
Definition at line 53 of file byte_formatter.cpp.
References eml_to_txt::num.
|
static |
this operation performs the inverse of a text_dump.
Definition at line 119 of file byte_formatter.cpp.
References basis::astring::find(), basis::array< contents >::length(), basis::astring::length(), basis::negative(), basis::array< contents >::reset(), and basis::astring::substring().
|
static |
prints the byte "to_print" into "out" as long as "to_print" is readable.
if it's not readable, then the "replace" is printed.
Definition at line 40 of file byte_formatter.cpp.
|
static |
sends the bytes in "to_print" of "length" bytes into the string "out".
Definition at line 47 of file byte_formatter.cpp.
|
static |
unshifts a string "to_convert" back into a byte_array.
converts a string "to_convert" created by bytes_to_shifted_string() into the original array of bytes and stores it in "as_array". the "as_array" parameter is not reset; any data will be appended to it.
Definition at line 281 of file byte_formatter.cpp.
References structures::bit_vector::bits(), deadly_error, FUNCDEF, basis::array< contents >::length(), basis::astring::length(), LOG, structures::bit_vector::resize(), basis::astring::s(), and structures::bit_vector::set_bit().
|
static |
wrangles the string "to_convert" into an equivalent byte form "as_array".
this is a fairly forgiving conversion; it will accept any string and strip out the hexadecimal bytes. spacing is optional, but every two hex nibbles together will be taken as a byte. if there are an odd number of nibbles, then the odd one will be taken as the least significant half of a byte.
Definition at line 256 of file byte_formatter.cpp.
References basis::astring::s().
|
static |
a version that works with the char pointer rather than an astring.
Definition at line 187 of file byte_formatter.cpp.
References basis::array< contents >::reset().
|
static |
prints out a block of memory in a human readable form.
it is stored in the "output" string. the "location" is where to dump, the "length" is the number of bytes to dump, and the "label" is where to start numbering the location label on the first line. the "eol" supplies the line ending sequence to be used for the output file. this should be "\r\n" for win32.
Definition at line 85 of file byte_formatter.cpp.
References LINE_SIZE, and basis::astring::SPRINTF.
|
static |
a version that operates on a byte_array and stores into a string.
Definition at line 71 of file byte_formatter.cpp.
References basis::array< contents >::length(), and basis::array< contents >::observe().
|
static |
this is a less efficient version of text_dump that returns a string.
it's easier to use when combining astrings.
Definition at line 63 of file byte_formatter.cpp.
|
static |
a version that operates on a byte_array and returns a string.
Definition at line 77 of file byte_formatter.cpp.
References basis::array< contents >::length(), and basis::array< contents >::observe().