istring Class Reference

Provides a dynamically resizable character string. More...

#include <istring.h>

Inheritance diagram for istring:

Inheritance graph
[legend]
Collaboration diagram for istring:

Collaboration graph
[legend]
List of all members.

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

 istring ()
 constructs an empty string.
 istring (const char *initial)
 constructs a copy of the string passed in "initial".
 istring (char c, int repeat)
 constructs a string with "repeat" characters of "c" in it.
 istring (const istring &s)
 Constructs a copy of the string "s".
 istring (special_flag way, const char *s,...)
 constructor that sports a few variable parameter constructions.
 ~istring ()
 destroys any storage for the string.
int length () const
 Returns the current length of the string.
int end () const
 returns the index of the last (non-null) character in the string.
bool empty () const
 empty() reports if the string is empty, that is, of zero length().
bool non_empty () const
 non_empty() reports if the string has some contents.
bool operator! () const
 the negation operator also returns true if the string is empty.
bool t () const
 t() is a shortcut for the string being "true", as in non-empty.
const char * observe () const
 observes the underlying pointer to the zero-terminated string.
const char * c_str () const
 synonym for observe. mimics the STL method name.
const char * s () const
 synonym for observe. the 's' stands for "string", if that helps.
char get (int index) const
 a constant peek at the string's internals at the specified index.
char * access ()
 provides access to the actual string held.
char * c_str ()
 synonym for access. mimics the STL method.
char * s ()
 synonym for access.
char & operator[] (int position)
 accesses individual characters in "this" string.
const char & operator[] (int position) const
 observes individual characters in "this" string.
void put (int position, char to_put)
 stores the character "to_put" at index "position" in the string.
istringsprintf (const char *s,...)
 similar to the SPRINTF constructor, but works on an existing string.
int convert (int default_value) const
 Converts the string into a corresponding integer.
long convert (long default_value) const
 converts the string to a long integer.
float convert (float default_value) const
 converts the string to a floating point number.
double convert (double default_value) const
 converts the string to a double precision floating point number.
bool operator< (const istring &that) const
 Returns true if this string is lexically less than the string "that".
bool operator> (const istring &that) const
 Returns true if this is lexically greater than the string "that".
bool operator<= (const istring &that) const
 Returns true if this is lexically less than or equal to "that".
bool operator>= (const istring &that) const
 Returns true if this is lexically greater than or equal to "that".
bool operator!= (const istring &that) const
 Returns true if this string is not equal to the string "that".
bool operator== (const istring &that) const
 Returns true if this string is equal to the string "that".
bool operator== (const char *that) const
 returns true if "that" is equal to this.
bool operator!= (const char *that) const
 returns true if "that" is not equal to this.
bool iequals (const istring &that) const
 returns true if this is case-insensitively equal to "that".
bool iequals (const char *that) const
 returns true if this is case-insensitively equal to "that".
bool compare (const istring &to_compare, int start_first, int start_second, int count) const
 Compares "this" string with "to_compare".
bool oy_icompare (const istring &to_compare, int start_first, int start_second, int count) const
 the case insensitive version of compare().
bool begins (const istring &maybe_prefix) const
 Returns true if "this" string begins with "maybe_prefix".
bool operator *= (const istring &maybe_prefix) const
 An alias for begins().
bool ibegins (const istring &maybe_prefix) const
 a case-insensitive method similar to begins().
bool ends (const istring &maybe_suffix) const
 returns true if this string ends with "maybe_suffix". a case-insensitive method similar to ends().
bool iends (const istring &maybe_suffix) const
istringoperator= (const istring &s)
 Sets the contents of this string to "s".
istringoperator= (const char *s)
 Sets the contents of this string to "s".
void reset ()
 clears out the contents string.
void reset (special_flag way, const char *s,...)
 operates like the constructor that takes a 'special_flag'.
void copy (char *to_stuff, int count) const
 Copies a maximum of "count" characters from this into "to_stuff".
void stuff (char *to_stuff, int count) const
 a synonym for copy().
istring operator+ (const istring &s) const
 Returns the concatenation of "this" and "s".
istringoperator+= (const istring &s)
 Modifies "this" by concatenating "s" onto it.
istringoperator+= (const char *s)
istring operator+ (const char *s) const
 < synonym for the concatenation operator but uses a char pointer instead. synonym for the concatenation operator but uses a char pointer instead.
istringoperator+= (char c)
 concatenater for single characters.
int find (char to_find, int position=0, bool reverse=false) const
 Locates "to_find" in "this".
