feisty meow concerns codebase  2.140
basis::astring Class Reference

Provides a dynamically resizable ASCII character string. More...

#include <astring.h>

Inheritance diagram for basis::astring:
Collaboration diagram for basis::astring:

Public Types

enum  special_flag { UNTERMINATED = 62 , SPRINTF = 84 }
 
enum  how_to_strip { FROM_FRONT = 1 , FROM_END = 2 , FROM_BOTH_SIDES = 3 }
 

Public Member Functions

 astring ()
 constructs an empty string. More...
 
 astring (const char *initial)
 constructs a copy of the string passed in "initial". More...
 
 astring (char c, int repeat)
 constructs a string with "repeat" characters of "c" in it. More...
 
 astring (const astring &s)
 Constructs a copy of the string "s". More...
 
 astring (const base_string &initial)
 constructs a string from the base class. More...
 
 astring (special_flag way, const char *s,...)
 constructor that sports a few variable parameter constructions. More...
 
virtual ~astring ()
 destroys any storage for the string. More...
 
 DEFINE_CLASS_NAME ("astring")
 
virtual int comparator (const astring &s2) const
 helps to fulfill orderable contract. More...
 
int length () const
 Returns the current length of the string. More...
 
int end () const
 returns the index of the last (non-null) character in the string. More...
 
bool empty () const
 empty() reports if the string is empty, that is, of zero length(). More...
 
bool non_empty () const
 non_empty() reports if the string has some contents. More...
 
bool operator! () const
 the negation operator returns true if the string is empty. More...
 
bool t () const
 t() is a shortcut for the string being "true", as in non-empty. More...
 
virtual const char * observe () const
 observes the underlying pointer to the zero-terminated string. More...
 
const char * c_str () const
 synonym for observe. mimics the STL method name. More...
 
const char * s () const
 synonym for observe. the 's' stands for "string", if that helps. More...
 
virtual char get (int index) const
 a constant peek at the string's internals at the specified index. More...
 
virtual char * access ()
 provides access to the actual string held. More...
 
char * c_str ()
 synonym for access. mimics the STL method. More...
 
char * s ()
 synonym for access. More...
 
char & operator[] (int position)
 accesses individual characters in "this" string. More...
 
const char & operator[] (int position) const
 observes individual characters in "this" string. More...
 
virtual void put (int position, char to_put)
 stores the character "to_put" at index "position" in the string. More...
 
astringsprintf (const char *s,...)
 similar to the SPRINTF constructor, but works on an existing string. More...
 
int convert (int default_value) const
 Converts the string into a corresponding integer. More...
 
long convert (long default_value) const
 converts the string to a long integer. More...
 
float convert (float default_value) const
 converts the string to a floating point number. More...
 
double convert (double default_value) const
 converts the string to a double precision floating point number. More...
 
bool equal_to (const char *that) const
 returns true if "that" is equal to this. More...
 
bool iequals (const astring &that) const
 returns true if this is case-insensitively equal to "that". More...
 
bool iequals (const char *that) const
 returns true if this is case-insensitively equal to "that". More...
 
bool compare (const astring &to_compare, int start_first, int start_second, int count, bool case_sensitive) const
 Compares "this" string with "to_compare". More...
 
bool begins (const astring &maybe_prefix) const
 Returns true if "this" string begins with "maybe_prefix". More...
 
bool ibegins (const astring &maybe_prefix) const
 a case-insensitive method similar to begins(). More...
 
bool ends (const astring &maybe_suffix) const
 returns true if this string ends with "maybe_suffix". More...
 
bool iends (const astring &maybe_suffix) const
 
astringoperator= (const astring &s)
 Sets the contents of this string to "s". More...
 
astringoperator= (const char *s)
 Sets the contents of this string to "s". More...
 
void reset ()
 clears out the contents string. More...
 
void reset (special_flag way, const char *s,...)
 operates like the constructor that takes a 'special_flag'. More...
 
void copy (char *to_stuff, int count) const
 Copies a maximum of "count" characters from this into "to_stuff". More...
 
void stuff (char *to_stuff, int count) const
 a synonym for copy(). More...
 
astring operator+ (const astring &s) const
 Returns the concatenation of "this" and "s". More...
 
astringoperator+= (const astring &s)
 Modifies "this" by concatenating "s" onto it. More...
 
astringoperator+= (const char *s)
 
astring operator+ (const char *s) const
 < synonym for the concatenation operator but uses a char pointer instead. More...
 
astringoperator+= (char c)
 concatenater for single characters. More...
 
int find (char to_find, int position=0, bool reverse=false) const
 Locates "to_find" in "this". More...
 
int find (const astring &to_find, int posn=0, bool reverse=false) const
 finds "to_find" in this string. More...
 
int ifind (char to_find, int position=0, bool reverse=false) const
 like the find() methods above, but case-insensitive. More...
 
int ifind (const astring &to_find, int posn=0, bool reverse=false) const
 like the find() methods above, but case-insensitive. More...
 
int find_any (const char *to_find, int position=0, bool reverse=false) const
 searches for any of the characters in "to_find". More...
 
