#include <string_manipulation.h>
Static Public Member Functions | |
| static istring | make_random_name (int min=1, int max=64) |
| creates a random name, where the letters are between 'a' and 'z'. | |
| static bool | quote_string (const istring &to_modify, istring "ed_string) |
| Quotes the string "to_modify". | |
| static istring | long_line (char line_item= '/', int repeat=76) |
| produces a long line of "line_item" characters. | |
| static istring | indentation (int spaces) |
| Returns a string made of white space that is "spaces" long. | |
| static istring & | escape_chars (istring &input_string) |
| escapes potentially troublesome characters. | |
| static istring & | unescape_chars (istring &input_string) |
| reverses escape_chars(). | |
| static bool | substring (const istring &look_in, const istring &after, const istring &before, istring &found) |
| look for the string "after" in "look_in". | |
| static void | carriage_returns_to_spaces (istring &to_strip) |
| converts carriage returns in "to_strip" into spaces. | |
| static void | split_lines (const istring &input, istring &output, int min_column=0, int max_column=79) |
| formats blocks of text for a maximum width. | |
| static byte | char_to_hex (char to_convert) |
| Converts a single character into the corresponding hex nibble. | |
| static char | hex_to_char (byte to_convert) |
| Converts a byte between 0 and 15 into a corresponding hexadecimal character. | |
| static byte_array | string_to_hex (const istring &character_form) |
| Turns a string form of a set of hex numbers into an array of bytes. | |
| static istring | hex_to_string (const byte_array &byte_form) |
| The inverse of string_to_hex prints "byte_form" as text. | |
Definition at line 24 of file string_manipulation.h.
| static istring string_manipulation::make_random_name | ( | int | min = 1, |
|
| int | max = 64 | |||
| ) | [static] |
creates a random name, where the letters are between 'a' and 'z'.
the underscore will also be used occasionally. the size is random, but the minimum size is "min" while the maximum is "max".
Referenced by creatapose(), formal(), main(), random_name(), octopus_request_id::randomized_id(), run_test_30(), run_test_32(), run_test_34(), test_byte_table(), and test_string_table().
| bool string_manipulation::quote_string | ( | const istring & | to_modify, | |
| istring & | quoted_string | |||
| ) | [static] |
Quotes the string "to_modify".
Uses single quotes if the string contains double quotes, or uses double quotes if the string contains single quotes or no quotes, and doesn't even attempt to quote a string that contains both single and double quotes. (by Brit Minor)
Definition at line 55 of file string_manipulation.cpp.
References istring::contains().
| istring string_manipulation::long_line | ( | char | line_item = '/', |
|
| int | repeat = 76 | |||
| ) | [static] |
produces a long line of "line_item" characters.
returns a string of text that is somewhat long compared to an 80 column output window and which consists of a single character repeated. the character used and the repeat count are both variable.
Definition at line 87 of file string_manipulation.cpp.
| istring string_manipulation::indentation | ( | int | spaces | ) | [static] |
Returns a string made of white space that is "spaces" long.
Definition at line 91 of file string_manipulation.cpp.
Referenced by xml_generator::add_content(), nodes::hier_prefix(), hier_prefix(), mailbox::show(), buffer_manager::show_buffers(), connection_table::show_connections(), zing_table::show_events(), split_lines(), and directory_tree::text_form().
escapes potentially troublesome characters.
looks for all instances of backslash(\) and quote(") characters in the string and places an additional backslash character in front of the existing character. returns a reference to the passed string.
Definition at line 99 of file string_manipulation.cpp.
References istring::insert(), and istring::length().
reverses escape_chars().
looks for all instances of double backslash(\) or backslash quote(\") and removes the extra backslash.
Definition at line 118 of file string_manipulation.cpp.
References istring::length(), and istring::zap().
| bool string_manipulation::substring | ( | const istring & | look_in, | |
| const istring & | after, | |||
| const istring & | before, | |||
| istring & | found | |||
| ) | [static] |
look for the string "after" in "look_in".
if found then look for the string "before" starting at the first location after "after". if found then fill found with all characters after "after" and before "before". return false if before or after are not found.
Definition at line 135 of file string_manipulation.cpp.
References istring::find(), istring::length(), and istring::substring().
| void string_manipulation::carriage_returns_to_spaces | ( | istring & | to_strip | ) | [static] |
converts carriage returns in "to_strip" into spaces.
processes the string "to_strip" by replacing all single carriage returns with spaces and by turning two or more carriage returns into a single CR plus spaces.
Definition at line 151 of file string_manipulation.cpp.
References parser_bits::is_eol(), and istring::length().
Referenced by split_lines().
| void string_manipulation::split_lines | ( | const istring & | input, | |
| istring & | output, | |||
| int | min_column = 0, |
|||
| int | max_column = 79 | |||
| ) | [static] |
formats blocks of text for a maximum width.
processes the "input" text by splitting any lines that are longer than the "max_column". the "min_column" is used to specify how much indentation should be included.
Definition at line 186 of file string_manipulation.cpp.
References portable::break_line(), carriage_returns_to_spaces(), istring::find_any(), istring::FROM_END, indentation(), parser_bits::is_eol(), istring::length(), negative(), log_base::platform_ending(), istring::strip_spaces(), istring::substring(), and parser_bits::white_space().
Referenced by directory_tree::text_form().
| byte string_manipulation::char_to_hex | ( | char | to_convert | ) | [static] |
Converts a single character into the corresponding hex nibble.
If the character is not valid, an arbitrary value is returned.
Definition at line 405 of file string_manipulation.cpp.
Referenced by byte_format::string_to_bytes(), and string_to_hex().
| char string_manipulation::hex_to_char | ( | byte | to_convert | ) | [static] |
Converts a byte between 0 and 15 into a corresponding hexadecimal character.
Definition at line 397 of file string_manipulation.cpp.
Referenced by hex_to_string().
| byte_array string_manipulation::string_to_hex | ( | const istring & | character_form | ) | [static] |
Turns a string form of a set of hex numbers into an array of bytes.
This functions takes a string in "character_form" and returns an array of bytes that is half as long and which contains the hexadecimal interpretation of the string. This is currently geared to even length strings...
Definition at line 416 of file string_manipulation.cpp.
References char_to_hex(), array< contents >::concatenate(), istring::get(), istring::length(), and NIL.
| istring string_manipulation::hex_to_string | ( | const byte_array & | byte_form | ) | [static] |
The inverse of string_to_hex prints "byte_form" as text.
This function takes an array of bytes and converts them into their equivalent hexadecimal character representation.
Definition at line 429 of file string_manipulation.cpp.
References array< contents >::get(), hex_to_char(), and array< contents >::length().
1.5.1