byte_format Namespace Reference

Provides functions for manipulating arrays of bytes. More...


Functions

void print_char (byte to_print, istring &out, char replace= '_')
 prints the byte "to_print" into "out" as long as "to_print" is readable.
void print_chars (const byte *to_print, int length, istring &out, char replace= '_')
 sends the bytes in "to_print" of "length" bytes into the string "out".
void make_eight (u_int num, istring &out)
istring text_dump (const byte *location, u_int length, u_int label=0, const char *eol="\n")
 this is a less efficient version of text_dump that returns a string.
void text_dump (istring &output, const byte_array &to_dump, u_int label=0, const char *eol="\n")
 a version that operates on a byte_array and stores into a string.
istring text_dump (const byte_array &to_dump, u_int label=0, const char *eol="\n")
 a version that operates on a byte_array and returns a string.
void text_dump (istring &output, const byte *location, u_int length, u_int label=0, const char *eol="\n")
 prints out a block of memory in a human readable form.
void parse_dump (const istring &dumped_form, byte_array &bytes_found)
 this operation performs the inverse of a text_dump.
void bytes_to_string (const byte *to_convert, int length, istring &as_string, bool space_delimited=true)
 a version that accepts a byte pointer and length, rather than byte_array.
bool in_hex_range (char to_check)
void string_to_bytes (const char *to_convert, byte_array &as_array)
 a version that works with the char pointer rather than an istring.
void bytes_to_string (const byte_array &to_convert, istring &as_string, bool space_delimited=true)
 converts a byte_array into a string.
void string_to_bytes (const istring &to_convert, byte_array &as_array)
 wrangles the string "to_convert" into an equivalent byte form "as_array".
void bytes_to_shifted_string (const byte_array &to_convert, istring &as_string)
 this is a special purpose converter from bytes to character strings.
void shifted_string_to_bytes (const istring &to_convert, byte_array &as_array)
 unshifts a string "to_convert" back into a byte_array.


Detailed Description

Provides functions for manipulating arrays of bytes.

Function Documentation

void TEXTUAL_FUNCTION_STYLE byte_format::bytes_to_shifted_string ( const byte_array to_convert,
istring as_string 
)

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 264 of file byte_format.cpp.

References FUNCDEF, istring::length(), array< contents >::length(), LOG, and array< contents >::observe().

Referenced by machine_uid::compact_form().

void TEXTUAL_FUNCTION_STYLE byte_format::bytes_to_string ( const byte_array to_convert,
istring as_string,
bool  space_delimited = true 
)

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 254 of file byte_format.cpp.

References bytes_to_string(), array< contents >::length(), and array< contents >::observe().

void TEXTUAL_FUNCTION_STYLE byte_format::bytes_to_string ( const byte to_convert,
int  length,
istring as_string,
bool  space_delimited = true 
)

a version that accepts a byte pointer and length, rather than byte_array.

Definition at line 166 of file byte_format.cpp.

References negative(), istring::s(), and istring::SPRINTF.

Referenced by bytes_to_string(), secret_string::encrypt_string(), main(), and octopus_entity::mangled_form().

bool byte_format::in_hex_range ( char  to_check  ) 

Definition at line 184 of file byte_format.cpp.

Referenced by string_to_bytes().

void byte_format::make_eight ( u_int  num,
istring out 
)

Definition at line 58 of file byte_format.cpp.

References out.

Referenced by text_dump().

void TEXTUAL_FUNCTION_STYLE byte_format::parse_dump ( const istring dumped_form,
byte_array bytes_found 
)

this operation performs the inverse of a text_dump.

Definition at line 124 of file byte_format.cpp.

References string_array::find(), istring::find(), array< contents >::length(), istring::length(), negative(), array< contents >::reset(), string_to_bytes(), and istring::substring().

void TEXTUAL_FUNCTION_STYLE byte_format::print_char ( byte  to_print,
istring out,
char  replace = '_' 
)

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 45 of file byte_format.cpp.

References parser_bits::is_printable_ascii(), and out.

Referenced by print_chars(), and text_dump().

void TEXTUAL_FUNCTION_STYLE byte_format::print_chars ( const byte to_print,
int  len,
istring out,
char  replace = '_' 
)

sends the bytes in "to_print" of "length" bytes into the string "out".

Definition at line 52 of file byte_format.cpp.

References out, and print_char().

void TEXTUAL_FUNCTION_STYLE byte_format::shifted_string_to_bytes ( const istring to_convert,
byte_array as_array 
)

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 284 of file byte_format.cpp.

References bit_vector::bits(), deadly_error, FUNCDEF, array< contents >::length(), istring::length(), LOG, bit_vector::resize(), and bit_vector::set_bit().

Referenced by machine_uid::expand().

void TEXTUAL_FUNCTION_STYLE byte_format::string_to_bytes ( const istring to_convert,
byte_array as_array 
)

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 261 of file byte_format.cpp.

References istring::s(), and string_to_bytes().

void TEXTUAL_FUNCTION_STYLE byte_format::string_to_bytes ( const char *  to_convert,
byte_array as_array 
)

a version that works with the char pointer rather than an istring.

Definition at line 192 of file byte_format.cpp.

References string_manipulation::char_to_hex(), in_hex_range(), and array< contents >::reset().

Referenced by secret_string::decrypt_string(), formal(), octopus_entity::from_text(), main(), parse_dump(), and string_to_bytes().

void TEXTUAL_FUNCTION_STYLE byte_format::text_dump ( istring output,
const byte location,
u_int  length,
u_int  label = 0,
const char *  eol = "\n" 
)

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 90 of file byte_format.cpp.

References LINE_SIZE, make_eight(), print_char(), and istring::SPRINTF.

istring TEXTUAL_FUNCTION_STYLE byte_format::text_dump ( const byte_array to_dump,
u_int  label = 0,
const char *  eol = "\n" 
)

a version that operates on a byte_array and returns a string.

Definition at line 82 of file byte_format.cpp.

References array< contents >::length(), array< contents >::observe(), and text_dump().

void TEXTUAL_FUNCTION_STYLE byte_format::text_dump ( istring output,
const byte_array to_dump,
u_int  label = 0,
const char *  eol = "\n" 
)

a version that operates on a byte_array and stores into a string.

Definition at line 76 of file byte_format.cpp.

References array< contents >::length(), array< contents >::observe(), and text_dump().

istring TEXTUAL_FUNCTION_STYLE byte_format::text_dump ( const byte location,
u_int  length,
u_int  label = 0,
const char *  eol = "\n" 
)

this is a less efficient version of text_dump that returns a string.

it's easier to use when combining istrings.

Definition at line 68 of file byte_format.cpp.

Referenced by cromp_common::chew_hostname(), file_logger::format_bytes(), main(), and text_dump().


Generated on Fri Nov 28 04:31:05 2008 for HOOPLE Libraries by  doxygen 1.5.1