int ifind_any (const char *to_find, int position=0, bool reverse=false) const
 searches case-insensitively for any of the characters in "to_find". More...
 
int find_non_match (const char *to_find, int position=0, bool reverse=false) const
 searches for any character that is not in "to_find" and returns index. More...
 
bool contains (const astring &to_find) const
 Returns true if "to_find" is contained in this string or false if not. More...
 
bool substring (astring &target, int start, int end) const
 a version that stores the substring in an existing "target" string. More...
 
astring substring (int start, int end) const
 Returns the segment of "this" between the indices "start" and "end". More...
 
astring middle (int start, int count)
 returns the middle of the string from "start" with "count" characters. More...
 
astring left (int count)
 returns the left "count" characters from the string. More...
 
astring right (int count)
 returns the right "count" characters from the string. More...
 
void pad (int length, char padding=' ')
 makes the string "length" characters long. More...
 
void trim (int length)
 shortens the string to "length" if it's longer than that. More...
 
void insert (int position, const astring &to_insert)
 Copies "to_insert" into "this" at the "position". More...
 
virtual void zap (int start, int end)
 Deletes the characters between "start" and "end" inclusively. More...
 
void to_lower ()
 to_lower modifies "this" by replacing capitals with lower-case. More...
 
void to_upper ()
 to_upper does the opposite of to_lower (that is, q becomes Q). More...
 
astring lower () const
 like to_lower(), but returns a new string rather than modifying this. More...
 
astring upper () const
 like to_upper(), but returns a new string rather than modifying this. More...
 
bool replace (const astring &tag, const astring &replacement)
 replaces the first occurrence of "tag" text with the "replacement". More...
 
bool replace_all (char to_replace, char new_char)
 changes all occurrences of "to_replace" with "new_char". More...
 
bool replace_all (const astring &to_replace, const astring &new_string)
 
void shrink ()
 changes all occurrences of "to_replace" into "new_string". More...
 
void strip (const astring &strip_list, how_to_strip way=FROM_BOTH_SIDES)
 strips all chars from "strip_list" out of "this" given the "way". More...
 
void strip_spaces (how_to_strip way=FROM_BOTH_SIDES)
 removes excess space characters from string's beginning, end or both. More...
 
void strip_white_spaces (how_to_strip way=FROM_BOTH_SIDES)
 like strip_spaces, but includes tabs in the list to strip. More...
 
int packed_size () const
 Reports the size required to pack this string into a byte array. More...
 
void pack (byte_array &target) const
 stores this string in the "target". it can later be unpacked again. More...
 
bool unpack (byte_array &source)
 retrieves a string (packed with pack()) from "source" into this string. More...
 
virtual bool equal_to (const equalizable &s2) const
 < provides a case insensitive comparison routine. More...
 
virtual bool less_than (const orderable &s2) const
 
virtual base_stringconcatenate_string (const base_string &s)
 Modifies "this" by concatenating "s" onto it. More...
 
virtual base_stringconcatenate_char (char c)
 concatenater for single characters. More...
 
virtual base_stringassign (const base_string &s)
 Sets the contents of this string to "s". More...
 
virtual base_stringupgrade (const char *s)
 Sets the contents of this string to "s". More...
 
virtual bool sub_string (base_string &target, int start, int end) const
 Gets the segment of "this" between the indices "start" and "end". More...
 
virtual bool sub_compare (const base_string &to_compare, int start_first, int start_second, int count, bool case_sensitive) const
 Compares "this" string with "to_compare". More...
 
virtual void insert (int position, const base_string &to_insert)
 Copies "to_insert" into "this" at the "position". More...
 
virtual void text_form (base_string &state_fill) const
 Provides a text view of all the important info owned by this object. More...
 
astringbase_sprintf (const char *s, va_list &args)
 
byte_arrayget_implementation ()
 
- Public Member Functions inherited from basis::base_string
virtual base_stringoperator= (const base_string &to_copy)
 sets this string's contents equal to the contents of "to_copy". More...
 
- Public Member Functions inherited from basis::orderable
virtual bool operator< (const orderable &s2) const
 the virtual method for object ordering. More...
 
- Public Member Functions inherited from basis::equalizable
virtual bool operator== (const equalizable &s2) const
 the virtual method for object equality. More...
 
- Public Member Functions inherited from basis::text_formable
virtual const char * class_name () const =0
 Returns the bare name of this class as a constant character pointer. More...
 

Static Public Member Functions

static const astringempty_string ()
 useful wherever empty strings are needed, e.g., function defaults. More...
 
static bool matches (const astring &match_list, char to_match)
 returns true if "to_match" is found in the "match_list" string. More...
 

Detailed Description

Provides a dynamically resizable ASCII character string.

It mimics the standard (char *) type, but provides a slew of helpful methods as well as enforcing bounds checking on the underlying array.

Definition at line 32 of file astring.h.

Member Enumeration Documentation

◆ how_to_strip

Enumerator
FROM_FRONT 
FROM_END 
FROM_BOTH_SIDES 

Definition at line 319 of file astring.h.

◆ special_flag

Enumerator
UNTERMINATED 
SPRINTF 

Definition at line 54 of file astring.h.

Constructor & Destructor Documentation

◆ astring() [1/6]

◆ astring() [2/6]

basis::astring::astring ( const char *  initial)

constructs a copy of the string passed in "initial".

Definition at line 90 of file astring.cpp.

References access(), basis::array< contents >::internal_offset_mem(), and basis::array< contents >::put().

◆ astring() [3/6]

basis::astring::astring ( char  c,
int  repeat 
)

constructs a string with "repeat" characters of "c" in it.

if "c" is the null character (i.e., equal to zero), then the resulting string will have "repeat" space characters in it.

Definition at line 69 of file astring.cpp.

References basis::array< contents >::access(), basis::array< contents >::internal_offset_mem(), basis::array< contents >::length(), and basis::array< contents >::put().

◆ astring() [4/6]

basis::astring::astring ( const astring s)

Constructs a copy of the string "s".

Definition at line 83 of file astring.cpp.

◆ astring() [5/6]

basis::astring::astring ( const base_string initial)

constructs a string from the base class.

Definition at line 64 of file astring.cpp.

◆ astring() [6/6]

basis::astring::astring ( special_flag  way,
const char *  s,
  ... 
)

constructor that sports a few variable parameter constructions.

For a flag of "UNTERMINATED", the constructor expects the third parameter to be an integer, and then it copies that number of characters from the C-string "s" without assuming that "s" is zero terminated.

For a flag of "SPRINTF", a string is constructed using the format specifier in "s" in a manner similar to the standard library "sprintf" function (see the standard library for <string.h>). If there are no "%" codes in "s", then the constructor just copies "s" without modification. If "%" codes are in the character array, then any additional arguments (...) are interpreted as they would be by sprintf. The length of the constructed string is tailored to fit the actual contents. If "s" is null, then the resulting string will be empty. Currently, the "*" specifier for variable length fields is not supported.

Definition at line 99 of file astring.cpp.

References astring(), base_sprintf(), length(), operator=(), basis::array< contents >::reset(), SPRINTF, and UNTERMINATED.

◆ ~astring()

basis::astring::~astring ( )
virtual

destroys any storage for the string.

Definition at line 126 of file astring.cpp.

References NULL_POINTER.

Member Function Documentation

◆ access()

char * basis::astring::access ( )
virtual

provides access to the actual string held.

this should never return NULL_POINTER. be very careful with the returned pointer: don't destroy or corrupt its contents (e.g., do not mess with its zero termination).

Implements basis::base_string.

Definition at line 136 of file astring.cpp.

References basis::array< contents >::access().

Referenced by astring(), c_str(), and filesystem::byte_filer::getline().

◆ assign()

base_string & basis::astring::assign ( const base_string s)
virtual

Sets the contents of this string to "s".

Implements basis::base_string.

Definition at line 1064 of file astring.cpp.

References astring(), and s().

◆ base_sprintf()

astring & basis::astring::base_sprintf ( const char *  s,
va_list &  args 
)

Definition at line 183 of file astring.cpp.

References reset().

Referenced by basis::a_sprintf::a_sprintf(), astring(), reset(), and sprintf().

◆ begins()

bool basis::astring::begins ( const astring maybe_prefix) const
inline

Returns true if "this" string begins with "maybe_prefix".

Definition at line 178 of file astring.h.

Referenced by structures::string_table::is_comment().

◆ c_str() [1/2]

char* basis::astring::c_str ( )
inline

synonym for access. mimics the STL method.

Definition at line 124 of file astring.h.

References access().

◆ c_str() [2/2]

const char* basis::astring::c_str ( ) const
inline

synonym for observe. mimics the STL method name.

Definition at line 111 of file astring.h.

◆ comparator()

int basis::astring::comparator ( const astring s2) const
virtual

helps to fulfill orderable contract.

Definition at line 156 of file astring.cpp.

References observe().

Referenced by equal_to(), and less_than().

◆ compare()

bool basis::astring::compare ( const astring to_compare,
int  start_first,
int  start_second,
int  count,
bool  case_sensitive 
) const

Compares "this" string with "to_compare".

The "start_first" is where the comparison begins in "this" string, and "start_second" where it begins in the "to_compare". The "count" is the number of characters to compare between the two strings. If either index is out of range, or "count"-1 + either index is out of range, then compare returns false. If the strings differ in that range, false is returned. Only if the strings have identical contents in the range is true returned.

Definition at line 810 of file astring.cpp.

References bounds_return, end(), length(), and observe().

Referenced by bookmark_tree::advance(), filesystem::filename::canonicalize(), write_build_config::check_nesting(), bookmark_tree::excellent_link_comparator(), write_build_config::execute(), processes::process_control::find_process_in_list(), ibegins(), and sub_compare().

◆ concatenate_char()

base_string & basis::astring::concatenate_char ( char  c)
virtual

concatenater for single characters.

Implements basis::base_string.

Definition at line 1058 of file astring.cpp.

◆ concatenate_string()

base_string & basis::astring::concatenate_string ( const base_string s)
virtual