int find (const istring &to_find, int posn=0, bool reverse=false) const
 finds "to_find" in this string.
int ifind (char to_find, int position=0, bool reverse=false) const
 like the find() methods above, but case-insensitive.
int ifind (const istring &to_find, int posn=0, bool reverse=false) const
 like the find() methods above, but case-insensitive.
int find_any (const istring &to_find, int position=0, bool reverse=false) const
 searches for any of the characters in "to_find".
int ifind_any (const istring &to_find, int position=0, bool reverse=false) const
 searches case-insensitively for any of the characters in "to_find".
int find_non_match (const istring &to_find, int position=0, bool reverse=false) const
 searches for any character that is not in "to_find" and returns index.
bool contains (const istring &to_find) const
 Returns true if "to_find" is contained in this string or false if not.
bool operator^= (const istring &to_find) const
 An alias for contains().
istring substring (int start, int end) const
 Returns the segment of "this" between the indices "start" and "end".
void substring (istring &target, int start, int end) const
 a version that stores the substring in an existing "target" string.
void pad (int length, char padding= ' ')
 makes the string "length" characters long.
void trim (int length)
 shortens the string to "length" if it's longer than that.
void insert (int position, const istring &to_insert)
 Copies "to_insert" into "this" at the "position".
void zap (int start, int end)
 Deletes the characters between "start" and "end" inclusively.
void to_lower ()
 to_lower modifies "this" by replacing capitals with lower-case.
void to_upper ()
 to_upper does the opposite of to_lower (that is, q becomes Q).
istring lower () const
 like to_lower(), but returns a new string rather than modifying this.
istring upper () const
 like to_upper(), but returns a new string rather than modifying this.
bool replace (const istring &tag, const istring &replacement)
 replaces the first occurrence of "tag" text with the "replacement".
bool replace_all (char to_replace, char new_char)
 changes all occurrences of "to_replace" with "new_char".
bool replace_all (const istring &to_replace, const istring &new_string)
void shrink ()
 changes all occurrences of "to_replace" into "new_string". resizes the string to its minimum possible length.
void strip (const istring &strip_list, how_to_strip way=FROM_BOTH_SIDES)
 strips all chars from "strip_list" out of "this" given the "way".
void strip_spaces (how_to_strip way=FROM_BOTH_SIDES)
 removes excess space characters from string's beginning, end or both.
void strip_white_spaces (how_to_strip way=FROM_BOTH_SIDES)
 like strip_spaces, but includes tabs in the list to strip.
void pack (byte_array &target) const
 stores this string in the "target". it can later be unpacked again.
bool unpack (byte_array &source)
 retrieves a string (packed with pack()) from "source" into this string.
int icompare (const istring &to_compare, int length=-1) const
 provides a case insensitive comparison routine.
int icompare (const char *to_compare, int length=-1) const
 a version of the above for raw character pointers.
const byte_sequencelow_level () const
 provides access to the low-level implementation of the object.
istringbase_sprintf (const char *s, va_list &args)
byte_sequenceget_implem ()

Static Public Member Functions

static const istringempty_string ()
 useful wherever empty strings are needed, e.g., function defaults.
static bool matches (const istring &match_list, char to_match)
 returns true if "to_match" is found in the "match_list" string.
static int slow_strncasecmp (const char *first, const char *second, int length=-1)
 a replacement for strncasecmp on platforms without them.

Detailed Description

Provides a dynamically resizable 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 28 of file istring.h.


Member Enumeration Documentation

enum istring::special_flag

Enumerator:
UNTERMINATED 
SPRINTF 

Definition at line 45 of file istring.h.

enum istring::how_to_strip

Enumerator:
FROM_FRONT 
FROM_END 
FROM_BOTH_SIDES 

Definition at line 324 of file istring.h.


Constructor & Destructor Documentation

istring::istring (  ) 

constructs an empty string.

Definition at line 68 of file istring.cpp.

Referenced by istring(), pad(), and reset().

istring::istring ( const char *  initial  ) 

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

Definition at line 93 of file istring.cpp.

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

