feisty meow concerns codebase
2.140
|
Provides a dynamically resizable ASCII character string. More...
#include <astring.h>
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... | |
astring & | sprintf (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 |
astring & | operator= (const astring &s) |
Sets the contents of this string to "s". More... | |
astring & | operator= (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... | |
astring & | operator+= (const astring &s) |
Modifies "this" by concatenating "s" onto it. More... | |
astring & | operator+= (const char *s) |
astring | operator+ (const char *s) const |
< synonym for the concatenation operator but uses a char pointer instead. More... | |
astring & | operator+= (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_string & | concatenate_string (const base_string &s) |
Modifies "this" by concatenating "s" onto it. More... | |
virtual base_string & | concatenate_char (char c) |
concatenater for single characters. More... | |
virtual base_string & | assign (const base_string &s) |
Sets the contents of this string to "s". More... | |
virtual base_string & | upgrade (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... | |
astring & | base_sprintf (const char *s, va_list &args) |
byte_array & | get_implementation () |
Public Member Functions inherited from basis::base_string | |
virtual base_string & | operator= (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 astring & | empty_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... | |
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.
basis::astring::astring | ( | ) |
constructs an empty string.
Definition at line 59 of file astring.cpp.
Referenced by assign(), astring(), filesystem::file_info::calculate(), filesystem::filename::canonicalize(), concatenate_string(), filesystem::filename::default_separator(), filesystem::filename::dirname(), filesystem::filename::filename(), insert(), pad(), reset(), sub_compare(), and filesystem::file_info::text_form().
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().
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().
basis::astring::astring | ( | const astring & | s | ) |
Constructs a copy of the string "s".
Definition at line 83 of file astring.cpp.
basis::astring::astring | ( | const base_string & | initial | ) |
constructs a string from the base class.
Definition at line 64 of file astring.cpp.
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.
|
virtual |
destroys any storage for the string.
Definition at line 126 of file astring.cpp.
References NULL_POINTER.
|
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().
|
virtual |
Sets the contents of this string to "s".
Implements basis::base_string.
Definition at line 1064 of file astring.cpp.
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().
|
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().
|
inline |
|
inline |
|
virtual |
helps to fulfill orderable contract.
Definition at line 156 of file astring.cpp.
References observe().
Referenced by equal_to(), and less_than().
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().
|
virtual |
concatenater for single characters.
Implements basis::base_string.
Definition at line 1058 of file astring.cpp.
|
virtual |
Modifies "this" by concatenating "s" onto it.
Implements basis::base_string.
Definition at line 1050 of file astring.cpp.
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().
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.
float basis::astring::convert | ( | float | default_value | ) | const |
converts the string to a floating point number.
Definition at line 775 of file astring.cpp.
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().
long basis::astring::convert | ( | long | default_value | ) | const |
converts the string to a long integer.
Definition at line 766 of file astring.cpp.
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().
basis::astring::DEFINE_CLASS_NAME | ( | "astring" | ) |
|
inline |
|
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().
|
inline |
returns the index of the last (non-null) character in the string.
If there is no content in the string, then a negative value is returned.
Definition at line 86 of file astring.h.
References length().
Referenced by processes::launch_process::break_line(), bookmark_tree::break_name(), filesystem::filename::canonicalize(), compare(), filesystem::filename::dirname(), nechung_oracle::display_random(), write_build_config::execute(), filesystem::filename::extension(), octopi::octopus_request_id::from_text(), configuration::application_configuration::get_cmdline_from_proc(), sockets::internet_address::is_valid_internet_address(), main(), filesystem::directory_tree::make_directories(), operator[](), configuration::variable_tokenizer::parse(), bookmark_tree::process_link(), bookmark_tree::prune_link_down(), bookmark_tree::read_csv_file(), filesystem::directory::recursive_create(), replace(), right(), filesystem::filename::rootname(), processes::launch_process::run(), configuration::ini_configurator::sections(), application::command_line::separate_command_line(), strip(), sub_string(), substring(), configuration::variable_tokenizer::text_form(), sockets::internet_address::tokenize(), textual::parser_bits::translate_CR_for_platform(), trim(), structures::version::version(), versions::version_ini::write_assembly(), loggers::critical_events::write_to_critical_events(), and zap().
|
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().
bool basis::astring::equal_to | ( | const char * | that | ) | const |
returns true if "that" is equal to this.
Definition at line 159 of file astring.cpp.
References observe().
Referenced by basis::astring_comparator(), configuration::variable_tokenizer::find(), versions::version_ini::get_record(), versions::version_ini::one_stop_version_stamp(), configuration::variable_tokenizer::parse(), filesystem::filename::pop(), write_build_config::process_version_parts(), application::launch_manager::reenable_launching_services(), sockets::SAFE_STATIC_CONST(), application::launch_manager::shut_down_launching_services(), configuration::system_values::text_form(), and true_value().
|
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().
int basis::astring::find | ( | char | to_find, |
int | position = 0 , |
||
bool | reverse = false |
||
) | const |
Locates "to_find" in "this".
find returns the index of "to_find" or "NOT_FOUND". find starts looking at "position". find returns "OUT_OF_RANGE" if the position is beyond the bounds of "this".
Definition at line 574 of file astring.cpp.
Referenced by bookmark_tree::break_name(), octopi::octopus_entity::breakout(), contains(), sockets::subnet_calculator::convert(), filesystem::filename::extension(), processes::configured_applications::find_program(), octopi::octopus_request_id::from_text(), application::command_line::get_command_line(), sockets::internet_address::has_ip_address(), filesystem::directory_tree::make_directories(), textual::byte_formatter::parse_dump(), bookmark_tree::process_comment(), replace(), replace_all(), versions::replace_version_entry(), filesystem::filename::rootname(), configuration::ini_configurator::sections(), application::command_line::separate_command_line(), strain_out_html_codes(), textual::parser_bits::substitute_env_vars(), structures::version::version(), and loggers::critical_events::write_to_critical_events().
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.
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().
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.
|
virtual |
a constant peek at the string's internals at the specified index.
Implements basis::base_string.
Definition at line 138 of file astring.cpp.
References basis::array< contents >::get().
Referenced by filesystem::filename::canonicalize(), octopi::entity_data_bin::clean_out_deadwood(), application::command_line::command_line(), filesystem::filename::dirname(), filesystem::filename::drive(), configuration::variable_tokenizer::is_eol_a_separator(), matches(), replace_all(), textual::string_manipulation::string_to_hex(), strip(), configuration::variable_tokenizer::text_form(), to_lower(), and to_upper().
byte_array & basis::astring::get_implementation | ( | ) |
Definition at line 134 of file astring.cpp.
|
inline |
|
inline |
Definition at line 192 of file astring.h.
Referenced by whacking_spider().
bool basis::astring::iequals | ( | const astring & | that | ) | const |
returns true if this is case-insensitively equal to "that".
Definition at line 565 of file astring.cpp.
References observe().
Referenced by listo_links::add(), case_insense_compare(), sockets::tcpip_stack::dns_resolve(), sockets::tcpip_stack::fill_and_resolve(), application::command_line::find(), filesystem::filename_list::find(), processes::configured_applications::find_program(), sockets::tcpip_stack::full_resolve(), filesystem::filename_list::locate(), bookmark_tree::magic_category_comparison(), filesystem::filename_list::member(), filesystem::filename_list::member_with_state(), stamping_spider(), and whacking_spider().
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().
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.
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.
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.
void basis::astring::insert | ( | int | position, |
const astring & | to_insert | ||
) |
Copies "to_insert" into "this" at the "position".
Characters at the index "position" and greater are moved over.
Definition at line 892 of file astring.cpp.
References bounds_return, basis::array< contents >::insert(), length(), and basis::array< contents >::overwrite().
Referenced by filesystem::filename::canonicalize(), insert(), application::application_shell::log(), geometric::numeric_specifier(), operator+=(), configuration::variable_tokenizer::parse(), replace(), replace_all(), versions::replace_version_entry(), processes::launch_process::run(), textual::parser_bits::substitute_env_vars(), and textual::parser_bits::translate_CR_for_platform().
|
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().
astring basis::astring::left | ( | int | count | ) |
returns the left "count" characters from the string.
Definition at line 886 of file astring.cpp.
References substring().
|
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().
|
virtual |
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().
|
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().
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().
|
inline |
non_empty() reports if the string has some contents.
|
virtual |
observes the underlying pointer to the zero-terminated string.
this does not allow the contents to be modified. this method should never return NULL_POINTER.
Implements basis::base_string.
Definition at line 140 of file astring.cpp.
References basis::array< contents >::observe().
Referenced by comparator(), compare(), convert(), copy(), filesystem::directory::directory(), sockets::tcpip_stack::dns_resolve(), equal_to(), sockets::tcpip_stack::full_resolve(), basis::environment::get(), configuration::ini_configurator::get_section(), structures::astring_hasher::hash(), iequals(), sockets::internet_machine_uid::internet_machine_uid(), textual::parser_bits::is_alpha(), textual::parser_bits::is_alphanumeric(), textual::parser_bits::is_hexadecimal(), textual::parser_bits::is_identifier(), textual::parser_bits::is_numeric(), octopi::octopus_entity::mangled_form(), filesystem::directory::operator=(), nechung_oracle::pick_random(), filesystem::byte_filer::read(), shrink(), substring(), filesystem::huge_file::touch(), processes::unix_rendez_file(), filesystem::filename::unlink(), filesystem::byte_filer::write(), and application::stdio_redirecter::write().
|
inline |
Returns the concatenation of "this" and "s".
Definition at line 732 of file astring.cpp.
|
inline |
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().
Modifies "this" by concatenating "s" onto it.
Definition at line 165 of file astring.cpp.
References insert(), and length().
Referenced by pad().
astring & basis::astring::operator+= | ( | const char * | s | ) |
Definition at line 793 of file astring.cpp.
References basis::array< contents >::insert(), and length().
Sets the contents of this string to "s".
Definition at line 507 of file astring.cpp.
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().
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().
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().
void basis::astring::pack | ( | byte_array & | target | ) | const |
stores this string in the "target". it can later be unpacked again.
Definition at line 961 of file astring.cpp.
References basis::attach(), and basis::array< contents >::observe().
Referenced by filesystem::directory_tree::pack(), filesystem::file_info::pack(), filesystem::file_time::pack(), filesystem::file_transfer_header::pack(), structures::string_table::pack(), octopi::octopus_entity::pack(), and octopi::file_transfer_infoton::pack().
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().
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().
|
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().
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().
bool basis::astring::replace_all | ( | char | to_replace, |
char | new_char | ||
) |
Definition at line 914 of file astring.cpp.
References find(), insert(), length(), basis::negative(), and zap().
|
inline |
clears out the contents string.
Definition at line 202 of file astring.h.
Referenced by configuration::ini_parser::add(), base_sprintf(), basis::detach(), sockets::tcpip_stack::full_resolve(), sockets::internet_address::has_ip_address(), sockets::internet_address::ip_appropriate_number(), operator=(), configuration::variable_tokenizer::parse(), configuration::application_configuration::query_for_process_info(), textual::xml_generator::reset(), configuration::ini_parser::reset(), reset(), processes::post_office::show_mail(), processes::post_office::show_routes(), substring(), and configuration::variable_tokenizer::text_form().
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.
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().
|
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().
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().
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().
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().
|
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().
|
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().
|
inline |
a synonym for copy().
Definition at line 216 of file astring.h.
Referenced by bogon::bogon(), processes::launch_process::break_line(), sockets::tcpip_stack::enumerate_adapters(), sockets::internet_address::fill(), bogon::operator=(), and sockets::tcpip_stack::resolve_any().
|
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().
|
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().
bool basis::astring::substring | ( | astring & | target, |
int | start, | ||
int | end | ||
) | const |
a version that stores the substring in an existing "target" string.
Definition at line 865 of file astring.cpp.
References bounds_return, end(), observe(), reset(), and UNTERMINATED.
Referenced by configuration::ini_parser::add(), processes::launch_process::break_line(), bookmark_tree::break_name(), cromp::cromp_common::chew_hostname(), sockets::subnet_calculator::convert(), cromp::cromp_common::decode_host(), filesystem::filename::extension(), octopi::octopus_request_id::from_text(), application::command_line::get_command_line(), sockets::internet_address::has_ip_address(), left(), filesystem::directory_tree::make_directories(), middle(), textual::byte_formatter::parse_dump(), bookmark_tree::prune_link_down(), right(), filesystem::filename::rootname(), application::command_line::separate_command_line(), textual::string_manipulation::split_lines(), sub_string(), textual::parser_bits::substitute_env_vars(), substring(), and structures::version::version().
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().
|
inline |
t() is a shortcut for the string being "true", as in non-empty.
the logic here is that the string is not false because it's not empty. for example: if (my_string.t()) { it_is_not_empty; }
Definition at line 97 of file astring.h.
References empty().
Referenced by listo_links::add(), filesystem::file_info::calculate(), filesystem::filename_list::calculate_progress(), sockets::combine(), application::command_line::command_line(), filesystem::directory_tree::compare_trees(), sockets::subnet_calculator::convert(), octopi::recursive_file_copy::copy_hierarchy(), write_build_config::execute(), versions::version_checker::get_handle(), timely::timer_driver::handle_system_timer(), versions::version_checker::loaded(), bookmark_tree::magic_category_comparison(), versions::version_ini::ole_auto_registering(), versions::version_ini::one_stop_version_stamp(), filesystem::byte_filer::open(), configuration::variable_tokenizer::parse(), bookmark_tree::process_comment(), versions::version_checker::retrieve_version_info(), configuration::section_manager::section_exists(), structures::version::set_component(), processes::post_office::show_mail(), textual::parser_bits::substitute_env_vars(), filesystem::file_info::text_form(), and versions::version_ini::write_assembly().
|
virtual |
Provides a text view of all the important info owned by this object.
It is understood that there could be a large amount of information and that this function might take a relatively long time to complete.
Implements basis::text_formable.
Definition at line 130 of file astring.cpp.
References basis::base_string::assign().
Referenced by sockets::spocket::accept(), octopi::file_transfer_tentacle::add_correspondence(), octopi::cleaning_applier(), sockets::spocket::connect(), octopi::octopus::evaluate(), octopi::file_transfer_tentacle::periodic_actions(), octopi::file_transfer_tentacle::refresh_now(), sockets::spocket::text_form(), geometric::line< numeric_type >::text_form(), geometric::rectangle< numeric_type >::text_form(), geometric::rectangle_warper< numeric_type >::text_form(), octopi::text_form_applier(), and sockets::internet_address::tokenize().
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().
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().
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.
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().
|
virtual |
Sets the contents of this string to "s".
Implements basis::base_string.
Definition at line 1072 of file astring.cpp.
References s().
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().
|
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().