Modifies "this" by concatenating "s" onto it.

Implements basis::base_string.

Definition at line 1050 of file astring.cpp.

References astring(), and s().

◆ contains()

bool basis::astring::contains ( const astring to_find) const

Returns true if "to_find" is contained in this string or false if not.

Definition at line 162 of file astring.cpp.

References find().

Referenced by sockets::internet_address::is_valid_internet_address(), write_build_config::output_decorated_macro(), write_build_config::output_macro(), and bookmark_tree::process_comment().

◆ convert() [1/4]

double basis::astring::convert ( double  default_value) const

converts the string to a double precision floating point number.

Definition at line 784 of file astring.cpp.

References length(), and observe().

◆ convert() [2/4]

float basis::astring::convert ( float  default_value) const

converts the string to a floating point number.

Definition at line 775 of file astring.cpp.

References length(), and observe().

◆ convert() [3/4]

int basis::astring::convert ( int  default_value) const

Converts the string into a corresponding integer.

The conversion starts at index 0 in "this" string, and stores it in "value". If a valid integer was found, it is returned. otherwise, the "default_value" is returned. NOTE: be careful of implicit conversions here; the "default_value" for any of these functions must either be an object of the exact type needed or must be cast to that type.

Definition at line 757 of file astring.cpp.

References length(), and observe().

Referenced by sockets::subnet_calculator::convert(), processes::configured_applications::find_program(), geometric::point< numeric_type >::from_text(), geometric::rectangle< numeric_type >::from_text(), sockets::internet_address::ip_appropriate_number(), sockets::internet_address::is_valid_internet_address(), configuration::configurator::load(), processes::configured_applications::parse_startup_entry(), and filesystem::file_time::unpack().

◆ convert() [4/4]

long basis::astring::convert ( long  default_value) const

converts the string to a long integer.

Definition at line 766 of file astring.cpp.

References length(), and observe().

◆ copy()

void basis::astring::copy ( char *  to_stuff,
int  count 
) const

Copies a maximum of "count" characters from this into "to_stuff".

The target "to_stuff" is a standard C-string. The terminating zero from this string is also copied. BE CAREFUL: if "count"+1 is greater than the allocated length of the C-string "to_stuff", then an invalid memory write will occur. keep in mind that the terminating zero will be put at position "count" in the C-string if the full "count" of characters are copied.

Definition at line 556 of file astring.cpp.

References length(), basis::minimum(), and observe().

◆ DEFINE_CLASS_NAME()

basis::astring::DEFINE_CLASS_NAME ( "astring"  )

◆ empty()

bool basis::astring::empty ( ) const
inline

empty() reports if the string is empty, that is, of zero length().

Definition at line 90 of file astring.h.

Referenced by octopi::octopus_entity::blank(), and t().

◆ empty_string()

const astring & basis::astring::empty_string ( )
static

useful wherever empty strings are needed, e.g., function defaults.

note that this is implemented in the opsystem library to avoid bad issues with static objects mixed into multiple dlls from a static library.

Definition at line 128 of file astring.cpp.

Referenced by textual::list_parsing::create_csv_line().

◆ end()

◆ ends()

bool basis::astring::ends ( const astring maybe_suffix) const
inline

returns true if this string ends with "maybe_suffix".

a case-insensitive method similar to ends().

Definition at line 187 of file astring.h.

Referenced by main(), and stamping_spider().

◆ equal_to() [1/2]

◆ equal_to() [2/2]

bool basis::astring::equal_to ( const equalizable s2) const
virtual

< provides a case insensitive comparison routine.

< this uses the best methods available (that is, it uses a system function if one exists). the string "to_compare" is compared with this string. if the "length" is negative, then this entire string is compared with the entire string "to_compare". otherwise, only "length" characters from this string are compared. if this string is before "to_compare" in a lexicographic ordering (basically alphabetical), then a negative number is returned. if this string is after "to_compare", then a positive number is returned. zero is returned if the two strings are equal for the extent of interest. int icompare(const char *to_compare, int length = -1) const; < a version of the above for raw character pointers. static int slow_strncasecmp(const char *first, const char *second, int length = -1); < a replacement for strncasecmp on platforms without them.

< this is slow because it cannot rely on OS methods to perform the comparison. if the "length" is negative, then the entire string "first" is compared to "second". otherwise just "length" characters are compared. this follows the standard library strncasecmp method: the return value can be in three states: negative, zero and positive. zero means the strings are identical lexicographically , whereas less than zero means "this_string" is less than "to_compare" and greater than zero means "this_string" is greater than "to_compare".

Implements basis::equalizable.

Definition at line 143 of file astring.cpp.

References basis::cast_or_throw(), and comparator().

◆ find() [1/2]

◆ find() [2/2]

int basis::astring::find ( const astring to_find,
int  posn = 0,
bool  reverse = false 
) const

finds "to_find" in this string.

Definition at line 671 of file astring.cpp.

◆ find_any()

int basis::astring::find_any ( const char *  to_find,
int  position = 0,
bool  reverse = false 
) const

searches for any of the characters in "to_find".

the first occurrence of any of those is returned, or a negative number is returned if no matches are found.

Definition at line 577 of file astring.cpp.

Referenced by textual::string_manipulation::split_lines().

◆ find_non_match()

int basis::astring::find_non_match ( const char *  to_find,
int  position = 0,
bool  reverse = false 
) const

searches for any character that is not in "to_find" and returns index.

Definition at line 583 of file astring.cpp.

◆ get()

◆ get_implementation()

byte_array & basis::astring::get_implementation ( )

Definition at line 134 of file astring.cpp.

◆ ibegins()

bool basis::astring::ibegins ( const astring maybe_prefix) const
inline

a case-insensitive method similar to begins().

Definition at line 182 of file astring.h.

References compare(), and length().

◆ iends()

bool basis::astring::iends ( const astring maybe_suffix) const
inline

Definition at line 192 of file astring.h.

Referenced by whacking_spider().

◆ iequals() [1/2]

◆ iequals() [2/2]

bool basis::astring::iequals ( const char *  that) const

returns true if this is case-insensitively equal to "that".

Definition at line 568 of file astring.cpp.

References observe().

◆ ifind() [1/2]

int basis::astring::ifind ( char  to_find,
int  position = 0,
bool  reverse = false 
) const

like the find() methods above, but case-insensitive.

Definition at line 571 of file astring.cpp.

◆ ifind() [2/2]

int basis::astring::ifind ( const astring to_find,
int  posn = 0,
bool  reverse = false 
) const

like the find() methods above, but case-insensitive.

Definition at line 674 of file astring.cpp.

◆ ifind_any()

int basis::astring::ifind_any ( const char *  to_find,
int  position = 0,
bool  reverse = false 
) const

searches case-insensitively for any of the characters in "to_find".

the first occurrence of any of those is returned, or a negative number is returned if none are found.

Definition at line 580 of file astring.cpp.

◆ insert() [1/2]

◆ insert() [2/2]

void basis::astring::insert ( int  position,
const base_string to_insert 
)
virtual

Copies "to_insert" into "this" at the "position".

Characters at the index "position" and greater are moved over.

Implements basis::base_string.

Definition at line 1094 of file astring.cpp.

References astring(), insert(), and basis::base_string::observe().

◆ left()

astring basis::astring::left ( int  count)

returns the left "count" characters from the string.

Definition at line 886 of file astring.cpp.

References substring().

◆ length()

int basis::astring::length ( ) const
virtual

Returns the current length of the string.

The length returned does not include the terminating null character at the end of the string.

Implements basis::base_string.

Definition at line 132 of file astring.cpp.

References basis::array< contents >::length().

Referenced by configuration::ini_parser::add(), bookmark_tree::advance(), sockets::internet_address::appropriate_for_ip(), astring(), bogon::bogon(), processes::launch_process::break_line(), textual::byte_formatter::bytes_to_shifted_string(), filesystem::filename::canonicalize(), textual::string_manipulation::carriage_returns_to_spaces(), cromp::cromp_common::chew_hostname(), textual::xml_generator::clean_reserved_mod(), application::command_line::command_line(), compare(), filesystem::directory_tree::compare_trees(), sockets::subnet_calculator::convert(), convert(), copy(), creatapose(), geometric::crop_non_numeric(), geometric::crop_numeric(), cromp::cromp_common::decode_host(), configuration::registry_configurator::delete_entry(), configuration::registry_configurator::delete_section(), filesystem::filename::detooth_filename(), filesystem::filename::drive(), textual::list_parsing::emit_quoted_chunk(), end(), bookmark_tree::excellent_link_comparator(), filesystem::filename::exists(), filesystem::filename::extension(), application::command_line::find(), configuration::registry_configurator::fix_section(), configuration::application_configuration::get_cmdline_from_proc(), application::command_line::get_command_line(), textual::list_parsing::get_ids_from_string(), configuration::registry_configurator::get_section(), configuration::ini_configurator::get_section(), application::command_line::get_value(), sockets::internet_address::has_ip_address(), structures::astring_hasher::hash(), ibegins(), basis::imatches_any(), insert(), sockets::internet_machine_uid::internet_machine_uid(), sockets::internet_address::ip_appropriate_number(), configuration::variable_tokenizer::is_eol_a_separator(), application::launch_manager::launch_now(), loggers::file_logger::log(), application::application_shell::log(), main(), filesystem::directory_tree::make_directories(), octopi::octopus_entity::mangled_form(), matches(), basis::matches_any(), basis::matches_none(), operator+=(), bogon::operator=(), packed_size(), filesystem::file_transfer_header::packed_size(), structures::string_set::packed_size(), structures::string_table::packed_size(), octopi::octopus_entity::packed_size(), pad(), textual::byte_formatter::parse_dump(), configuration::registry_configurator::put(), configuration::ini_configurator::put(), configuration::table_configurator::put(), bookmark_tree::read_csv_file(), replace_all(), versions::replace_version_entry(), reset(), versions::version_checker::retrieve_version(), octopi::SAFE_STATIC_CONST(), configuration::registry_configurator::section_exists(), filesystem::filename::separate(), application::command_line::separate_command_line(), textual::byte_formatter::shifted_string_to_bytes(), show_message(), processes::post_office::show_routes(), textual::string_manipulation::split_lines(), strain_out_html_codes(), textual::string_manipulation::string_to_hex(), strip(), textual::parser_bits::substitute_env_vars(), octopi::octopus_entity::text_form(), filesystem::directory_tree::text_form(), to_lower(), to_upper(), trim(), structures::version::version(), filesystem::byte_filer::write(), application::stdio_redirecter::write(), and versions::version_ini::write_rc().

◆ less_than()

bool basis::astring::less_than ( const orderable s2) const
virtual

Implements basis::orderable.

Definition at line 149 of file astring.cpp.

References comparator().

◆ lower()

astring basis::astring::lower ( ) const

like to_lower(), but returns a new string rather than modifying this.

Definition at line 542 of file astring.cpp.

References to_lower().

Referenced by versions::version_ini::executable(), processes::process_control::find_process_in_list(), and versions::version_ini::ole_auto_registering().

◆ matches()

bool basis::astring::matches ( const astring match_list,
char  to_match 
)
static

returns true if "to_match" is found in the "match_list" string.

Definition at line 941 of file astring.cpp.

References get(), and length().

Referenced by strip().

◆ middle()

astring basis::astring::middle ( int  start,
int  count 
)

returns the middle of the string from "start" with "count" characters.

Definition at line 883 of file astring.cpp.

References substring().

◆ non_empty()

bool basis::astring::non_empty ( ) const
inline

non_empty() reports if the string has some contents.

Definition at line 92 of file astring.h.

◆ observe()

◆ operator!()

bool basis::astring::operator! ( ) const
inline

the negation operator returns true if the string is empty.

it can be used in expressions in a readable way, for example: if (!my_string) { it_is_empty; }

Definition at line 94 of file astring.h.

◆ operator+() [1/2]

astring basis::astring::operator+ ( const astring s) const

Returns the concatenation of "this" and "s".

Definition at line 732 of file astring.cpp.

◆ operator+() [2/2]

astring basis::astring::operator+ ( const char *  s) const
inline

< synonym for the concatenation operator but uses a char pointer instead.

synonym for the concatenation operator but uses a char pointer instead.

Definition at line 227 of file astring.h.

◆ operator+=() [1/3]

astring & basis::astring::operator+= ( char  c)

concatenater for single characters.

Definition at line 802 of file astring.cpp.

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

◆ operator+=() [2/3]

astring & basis::astring::operator+= ( const astring s)

Modifies "this" by concatenating "s" onto it.

Definition at line 165 of file astring.cpp.

References insert(), and length().

Referenced by pad().

◆ operator+=() [3/3]

astring & basis::astring::operator+= ( const char *  s)

Definition at line 793 of file astring.cpp.

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

◆ operator=() [1/2]

astring & basis::astring::operator= ( const astring s)

Sets the contents of this string to "s".

Definition at line 507 of file astring.cpp.

Referenced by astring(), and reset().

◆ operator=() [2/2]

astring & basis::astring::operator= ( const char *  s)

Sets the contents of this string to "s".

Definition at line 514 of file astring.cpp.

References reset().

◆ operator[]() [1/2]

char & basis::astring::operator[] ( int  position)

accesses individual characters in "this" string.

if the "position" is out of range, the return value is not meaningful.

Definition at line 739 of file astring.cpp.

References end(), and basis::array< contents >::use().

◆ operator[]() [2/2]

const char & basis::astring::operator[] ( int  position) const

observes individual characters in "this" string.

if the "position" is out of range, the return value is not meaningful.

Definition at line 748 of file astring.cpp.

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

◆ pack()

◆ packed_size()

int basis::astring::packed_size ( ) const

Reports the size required to pack this string into a byte array.

Definition at line 959 of file astring.cpp.

References length().

Referenced by filesystem::directory_tree::packed_size(), and filesystem::file_info::packed_size().

◆ pad()

void basis::astring::pad ( int  length,
char  padding = ' ' 
)

makes the string "length" characters long.

this string is padded with the "padding" character if the string is less than that length initially.

Definition at line 493 of file astring.cpp.

References astring(), length(), operator+=(), and UNTERMINATED.

Referenced by filesystem::byte_filer::getline(), and filesystem::byte_filer::read().

◆ put()

virtual void basis::astring::put ( int  position,
char  to_put 
)
inlinevirtual

stores the character "to_put" at index "position" in the string.

Implements basis::base_string.

Definition at line 138 of file astring.h.

Referenced by filesystem::filename::canonicalize(), and replace_all().

◆ replace()

bool basis::astring::replace ( const astring tag,
const astring replacement 
)

replaces the first occurrence of "tag" text with the "replacement".

true is returned if the "tag" was actually found and replaced.

Definition at line 905 of file astring.cpp.

References end(), find(), insert(), basis::negative(), and zap().

Referenced by versions::version_ini::one_stop_version_stamp().

◆ replace_all() [1/2]

bool basis::astring::replace_all ( char  to_replace,
char  new_char 
)

changes all occurrences of "to_replace" with "new_char".

Definition at line 929 of file astring.cpp.

References get(), length(), and put().

Referenced by main().

◆ replace_all() [2/2]

bool basis::astring::replace_all ( const astring to_replace,
const astring new_string 
)

Definition at line 914 of file astring.cpp.

References find(), insert(), length(), basis::negative(), and zap().

◆ reset() [1/2]

◆ reset() [2/2]

void basis::astring::reset ( special_flag  way,
const char *  s,
  ... 
)

operates like the constructor that takes a 'special_flag'.

Definition at line 467 of file astring.cpp.

References astring(), base_sprintf(), length(), operator=(), reset(), basis::array< contents >::reset(), SPRINTF, and UNTERMINATED.

◆ right()

astring basis::astring::right ( int  count)

returns the right "count" characters from the string.

Definition at line 889 of file astring.cpp.

References end(), and substring().

◆ s() [1/2]

char* basis::astring::s ( )
inline

synonym for access.

Definition at line 126 of file astring.h.

◆ s() [2/2]

const char* basis::astring::s ( ) const
inline

synonym for observe. the 's' stands for "string", if that helps.

Definition at line 113 of file astring.h.

Referenced by filesystem::directory::absolute_path(), processes::configured_applications::add_program(), loggers::critical_events::alert_message(), assign(), octopi::octopus_entity::breakout(), textual::byte_formatter::bytes_to_shifted_string(), textual::byte_formatter::bytes_to_string(), cromp::cromp_common::chew_hostname(), filesystem::filename::chmod(), versions::version_checker::complain_cannot_load(), versions::version_checker::complain_wrong_version(), concatenate_string(), timely::convert(), creatapose(), do_checksum(), do_fletcher_checksum(), filesystem::file_time::file_time(), loggers::critical_events::FL_continuable_error(), loggers::critical_events::FL_deadly_error(), loggers::critical_events::FL_non_continuable_error(), cromp::cromp_transaction::flatten(), structures::bit_vector::get(), configuration::application_configuration::get_cmdline_from_proc(), versions::version_checker::good_version(), header_string(), sockets::internet_address::is_valid_internet_address(), application::launch_manager::launch_now(), loggers::file_logger::log(), main(), filesystem::directory::make_directory(), processes::transition_map::make_transition(), octopi::octopus_entity::mangled_form(), versions::version_ini::one_stop_version_stamp(), filesystem::byte_filer::open(), cromp::cromp_transaction::peek_header(), nechung_oracle::pick_random(), print_instructions(), processes::transition_map::pulse(), sockets::socket_minder::push_receives(), sockets::socket_minder::push_sends(), configuration::registry_configurator::put(), configuration::application_configuration::query_for_process_info(), filesystem::directory::remove_directory(), processes::rendezvous::rendezvous(), filesystem::directory::rescan(), filesystem::file_time::reset(), processes::launch_process::run(), sockets::raw_socket::select(), basis::environment::set(), filesystem::file_time::set_time(), textual::byte_formatter::shifted_string_to_bytes(), standard_sprintf_test(), textual::byte_formatter::string_to_bytes(), geometric::point< numeric_type >::text_form(), nodes::symbol_tree::text_form(), processes::process_entry::text_form(), octopi::octopus_entity::text_form(), sockets::socket_data::text_form(), manifest_chunk::text_form(), structures::memory_limiter::text_form(), processes::transition_map::time_slice(), loggers::file_logger::truncate(), upgrade(), versions::version_ini::write_rc(), and loggers::critical_events::write_to_critical_events().

◆ shrink()

void basis::astring::shrink ( )

changes all occurrences of "to_replace" into "new_string".

resizes the string to its minimum possible length. this fixes any situations where a null character has been inserted into the middle of the string. the string is truncated after the first null charater encountered and its size is corrected. this also repairs any case where the string was originally longer than it is now.

Definition at line 168 of file astring.cpp.

References observe(), and basis::array< contents >::swap_contents().

Referenced by configuration::ini_configurator::get_section(), filesystem::byte_filer::getline(), and filesystem::byte_filer::read().

◆ sprintf()

astring & basis::astring::sprintf ( const char *  s,
  ... 
)

similar to the SPRINTF constructor, but works on an existing string.

any existing contents in the string are wiped out.

Definition at line 174 of file astring.cpp.

References base_sprintf().

◆ strip()

void basis::astring::strip ( const astring strip_list,
how_to_strip  way = FROM_BOTH_SIDES 
)

strips all chars from "strip_list" out of "this" given the "way".

Definition at line 948 of file astring.cpp.

References end(), FROM_END, FROM_FRONT, get(), length(), matches(), and zap().

Referenced by strip_white_spaces().

◆ strip_spaces()

void basis::astring::strip_spaces ( how_to_strip  way = FROM_BOTH_SIDES)
inline

removes excess space characters from string's beginning, end or both.

Definition at line 325 of file astring.h.

Referenced by bookmark_tree::break_name(), write_build_config::execute(), bookmark_tree::read_csv_file(), and textual::string_manipulation::split_lines().

◆ strip_white_spaces()