istring::istring ( 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 73 of file istring.cpp.

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

istring::istring ( const istring s  ) 

Constructs a copy of the string "s".

Definition at line 87 of file istring.cpp.

istring::istring ( 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 "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 106 of file istring.cpp.

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

istring::~istring (  ) 

destroys any storage for the string.

Definition at line 134 of file istring.cpp.

References NIL, and WHACK().


Member Function Documentation

int istring::length (  )  const

Returns the current length of the string.

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

Definition at line 140 of file istring.cpp.

References array< contents >::length().

Referenced by ADD(), ini_parser::add(), file_differ::AddCRs(), portable::break_line(), byte_format::bytes_to_shifted_string(), filename::canonicalize(), string_manipulation::carriage_returns_to_spaces(), cromp_common::chew_hostname(), xml_generator::clean_reserved_mod(), command_line::command_line(), compare(), directory_tree::compare_trees(), service_control::control_service(), convert(), subnet_calculator::convert(), copy(), creatapose(), crop_non_numeric(), crop_numeric(), cromp_common::decode_host(), network_address::detokenize(), filename::detooth_filename(), filename::drive(), list_parsing::emit_quoted_chunk(), secret_string::encrypt_string(), end(), string_manipulation::escape_chars(), filename::exists(), filename::extension(), FIND(), command_line::find(), portable::get_cmdline_from_proc(), command_line::get_command_line(), list_parsing::get_ids_from_string(), list_parsing::get_rest_of_line(), ini_configurator::get_section(), list_parsing::get_separated_value(), command_line::get_value(), list_parsing::get_values_from_string(), version_checker::get_version(), internet_address::has_ip_address(), istring_hasher::hash(), icompare(), imatches_any(), info_edit::info_edit(), insert(), internet_machine_uid::internet_machine_uid(), internet_address::ip_appropriate_number(), tokenizer::is_eol_a_separator(), istring(), process_manager::launch_now(), application_shell::log(), file_logger::log(), debugging_base::log(), main(), octopus_entity::mangled_form(), matches(), matches_any(), matches_none(), common_database_support::nerf_special_characters(), debugging_console_view::OnBeginPrinting(), operator *=(), operator+=(), oy_icompare(), file_transfer_header::packed_size(), octopus_entity::packed_size(), string_table::packed_size(), string_set::packed_size(), pad(), list_parsing::parse_csv_line(), byte_format::parse_dump(), grid_processor::process_grid_files(), ini_configurator::put(), table_configurator::put(), ini_configurator::put_section(), service_control::reconfigure_service(), replace_all(), database_login_info::replace_value(), reset(), run_test_01(), run_test_03(), run_test_04(), run_test_09(), run_test_10(), run_test_11(), run_test_12(), run_test_14(), run_test_16(), run_test_18(), run_test_25(), run_test_31(), run_test_32(), run_test_41(), SAFE_STATIC_CONST(), smtp_client::send_email(), filename::separate(), command_line::separate_command_line(), smtp_client::set_body(), smtp_client::set_subject(), byte_format::shifted_string_to_bytes(), show_message(), post_office::show_routes(), string_manipulation::split_lines(), strain_out_html_codes(), string_manipulation::string_to_hex(), strip(), parser_bits::substitute_env_vars(), string_manipulation::substring(), test_bogon_amorph(), test_byte_array_amorph(), test_stack_with_objects(), test_stack_with_pointers(), directory_tree::text_form(), octopus_entity::text_form(), to_lower(), to_upper(), trim(), string_manipulation::unescape_chars(), database_login_info::update_freetds_configuration(), query_handler::use_database(), smtp_client::validate_address(), version::version(), stdio_redirecter::write(), byte_filer::write(), version_ini::write_code(), and version_ini::write_rc().

int istring::end (  )  const [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 72 of file istring.h.

References length().

Referenced by portable::break_line(), bookmark_tree::break_name(), filename::canonicalize(), compare(), nechung_oracle::display_random(), write_build_config::execute(), filename::extension(), filename::filename(), octopus_request_id::from_text(), info_edit::info_edit(), portable::launch_process(), main(), operator[](), oy_icompare(), tokenizer::parse(), grid_processor::process_grid_files(), bookmark_tree::process_link(), smtp_client::prune_address(), bookmark_tree::read_csv_file(), directory::recursive_create(), replace(), filename::rootname(), run_test_21(), run_test_32(), ini_configurator::sections(), command_line::separate_command_line(), strip(), substring(), portable::system_error_text(), tokenizer::text_form(), parser_bits::translate_CR_for_platform(), trim(), version::version(), version_ini::write_assembly(), critical_events::write_to_critical_events(), and zap().

bool istring::empty (  )  const [inline]

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

Definition at line 76 of file istring.h.

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

bool istring::non_empty (  )  const [inline]

non_empty() reports if the string has some contents.

Definition at line 78 of file istring.h.

bool istring::operator! (  )  const [inline]

the negation operator also 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 80 of file istring.h.

bool istring::t (  )  const [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 83 of file istring.h.

References empty().

Referenced by listo_links::add(), file_info::calculate(), filename_list::calculate_progress(), combine(), command_line::command_line(), directory_tree::compare_trees(), subnet_calculator::convert(), recursive_file_copy::copy_hierarchy(), debugger::create_debug_message(), version_checker::get_handle(), timer_driver::handle_system_timer(), service_root::install(), version_checker::loaded(), bookmark_tree::magic_category_comparison(), wx_debugging_base::name(), debugging_base::name(), internet_address::normalize_host(), debugging_console_view::OnBeginPrinting(), tiny_shell::OnCreate(), version_ini::one_stop_version_stamp(), byte_filer::open(), tokenizer::parse(), bookmark_tree::process_comment(), grid_processor::process_grid_files(), version_checker::retrieve_version_info(), section_manager::section_exists(), smtp_client::send_email(), version::set_component(), wx_debugging_base::setup(), debugging_base::setup(), post_office::show_mail(), parser_bits::substitute_env_vars(), test_string_table(), file_info::text_form(), database_login_info::update_freetds_configuration(), and version_ini::write_assembly().

const istring & istring::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 136 of file istring.cpp.

References __istring_empty_string().

Referenced by bookmark_tree::break_name(), filename::compare_prefix(), filename::compare_suffix(), directory_tree::compare_trees(), list_parsing::create_csv_line(), directory_tree::current(), directory_tree::current_dir(), tcpip_stack::fill_and_resolve(), locked_logger::get_ending(), library_wide_cleanup::library_wide_cleanup(), list_parsing::parse_csv_line(), bookmark_tree::process_comment(), database_login_info::reset(), run_test_01(), filename::separate(), and heartbeat::text_form().

const char * istring::observe (  )  const

observes the underlying pointer to the zero-terminated string.

this does not allow the contents to be modified. this method should never return NIL.

Definition at line 148 of file istring.cpp.

References array< contents >::observe().

Referenced by compare(), hoople_api::string_conversions::convert(), convert(), copy(), directory::directory(), tcpip_stack::dns_resolve(), portable::env_string(), filename::exists(), tcpip_stack::full_resolve(), path_configuration::get_logging_directory(), ini_configurator::get_section(), istring_hasher::hash(), icompare(), iequals(), internet_machine_uid::internet_machine_uid(), parser_bits::is_alphanumeric(), parser_bits::is_hexadecimal(), parser_bits::is_identifier(), parser_bits::is_numeric(), main(), octopus_entity::mangled_form(), operator!=(), directory::operator=(), operator==(), oy_icompare(), nechung_oracle::pick_random(), byte_filer::read(), shrink(), substring(), test_byte_array_amorph(), linked_buffer::text_form(), buffer::text_form(), unix_rendez_file(), stdio_redirecter::write(), and byte_filer::write().

const char* istring::c_str (  )  const [inline]

synonym for observe. mimics the STL method name.

Definition at line 97 of file istring.h.

const char* istring::s (  )  const [inline]

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

Definition at line 99 of file istring.h.

Referenced by directory::absolute_path(), ADD(), argument_list::add(), application_config::add_program(), guards::alert_message(), octopus_entity::breakout(), byte_format::bytes_to_string(), CHECK_STACK_RESULT(), cromp_common::chew_hostname(), filename::chmod(), version_checker::complain_cannot_load(), version_checker::complain_wrong_version(), creatapose(), drawing_window::Create(), file_differ::diff_files(), menu::draw(), secret_string::encrypt_string(), file_time::file_time(), FIND(), guards::FL_continuable_error(), guards::FL_deadly_error(), guards::FL_non_continuable_error(), formal(), bit_vector::get(), portable::get_cmdline_from_proc(), path_configuration::get_logging_directory(), version_checker::good_version(), header_string(), service_root::initialize(), service_root::install(), internet_address::is_valid_internet_address(), portable::launch_process(), list_box::list_box_callback(), library_plugins::dynamic_library_loader::load_the_library(), file_logger::log(), console_logger::log(), query_handler::login_to_database(), main(), directory::make_directory(), transition_map::make_transition(), octopus_entity::mangled_form(), byte_filer::open(), parse_address(), cromp_transaction::peek_header(), nechung_oracle::pick_random(), query_handler::process_query(), grid_processor::process_query_as_df(), transition_map::pulse(), socket_minder::push_receives(), socket_minder::push_sends(), directory::remove_directory(), rendezvous::rendezvous(), directory::rescan(), file_time::reset(), run_test_01(), run_test_04(), run_test_05(), run_test_10(), run_test_12(), run_test_14(), run_test_24(), run_test_30(), run_test_34(), raw_socket::select(), smtp_client::send_email(), smtp_client::set_body(), portable::set_environ(), smtp_client::set_subject(), zing_table::show_events(), slider::slider(), standard_sprintf_test(), byte_format::string_to_bytes(), system_string::system_string(), test_bogon_amorph(), test_byte_array_amorph(), test_string_table(), process_entry::text_form(), octopus_entity::text_form(), nodes::symbol_tree::text_form(), geometric::point< numeric_type >::text_form(), memory_limiter::text_form(), spocket::text_form(), socket_data::text_form(), connection::text_form(), transition_map::time_slice(), file_logger::truncate(), filename::unlink(), query_handler::use_database(), version_ini::write_code(), version_ini::write_rc(), and critical_events::write_to_critical_events().

char istring::get ( int  index  )  const

a constant peek at the string's internals at the specified index.

Definition at line 146 of file istring.cpp.

References array< contents >::get().

Referenced by filename::canonicalize(), command_line::command_line(), filename::dirname(), filename::drive(), tokenizer::is_eol_a_separator(), matches(), replace_all(), string_manipulation::string_to_hex(), strip(), tokenizer::text_form(), to_lower(), and to_upper().

char * istring::access (  ) 

provides access to the actual string held.

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

Definition at line 144 of file istring.cpp.

References array< contents >::access().

Referenced by c_str(), byte_filer::getline(), istring(), main(), and test_byte_array_amorph().

char* istring::c_str (  )  [inline]

synonym for access. mimics the STL method.

Definition at line 110 of file istring.h.

References access().

char* istring::s (  )  [inline]

synonym for access.

Definition at line 112 of file istring.h.

char & istring::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 752 of file istring.cpp.

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

const char & istring::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 761 of file istring.cpp.

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

void istring::put ( int  position,
char  to_put 
) [inline]

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

Definition at line 124 of file istring.h.

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

istring & istring::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 187 of file istring.cpp.

References base_sprintf().

Referenced by istring_sprintf_test().

int istring::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 770 of file istring.cpp.

References length(), and observe().

Referenced by subnet_calculator::convert(), application_config::find_program(), geometric::rectangle< numeric_type >::from_text(), geometric::point< numeric_type >::from_text(), internet_address::ip_appropriate_number(), configurator::load(), main(), application_config::parse_startup_entry(), grid_processor::process_grid_files(), and run_test_15().

long istring::convert ( long  default_value  )  const

converts the string to a long integer.

Definition at line 779 of file istring.cpp.

References length(), and observe().

float istring::convert ( float  default_value  )  const

converts the string to a floating point number.

Definition at line 788 of file istring.cpp.

References length(), and observe().

double istring::convert ( double  default_value  )  const

converts the string to a double precision floating point number.

Definition at line 797 of file istring.cpp.

References length(), and observe().

bool istring::operator< ( const istring that  )  const

Returns true if this string is lexically less than the string "that".

Definition at line 151 of file istring.cpp.

References _implementation.

bool istring::operator> ( const istring that  )  const

Returns true if this is lexically greater than the string "that".

Definition at line 154 of file istring.cpp.

References _implementation.

bool istring::operator<= ( const istring that  )  const

Returns true if this is lexically less than or equal to "that".

Definition at line 157 of file istring.cpp.

References _implementation.

bool istring::operator>= ( const istring that  )  const

Returns true if this is lexically greater than or equal to "that".

Definition at line 160 of file istring.cpp.

References _implementation.

bool istring::operator!= ( const istring that  )  const

Returns true if this string is not equal to the string "that".

Definition at line 163 of file istring.cpp.

bool istring::operator== ( const istring that  )  const

Returns true if this string is equal to the string "that".

Definition at line 166 of file istring.cpp.

References observe().

bool istring::operator== ( const char *  that  )  const

returns true if "that" is equal to this.

Definition at line 169 of file istring.cpp.

References observe().

bool istring::operator!= ( const char *  that  )  const

returns true if "that" is not equal to this.

Definition at line 172 of file istring.cpp.

References observe().

bool istring::iequals ( const istring that  )  const

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

Definition at line 578 of file istring.cpp.

References observe().

Referenced by case_insense_compare(), tcpip_stack::dns_resolve(), tcpip_stack::fill_and_resolve(), filename_list::find(), command_line::find(), application_config::find_program(), tcpip_stack::full_resolve(), service_root::install(), filename_list::locate(), bookmark_tree::magic_category_comparison(), filename_list::member(), grid_processor::reset_data_fields(), and grid_processor::write_fields_for_row().

bool istring::iequals ( const char *  that  )  const

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

Definition at line 581 of file istring.cpp.

References observe().

bool istring::compare ( const istring to_compare,
int  start_first,
int  start_second,
int  count 
) 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 824 of file istring.cpp.

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

Referenced by write_build_config::check_nesting(), write_build_config::execute(), process_control::find_process_in_list(), operator *=(), and run_test_10().

bool istring::oy_icompare ( const istring to_compare,
int  start_first,
int  start_second,
int  count 
) const

the case insensitive version of compare().

Definition at line 857 of file istring.cpp.

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

bool istring::begins ( const istring maybe_prefix  )  const [inline]

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

Definition at line 183 of file istring.h.

Referenced by ibegins(), string_table::is_comment(), main(), and run_test_34().

bool istring::operator *= ( const istring maybe_prefix  )  const [inline]

An alias for begins().

Definition at line 186 of file istring.h.

References compare(), and length().

bool istring::ibegins ( const istring maybe_prefix  )  const [inline]

a case-insensitive method similar to begins().

Definition at line 190 of file istring.h.

References begins().

Referenced by run_test_34().

bool istring::ends ( const istring maybe_suffix  )  const [inline]

returns true if this string ends with "maybe_suffix". a case-insensitive method similar to ends().

Definition at line 195 of file istring.h.

Referenced by run_test_34().

bool istring::iends ( const istring maybe_suffix  )  const [inline]

Definition at line 201 of file istring.h.

Referenced by run_test_34().

istring & istring::operator= ( const istring s  ) 

Sets the contents of this string to "s".

Definition at line 520 of file istring.cpp.

References _implementation.

Referenced by istring(), and reset().

istring & istring::operator= ( const char *  s  ) 

Sets the contents of this string to "s".

Definition at line 527 of file istring.cpp.

References reset().

void istring::reset (  )  [inline]

clears out the contents string.

Definition at line 212 of file istring.h.

Referenced by ini_parser::add(), base_sprintf(), hoople_api::string_conversions::convert(), basis::detach(), file_differ::diff_files(), tcpip_stack::full_resolve(), internet_address::has_ip_address(), internet_address::ip_appropriate_number(), operator=(), tokenizer::parse(), portable::query_for_process_info(), xml_generator::reset(), ini_parser::reset(), reset(), run_test_05(), run_test_12(), post_office::show_mail(), post_office::show_routes(), substring(), tokenizer::text_form(), and scheduler::~scheduler().

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

operates like the constructor that takes a 'special_flag'.

Definition at line 480 of file istring.cpp.

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

void istring::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 "\0" 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 '' will be put at position "count" in the C-string if the full "count" of characters are copied.

Definition at line 569 of file istring.cpp.

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

void istring::stuff ( char *  to_stuff,
int  count 
) const [inline]

a synonym for copy().

Definition at line 226 of file istring.h.

Referenced by portable::break_line(), tcpip_stack::enumerate_adapters(), ipc_address::fill(), internet_address::fill(), tcpip_stack::resolve_any(), run_test_09(), test_bogon_amorph(), test_byte_array_amorph(), test_stack_with_objects(), and test_stack_with_pointers().

istring istring::operator+ ( const istring s  )  const

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

Definition at line 745 of file istring.cpp.

istring & istring::operator+= ( const istring s  ) 

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

Definition at line 178 of file istring.cpp.

References insert(), and length().

Referenced by pad().

istring & istring::operator+= ( const char *  s  ) 

Definition at line 806 of file istring.cpp.

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

istring istring::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 237 of file istring.h.

istring & istring::operator+= ( char  c  ) 

concatenater for single characters.

Definition at line 816 of file istring.cpp.

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

int istring::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 587 of file istring.cpp.

Referenced by bookmark_tree::break_name(), octopus_entity::breakout(), contains(), subnet_calculator::convert(), network_address::detokenize(), filename::extension(), application_config::find_program(), octopus_request_id::from_text(), command_line::get_command_line(), list_parsing::get_positions(), list_parsing::get_rest_of_line(), list_parsing::get_separated_value(), list_parsing::get_values_from_string(), internet_address::has_ip_address(), service_root::install(), byte_format::parse_dump(), bookmark_tree::process_comment(), grid_processor::process_grid_files(), smtp_client::prune_address(), replace(), replace_all(), database_login_info::replace_value(), filename::rootname(), run_test_04(), run_test_21(), run_test_22(), ini_configurator::sections(), command_line::separate_command_line(), strain_out_html_codes(), parser_bits::substitute_env_vars(), string_manipulation::substring(), smtp_client::validate_address(), version::version(), version_ini::write_assembly(), and critical_events::write_to_critical_events().

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

finds "to_find" in this string.

Definition at line 684 of file istring.cpp.

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

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

Definition at line 584 of file istring.cpp.

Referenced by list_parsing::get_rest_of_line(), and list_parsing::get_separated_value().

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

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

Definition at line 687 of file istring.cpp.

int istring::find_any ( const istring 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 590 of file istring.cpp.

Referenced by run_test_39(), and string_manipulation::split_lines().

int istring::ifind_any ( const istring 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 593 of file istring.cpp.

int istring::find_non_match ( const istring 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 596 of file istring.cpp.

Referenced by run_test_41().

bool istring::contains ( const istring to_find  )  const

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

Definition at line 175 of file istring.cpp.

References find().

Referenced by main(), write_build_config::output_decorated_macro(), write_build_config::output_macro(), bookmark_tree::process_comment(), string_manipulation::quote_string(), and smtp_client::setup_session().

bool istring::operator^= ( const istring to_find  )  const [inline]

An alias for contains().

Definition at line 272 of file istring.h.

istring istring::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 880 of file istring.cpp.

Referenced by ini_parser::add(), portable::break_line(), bookmark_tree::break_name(), cromp_common::chew_hostname(), subnet_calculator::convert(), cromp_common::decode_host(), network_address::detokenize(), filename::extension(), octopus_request_id::from_text(), command_line::get_command_line(), list_parsing::get_rest_of_line(), list_parsing::get_separated_value(), internet_address::has_ip_address(), main(), byte_format::parse_dump(), grid_processor::process_grid_files(), smtp_client::prune_address(), filename::rootname(), run_test_10(), command_line::separate_command_line(), string_manipulation::split_lines(), parser_bits::substitute_env_vars(), string_manipulation::substring(), and version::version().

void istring::substring ( istring target,
int  start,
int  end 
) const

a version that stores the substring in an existing "target" string.

Definition at line 869 of file istring.cpp.

References bounds_halt, end(), FUNCDEF, observe(), reset(), and UNTERMINATED.

void istring::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 506 of file istring.cpp.

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

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

void istring::trim ( int  length  ) 

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

Definition at line 514 of file istring.cpp.

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

void istring::insert ( int  position,
const istring to_insert 
)

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

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

Definition at line 887 of file istring.cpp.

References _implementation, bounds_return, array< contents >::insert(), length(), and array< contents >::overwrite().

Referenced by file_differ::AddCRs(), string_manipulation::escape_chars(), portable::launch_process(), application_shell::log(), debugging_base::log(), common_database_support::nerf_special_characters(), numeric_specifier(), operator+=(), replace(), replace_all(), database_login_info::replace_value(), run_test_10(), run_test_16(), parser_bits::substitute_env_vars(), parser_bits::translate_CR_for_platform(), and version_ini::write_assembly().

void istring::zap ( int  start,
int  end 
)

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.

Definition at line 534 of file istring.cpp.

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

Referenced by ini_parser::add(), portable::break_line(), bookmark_tree::break_name(), octopus_entity::breakout(), filename::canonicalize(), subnet_calculator::convert(), crop_non_numeric(), crop_numeric(), write_build_config::execute(), application_config::find_program(), portable::get_cmdline_from_proc(), version_checker::get_version(), info_edit::info_edit(), main(), bookmark_tree::process_comment(), grid_processor::process_grid_files(), smtp_client::prune_address(), replace(), replace_all(), database_login_info::replace_value(), run_test_03(), run_test_04(), run_test_09(), run_test_10(), run_test_14(), run_test_21(), run_test_32(), ini_configurator::sections(), smtp_client::send_email(), strain_out_html_codes(), strip(), parser_bits::substitute_env_vars(), portable::system_error_text(), tokenizer::text_form(), parser_bits::translate_CR_for_platform(), trim(), string_manipulation::unescape_chars(), version_ini::write_assembly(), and critical_events::write_to_critical_events().

void istring::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 541 of file istring.cpp.

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

Referenced by portable::application_name(), version_ini::executable(), tcpip_stack::fill_and_resolve(), command_line::find(), version_ini::get_record(), lower(), main(), portable::module_name(), process_manager::query_application(), and SAFE_STATIC_CONST().

void istring::to_upper (  ) 

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

Definition at line 548 of file istring.cpp.

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

Referenced by modify_character(), and upper().

istring istring::lower (  )  const

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

Definition at line 555 of file istring.cpp.

References to_lower().

Referenced by network_address::detokenize(), version_ini::executable(), process_control::find_process_in_list(), and version_ini::ole_auto_registering().

istring istring::upper (  )  const

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

Definition at line 562 of file istring.cpp.

References to_upper().

Referenced by portable::env_string(), and version_ini::write_code().

bool istring::replace ( const istring tag,
const istring 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 900 of file istring.cpp.

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

Referenced by main(), version_ini::one_stop_version_stamp(), run_test_21(), and run_test_33().

bool istring::replace_all ( char  to_replace,
char  new_char 
)

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

Definition at line 924 of file istring.cpp.

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

Referenced by main(), run_test_40(), and version_ini::write_code().

bool istring::replace_all ( const istring to_replace,
const istring new_string 
)

Definition at line 909 of file istring.cpp.

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

void istring::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 181 of file istring.cpp.

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

Referenced by ini_configurator::get_section(), byte_filer::getline(), main(), query_handler::print_row(), byte_filer::read(), run_test_35(), query_handler::show_this_row(), and grid_processor::write_fields_for_row().

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

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

Definition at line 943 of file istring.cpp.

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

Referenced by run_test_23(), and strip_white_spaces().

void istring::strip_spaces ( how_to_strip  way = FROM_BOTH_SIDES  )  [inline]

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

Definition at line 330 of file istring.h.

Referenced by bookmark_tree::break_name(), network_address::detokenize(), write_build_config::execute(), run_test_21(), and string_manipulation::split_lines().

void istring::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 334 of file istring.h.

References strip().

Referenced by ini_configurator::sections().

bool istring::matches ( const istring match_list,
char  to_match 
) [static]

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

Definition at line 936 of file istring.cpp.

References get(), and length().

Referenced by tokenizer::assignment(), tokenizer::comment_char(), tokenizer::quote_mark(), tokenizer::separator(), and strip().

void istring::pack ( byte_array target  )  const

stores this string in the "target". it can later be unpacked again.

Definition at line 954 of file istring.cpp.

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

Referenced by debugger::create_debug_message(), file_transfer_infoton::pack(), occurrence::pack(), file_transfer_header::pack(), filename::pack(), file_info::pack(), directory_tree::pack(), octopus_entity::pack(), string_table::pack(), manifest_chunk::pack(), network_address::parse_pack(), run_test_29(), run_test_37(), and SAFE_STATIC_CONST().

bool istring::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 957 of file istring.cpp.

References basis::detach().

Referenced by debugger::crack_debug_message(), network_address::parse_unpack(), run_test_29(), run_test_37(), SAFE_STATIC_CONST(), unpack(), file_transfer_infoton::unpack(), occurrence::unpack(), file_transfer_header::unpack(), filename::unpack(), file_info::unpack(), directory_tree::unpack(), octopus_entity::unpack(), string_table::unpack(), and manifest_chunk::unpack().

int istring::icompare ( const istring to_compare,
int  length = -1 
) const

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.

Definition at line 960 of file istring.cpp.

References observe().

int istring::icompare ( const char *  to_compare,
int  length = -1 
) const

a version of the above for raw character pointers.

Definition at line 835 of file istring.cpp.

References length(), negative(), and observe().

int istring::slow_strncasecmp ( const char *  first,
const char *  second,
int  length = -1 
) [static]

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".

Definition at line 963 of file istring.cpp.

References minimum(), positive(), and simple_lower().

Referenced by run_test_34().

const byte_sequence & istring::low_level (  )  const

provides access to the low-level implementation of the object.

Definition at line 138 of file istring.cpp.

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

Definition at line 196 of file istring.cpp.

References reset().

Referenced by isprintf::isprintf(), istring(), reset(), and sprintf().

byte_sequence & istring::get_implem (  ) 

Definition at line 142 of file istring.cpp.

Referenced by run_test_35().


The documentation for this class was generated from the following files:
Generated on Fri Nov 28 04:30:50 2008 for HOOPLE Libraries by  doxygen 1.5.1