feisty meow concerns codebase  2.140
basis::base_string Class Referenceabstract

Defines the base class for all string processing objects in hoople. More...

#include <base_string.h>

Inheritance diagram for basis::base_string:
Collaboration diagram for basis::base_string:

Public Member Functions

virtual int length () const =0
 Returns the current length of the string. More...
 
virtual const char * observe () const =0
 observes the underlying pointer to the zero-terminated string. More...
 
virtual char * access ()=0
 provides access to the actual string held. More...
 
virtual char get (int index) const =0
 a constant peek at the string's internals at the specified index. More...
 
virtual void put (int position, char to_put)=0
 stores the character "to_put" at index "position" in the string. More...
 
virtual bool sub_compare (const base_string &to_compare, int start_first, int start_second, int count, bool case_sensitive) const =0
 Compares "this" string with "to_compare". More...
 
virtual base_stringassign (const base_string &s)=0
 Sets the contents of this string to "s". More...
 
virtual base_stringupgrade (const char *s)=0
 Sets the contents of this string to "s". More...
 
virtual void insert (int position, const base_string &to_insert)=0
 Copies "to_insert" into "this" at the "position". More...
 
virtual void zap (int start, int end)=0
 Deletes the characters between "start" and "end" inclusively. More...
 
virtual base_stringconcatenate_string (const base_string &s)=0
 Modifies "this" by concatenating "s" onto it. More...
 
virtual base_stringconcatenate_char (char c)=0
 concatenater for single characters. More...
 
virtual bool sub_string (base_string &target, int start, int end) const =0
 Gets the segment of "this" between the indices "start" and "end". More...
 
virtual base_stringoperator= (const base_string &to_copy)
 sets this string's contents equal to the contents of "to_copy". More...
 
- Public Member Functions inherited from basis::orderable
virtual bool less_than (const orderable &s2) const =0
 
virtual bool operator< (const orderable &s2) const
 the virtual method for object ordering. More...
 
- Public Member Functions inherited from basis::equalizable
virtual bool equal_to (const equalizable &s2) const =0
 
virtual bool operator== (const equalizable &s2) const
 the virtual method for object equality. More...
 

Detailed Description

Defines the base class for all string processing objects in hoople.

Definition at line 27 of file base_string.h.

Member Function Documentation

◆ access()

virtual char* basis::base_string::access ( )
pure 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).

Implemented in basis::astring.

◆ assign()

◆ concatenate_char()

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

concatenater for single characters.

Implemented in basis::astring.

◆ concatenate_string()

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

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

Implemented in basis::astring.

◆ get()

virtual char basis::base_string::get ( int  index) const
pure virtual

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

Implemented in basis::astring.

◆ insert()

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

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

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

Implemented in basis::astring.

◆ length()

virtual int basis::base_string::length ( ) const
pure virtual

Returns the current length of the string.

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

Implemented in basis::astring.

Referenced by loggers::file_logger::log().

◆ observe()

virtual const char* basis::base_string::observe ( ) const
pure 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.

Implemented in basis::astring.

Referenced by basis::astring::insert(), loggers::console_logger::log(), loggers::file_logger::log(), and basis::astring::sub_compare().

◆ operator=()

virtual base_string& basis::base_string::operator= ( const base_string to_copy)
inlinevirtual

sets this string's contents equal to the contents of "to_copy".

this assignment ensures that setting the base class to derived versions will succeed; otherwise, a base class copy does very little.

Definition at line 92 of file base_string.h.

References assign().

◆ put()

virtual void basis::base_string::put ( int  position,
char  to_put 
)
pure virtual

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

Implemented in basis::astring.

◆ sub_compare()

virtual bool basis::base_string::sub_compare ( const base_string to_compare,
int  start_first,
int  start_second,
int  count,
bool  case_sensitive 
) const
pure 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.

Implemented in basis::astring.

◆ sub_string()

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

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

false is returned if the range is invalid.

Implemented in basis::astring.

◆ upgrade()

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

Sets the contents of this string to "s".

Implemented in basis::astring.

◆ zap()

virtual void basis::base_string::zap ( int  start,
int  end 
)
pure 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.

Implemented in basis::astring.


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