void basis::astring::strip_white_spaces ( how_to_strip  way = FROM_BOTH_SIDES)
inline

like strip_spaces, but includes tabs in the list to strip.

Definition at line 329 of file astring.h.

References strip().

Referenced by configuration::ini_configurator::sections().

◆ stuff()

void basis::astring::stuff ( char *  to_stuff,
int  count 
) const
inline

◆ sub_compare()

bool basis::astring::sub_compare ( const base_string to_compare,
int  start_first,
int  start_second,
int  count,
bool  case_sensitive 
) const
virtual

Compares "this" string with "to_compare".

The "start_first" is where the comparison begins in "this" string, and "start_second" where it begins in the "to_compare". The "count" is the number of characters to compare between the two strings. If either index is out of range, or "count"-1 + either index is out of range, then compare returns false. If the strings differ in that range, false is returned. Only if the strings have identical contents in the range is true returned. If case-sensitive is false, then matches will not require the caps and lower-case match.

Implements basis::base_string.

Definition at line 1085 of file astring.cpp.

References astring(), compare(), and basis::base_string::observe().

◆ sub_string()

bool basis::astring::sub_string ( base_string target,
int  start,
int  end 
) const
virtual

Gets the segment of "this" between the indices "start" and "end".

false is returned if the range is invalid.

Implements basis::base_string.

Definition at line 1078 of file astring.cpp.

References end(), and substring().

◆ substring() [1/2]

◆ substring() [2/2]

astring basis::astring::substring ( int  start,
int  end 
) const

Returns the segment of "this" between the indices "start" and "end".

An empty string is returned if the indices are out of range.

Definition at line 876 of file astring.cpp.

References end(), and substring().

◆ t()

◆ text_form()

◆ to_lower()

void basis::astring::to_lower ( )

to_lower modifies "this" by replacing capitals with lower-case.

every capital letter is replaced with the corresponding lower case letter (i.e., A becomes a).

Definition at line 528 of file astring.cpp.

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

Referenced by versions::version_ini::executable(), sockets::tcpip_stack::fill_and_resolve(), application::command_line::find(), versions::version_ini::get_record(), lower(), main(), versions::version_checker::module_name(), application::launch_manager::query_application(), and sockets::SAFE_STATIC_CONST().

◆ to_upper()

void basis::astring::to_upper ( )

to_upper does the opposite of to_lower (that is, q becomes Q).

Definition at line 535 of file astring.cpp.

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

Referenced by upper().

◆ trim()

void basis::astring::trim ( int  length)

shortens the string to "length" if it's longer than that.

Definition at line 501 of file astring.cpp.

References end(), length(), and zap().

◆ unpack()

bool basis::astring::unpack ( byte_array source)

retrieves a string (packed with pack()) from "source" into this string.

note that the string is grabbed from the array destructively; whatever portion of the byte array was used to store the string will be removed from the head of the array.

Definition at line 964 of file astring.cpp.

References basis::detach().

Referenced by filesystem::directory_tree::unpack(), filesystem::file_info::unpack(), filesystem::file_time::unpack(), filesystem::file_transfer_header::unpack(), structures::string_table::unpack(), octopi::octopus_entity::unpack(), and octopi::file_transfer_infoton::unpack().

◆ upgrade()

base_string & basis::astring::upgrade ( const char *  s)
virtual

Sets the contents of this string to "s".

Implements basis::base_string.

Definition at line 1072 of file astring.cpp.

References s().

◆ upper()

astring basis::astring::upper ( ) const

like to_upper(), but returns a new string rather than modifying this.

Definition at line 549 of file astring.cpp.

References to_upper().

◆ zap()

void basis::astring::zap ( int  start,
int  end 
)
virtual

Deletes the characters between "start" and "end" inclusively.

C++ array conventions are used (0 through length()-1 are valid). If either index is out of bounds, then the string is not modified.

Implements basis::base_string.

Definition at line 521 of file astring.cpp.

References bounds_return, end(), and basis::array< contents >::zap().

Referenced by configuration::ini_parser::add(), filesystem::filename::basename(), processes::launch_process::break_line(), bookmark_tree::break_name(), octopi::octopus_entity::breakout(), filesystem::filename::canonicalize(), sockets::subnet_calculator::convert(), geometric::crop_non_numeric(), geometric::crop_numeric(), filesystem::filename::dirname(), nechung_oracle::display_random(), write_build_config::execute(), processes::configured_applications::find_program(), configuration::application_configuration::get_cmdline_from_proc(), main(), configuration::variable_tokenizer::parse(), bookmark_tree::process_comment(), bookmark_tree::process_link(), bookmark_tree::read_csv_file(), replace(), replace_all(), versions::replace_version_entry(), versions::version_checker::retrieve_version(), configuration::ini_configurator::sections(), strain_out_html_codes(), strip(), textual::parser_bits::substitute_env_vars(), configuration::variable_tokenizer::text_form(), sockets::internet_address::tokenize(), textual::parser_bits::translate_CR_for_platform(), trim(), versions::version_ini::write_assembly(), and loggers::critical_events::write_to_critical_events().


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