feisty meow concerns codebase  2.140
textual::string_manipulation Class Reference

Provides various functions for massaging strings. More...

#include <string_manipulation.h>

Static Public Member Functions

static basis::astring make_random_name (int min=1, int max=64)
 creates a random name, where the letters are between 'a' and 'z'. More...
 
static basis::astring long_line (char line_item='/', int repeat=76)
 produces a long line of "line_item" characters. More...
 
static basis::astring indentation (int spaces)
 Returns a string made of white space that is "spaces" long. More...
 
static void carriage_returns_to_spaces (basis::astring &to_strip)
 converts carriage returns in "to_strip" into spaces. More...
 
static void split_lines (const basis::astring &input, basis::astring &output, int min_column=0, int max_column=79)
 formats blocks of text for a maximum width. More...
 
static basis::abyte char_to_hex (char to_convert)
 Converts a single character into the corresponding hex nibble. More...
 
static char hex_to_char (basis::abyte to_convert)
 Converts a byte between 0 and 15 into a corresponding hexadecimal character. More...
 
static basis::byte_array string_to_hex (const basis::astring &character_form)
 Turns a string form of a set of hex numbers into an array of bytes. More...
 
static basis::astring hex_to_string (const basis::byte_array &byte_form)
 The inverse of string_to_hex prints "byte_form" as text. More...
 

Detailed Description

Provides various functions for massaging strings.

Definition at line 24 of file string_manipulation.h.

Member Function Documentation

◆ carriage_returns_to_spaces()

void textual::string_manipulation::carriage_returns_to_spaces ( basis::astring 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 60 of file string_manipulation.cpp.

References is_eol(), and basis::astring::length().

◆ char_to_hex()

abyte textual::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 313 of file string_manipulation.cpp.

◆ hex_to_char()

char textual::string_manipulation::hex_to_char ( basis::abyte  to_convert)
static

Converts a byte between 0 and 15 into a corresponding hexadecimal character.

Definition at line 305 of file string_manipulation.cpp.

◆ hex_to_string()

astring textual::string_manipulation::hex_to_string ( const basis::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 337 of file string_manipulation.cpp.

References basis::array< contents >::get(), and basis::array< contents >::length().

◆ indentation()

astring textual::string_manipulation::indentation ( int  spaces)
static

Returns a string made of white space that is "spaces" long.

Definition at line 53 of file string_manipulation.cpp.

Referenced by textual::xml_generator::add_content().

◆ long_line()

astring textual::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 50 of file string_manipulation.cpp.

◆ make_random_name()

astring textual::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".

Definition at line 33 of file string_manipulation.cpp.

References mathematics::chaos::inclusive(), and rando.

◆ split_lines()

void textual::string_manipulation::split_lines ( const basis::astring input,
basis::astring 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 94 of file string_manipulation.cpp.

References basis::astring::find_any(), basis::astring::FROM_END, is_eol(), basis::astring::length(), basis::negative(), textual::splitter_finding_set, basis::astring::strip_spaces(), and basis::astring::substring().

◆ string_to_hex()

byte_array textual::string_manipulation::string_to_hex ( const basis::astring 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 324 of file string_manipulation.cpp.

References basis::array< contents >::concatenate(), basis::astring::get(), basis::astring::length(), and NULL_POINTER.


The documentation for this class was generated from the following files: