AXCEL C++ Framework
Elegance through abstraction
Public Member Functions
axcel::string Class Reference

String. More...

#include <axcel.h>

Inheritance diagram for axcel::string:
axcel::data axcel::io::ios axcel::io::input axcel::io::output axcel::io::iob axcel::io::iob axcel::object axcel::object

List of all members.

Public Member Functions

virtual string type ()
 "data"
virtual operator string ()
 Convert to string.
 string ()
 string (const char *s)
 string (size_t n)
 string (const string &s)
 string (const data &s)
 ~string ()
int getc ()
 Read byte.
int putc (int c)
 Write byte.
stringclear ()
 Clear string.
bool empty ()
 Is string empty?
size_t len ()
 Length.
size_t msize () const
 Resize buffer.
string cat (const char *s, size_t n=0)
 Concatenate string.
string cat (int c, size_t n=1)
 Concatenate character.
string prep (const char *s, size_t n=0)
 Prepend string.
string prep (int c, size_t n=1)
 Prepend character.
long chr (int c, size_t index=0)
 Find first character.
long rchr (int c)
 Find last character.
long str (const char *s, size_t index=0)
 Find first substring.
long rstr (const char *s)
 Find last substring.
bool starts (const char *s)
 Starts with string?
bool starts (int c)
 Starts with character?
bool ends (const char *s)
 Ends with string?
bool ends (int c)
 Ends with character?
bool is (const char *s)
 Same string content?
bool is (int c)
 Same string content?
string cpy (const char *src, size_t index=0, size_t count=0)
 Overwrite string.
string cpy (int c, size_t index=0, size_t count=1)
 Overwrite string.
size_t spn (const char *accept, size_t index=0)
 Length of set.
size_t spn (int c, size_t index=0)
 Length of set.
size_t cspn (const char *reject, size_t index=0)
 Length of set.
size_t cspn (int c, size_t index=0)
 Length of set.
string fry ()
 Randomize.
long pbrk (const char *accept, size_t index=0)
 Find any character.
long rpbrk (const char *accept, size_t index=0)
 Reverse find any character.
string substr (size_t start, size_t count)
 Get substring.
string tok (size_t index, const char *delim=" ")
 Extract token.
string tok (size_t index, int delim)
 Extract token.
size_t ntok (const char *delim=" ")
 Count tokens.
size_t ntok (int delim)
 Count tokens.
long itok (size_t index, const char *delim=" ")
 index of token
long itok (size_t index, int delim)
 index of token
std::deque< axcel::stringsplit (const char *delim=" ")
 Split string.
std::deque< axcel::stringsplit (int delim)
 Split string.
string wrap (size_t len, const char *eol="\r\n")
string left (size_t n)
 Get left substring.
string right (size_t n)
 Get right substring.
size_t nchr (int ch)
 Count of character occurrences.
size_t nstr (const char *str)
 Count of string occurrences.
string rep (const char *oldstr, const char *newstr)
 Search and replace.
string rep (int oldc, int newc)
 Search and replace.
string ins (size_t index, const char *str)
 insert into string
string ins (size_t index, int c)
 insert into string
string rm (size_t index, size_t n)
 Remove characters.
string rev (size_t start=0, size_t count=0)
 Reverse.
string dup (int i)
 Duplicate.
string ror (size_t i=1, size_t index=0, size_t count=0)
 Rotate right.
string rol (size_t i=1, size_t index=0, size_t count=0)
 Rotate left.
string shl (size_t n=1)
 Shift left.
string shr (size_t n=1)
 Shift right.
string lc (size_t start=0, size_t count=0)
 Lowercase.
string uc (size_t start=0, size_t count=0)
 Uppercase.
string q ()
 Single-quote string.
string qq ()
 Double-quote string.
string qx ()
 Execute string.
char & front ()
 Get first character.
char & back ()
 Get last character.
string esc (const char *format, int(*charfilter)(int)=NULL)
 Escape characters.
string esc (const char *format, const char *chrs)
 Escape characters.
string uesc (const char *format, int(*charfilter)(int)=NULL)
 Unescape string.
string uesc (const char *format, const char *chrs)
 Unescape string.
string untag (int opentag= '<', int closetag= '>')
 Strip tags.
string ltrim ()
 Left trim.
string rtrim ()
 Right trim.
string strip ()
 Strip whitespace.
string chop ()
 Remove last character.
string chomp (const char *eat="\r\n")
 Delete ending string.
string chomp (char eat)
 Remove ending character.
string cut ()
 Remove first character.
string munch (const char *eat)
 Delete starting string.
string munch (char eat)
 Remove starting character.
string prefix (const char *str)
 Prepend if not existing.
string suffix (const char *str)
 Append if not existing.
string slurp (char c)
 Remove up to first character occurrence.
string rslurp (char c)
 Remove up to last character occurrence.
string burn (char c)
 Remove starting from first character occurrence.
string rburn (char c)
 Remove starting from last character occurrence.
string slurp (const char *s)
 Remove up to first string occurrence.
string rslurp (const char *s)
 Remove up to first string occurrence.
string burn (const char *s)
 Remove starting from last string occurrence.
string rburn (const char *s)
 Remove starting from last string occurrence.
stringswap (string &s)
 Swap string content.
string center (size_t newlen, const char *left, const char *right)
 Center.
string center (size_t newlen, int left, int right)
 Center.
string center (size_t newlen, const char *pad=" ")
 Center.
string center (size_t newlen, int pad)
 Center.
string lpad (size_t newlen, const char *pad=" ")
 Pad left.
string lpad (size_t newlen, int pad)
 Pad left.
string rpad (size_t newlen, const char *pad=" ")
 Pad right.
string rpad (size_t newlen, int pad)
 Pad right.
string squeeze (const char *chrs=0)
 Remove repeating characters.
string squeeze (int chr)
 Remove repeating characters.
string alnums ()
 Get alphanumeric characters.
string alphas ()
 Get alphabetical characters.
string cntrls ()
 Get control characters.
string digits ()
 Get digit characters.
string graphs ()
 Get printable characters.
string lowers ()
 Get lowercase characters.
string prints ()
 Get printable characters.
string puncts ()
 Get punctuation characters.
string spaces ()
 Get whitespace characters.
string uppers ()
 Get uppercase characters.
string xdigits ()
 Get hex digit characters.
string ctypes (int(*cfunc)(int))
 Extract characters by type.
string ctypes (const char *chrs)
 Extract specific characters.
bool isalnum ()
 Alphanumeric check.
bool isalpha ()
 Alphabetical check.
bool iscntrl ()
 Control check.
bool isdigit ()
 Digit check.
bool isgraph ()
 Graph check.
bool islower ()
 Lowercase check.
bool isprint ()
 Printable check.
bool ispunct ()
 Punctuation check.
bool isspace ()
 Whitespace check.
bool isupper ()
 Uppercase check.
bool isxdigit ()
 Hex digit check.
bool isctype (int(*cfunc)(int))
 Compare character types.
bool isctype (const char *chrs)
 Compare character types.
string inc ()
 Alnum increment.
string dec ()
 Alnum decrement.
string incn ()
 Digit increment.
string decn ()
 Digit decrement.
string add (int n)
 Alnum increment recursively.
string add (const char *s)
string sub (int n)
 Alnum decrement recursively.
string sub (const char *s)
string addn (int n)
 Digit increment recursively.
string addn (const char *s)
string subn (int n)
 Digit decrement recursively.
string subn (const char *s)
unsigned short cksum ()
 Get checksum.
int cmpstr (const char *s,...)
 Compare to multiple strings.
int cmpinstr (const char *s,...)
 Find multiple strings.
int cmpleft (const char *s,...)
 Compare beginning to multiple strings.
int cmpright (const char *s,...)
 Compare end to multiple strings.
stringoperator= (string s)
stringoperator= (const char *s)
stringoperator= (const data &d)
string operator+ (const char *str)
 Concatenate.
string operator+ (char c)
 Concatenate.
stringoperator+= (const char *str)
 Concatenate and assign.
stringoperator+= (char c)
 Concatenate and assign.
string operator- (const char *str)
 Prepend.
string operator- (char c)
 Prepend.
stringoperator-= (const char *str)
 Prepend and assign.
stringoperator-= (char c)
 Prepend and assign.
bool operator== (const char *s)
 Is equal?
bool operator== (char c)
 Is equal?
bool operator!= (const char *s)
 Is not equal?
bool operator!= (char c)
 Is not equal?
char & operator[] (int i)
 Reference character.
string operator* (int i)
 Duplicate.
stringoperator*= (int i)
 Duplicate and assign.
string operator() ()
 Execute string.
 operator const char * ()
 operator char * ()
stringoperator++ ()
 Digit increment.
string operator++ (int foo)
 Digit increment.
stringoperator-- ()
 Digit decrement.
string operator-- (int foo)
 Digit decrement.

Detailed Description

String.

Most methods of this string class returns the result by value, not by reference; ergo, methods on a string can be chained together for epic pleasure and efficiency. This class also allows for reading and writing to the string like a file as it inherits from axcel::io::input and axcel::io::output. Unfortunately, this is a string of char's (not a wide character string) and does not support regular expressions.

Definition at line 586 of file axcel.h.


Constructor & Destructor Documentation

axcel::string::string ( )

Definition at line 1455 of file axcel.cpp.

axcel::string::string ( const char *  s)

Definition at line 1457 of file axcel.cpp.

axcel::string::string ( size_t  n)

Definition at line 1469 of file axcel.cpp.

axcel::string::string ( const string s)

Definition at line 1471 of file axcel.cpp.

axcel::string::string ( const data s)

Definition at line 3890 of file axcel.cpp.

axcel::string::~string ( )

Definition at line 1480 of file axcel.cpp.


Member Function Documentation

string axcel::string::add ( int  n)

Alnum increment recursively.

Parameters:
nNumber of times to increment
Returns:
This string incremented n times (see inc())

Definition at line 2947 of file axcel.cpp.

string axcel::string::add ( const char *  s)

Definition at line 3065 of file axcel.cpp.

string axcel::string::addn ( int  n)

Digit increment recursively.

Parameters:
nNumber of times to increment
Returns:
This string incremented n times (see incn())

Definition at line 3128 of file axcel.cpp.

string axcel::string::addn ( const char *  s)

Definition at line 3129 of file axcel.cpp.

string axcel::string::alnums ( )

Get alphanumeric characters.

Returns:
string containing all alphanumeric characters from this string

Definition at line 2797 of file axcel.cpp.

string axcel::string::alphas ( )

Get alphabetical characters.

Returns:
string containing all alphabetical characters from this string

Definition at line 2802 of file axcel.cpp.

char & axcel::string::back ( )

Get last character.

Returns:
this->buf[this->len() - 1]

Definition at line 1743 of file axcel.cpp.

string axcel::string::burn ( char  c) [inline]

Remove starting from first character occurrence.

Parameters:
cCharacter to find
Returns:
This string with all characters removed starting from the first occurrence of c

Finds the first occurrence of c, and removes that character and all characters proceeding it in this string.

Definition at line 702 of file axcel.h.

string axcel::string::burn ( const char *  s) [inline]

Remove starting from last string occurrence.

Parameters:
sstring to find
Returns:
This string with all characters removed starting from the first occurrence of s

Finds the first occurrence of s, and removes that string and all characters proceeding it in this string.

Definition at line 738 of file axcel.h.

string axcel::string::cat ( int  c,
size_t  n = 1 
)

Concatenate character.

Parameters:
cCharacter to append
nNumber of times to append character (default = 1)
Returns:
string object result

Definition at line 1823 of file axcel.cpp.

string axcel::string::cat ( const char *  s,
size_t  n = 0 
)

Concatenate string.

Parameters:
sstring to append
Numberof characters from s to append (default = all)
Returns:
string object of result of appending s to this string

Definition at line 1792 of file axcel.cpp.

string axcel::string::center ( size_t  newlen,
const char *  left,
const char *  right 
)

Center.

Parameters:
newlenNew length
leftLeft padding character pattern
rightRight padding character pattern
Returns:
string object result

Definition at line 2610 of file axcel.cpp.

string axcel::string::center ( size_t  newlen,
int  left,
int  right 
)

Center.

Parameters:
newlenNew length
leftLeft padding character
rightRight padding character
Returns:
string object result

Definition at line 2625 of file axcel.cpp.

string axcel::string::center ( size_t  newlen,
const char *  pad = " " 
)

Center.

Parameters:
newlenNew length
padCharacter pattern padding
Returns:
string object result

Definition at line 2637 of file axcel.cpp.

string axcel::string::center ( size_t  newlen,
int  pad 
)

Center.

Parameters:
newlenNew length
padPadding character
Returns:
string object result

Definition at line 2646 of file axcel.cpp.

string axcel::string::chomp ( const char *  eat = "\r\n")

Delete ending string.

Parameters:
eatstring to delete
Returns:
This string with the ending string eat removed (if it exists)

Definition at line 2538 of file axcel.cpp.

string axcel::string::chomp ( char  c)

Remove ending character.

Parameters:
cCharacter to remove
Returns:
This string with the ending character c removed if it exists

Definition at line 3108 of file axcel.cpp.

string axcel::string::chop ( )

Remove last character.

Returns:
This string with the last character removed (if it ends with \r\n then both are removed)

Definition at line 2521 of file axcel.cpp.

long axcel::string::chr ( int  c,
size_t  index = 0 
)

Find first character.

Parameters:
cCharacter to find
indexindex to start searching from (default = 0)
Returns:
index of character or -1 if not found

Definition at line 1877 of file axcel.cpp.

unsigned short axcel::string::cksum ( )

Get checksum.

Returns:
BSD checksum of this null-terminated string

Definition at line 3151 of file axcel.cpp.

string & axcel::string::clear ( )

Clear string.

Returns:
This object after null terminating first byte of this string

Definition at line 1748 of file axcel.cpp.

int axcel::string::cmpinstr ( const char *  s,
  ... 
)

Find multiple strings.

Returns:
index of first string from list of null pointer terminated const char* arguments occurs in this string. -1 if none.

Definition at line 3331 of file axcel.cpp.

int axcel::string::cmpleft ( const char *  s,
  ... 
)

Compare beginning to multiple strings.

Returns:
index of which string in list of null pointer terminated const char* arguments matches the beginning of this string. -1 if none.

Definition at line 3346 of file axcel.cpp.

int axcel::string::cmpright ( const char *  s,
  ... 
)

Compare end to multiple strings.

Returns:
index of which string in null-terminated list of const char* arguments matches the end of this string.

Definition at line 3361 of file axcel.cpp.

int axcel::string::cmpstr ( const char *  s,
  ... 
)

Compare to multiple strings.

Returns:
index of which string in null-terminated list of const char* arguments matches this string. -1 if none.

Definition at line 3316 of file axcel.cpp.

string axcel::string::cntrls ( )

Get control characters.

Returns:
string containing all control characters from this string

Definition at line 2807 of file axcel.cpp.

string axcel::string::cpy ( const char *  src,
size_t  index = 0,
size_t  count = 0 
)

Overwrite string.

Parameters:
srcstring to to copy from
indexOffset of this string to copy to
countNumber of characters from src to copy
Returns:
string object result

Definition at line 2013 of file axcel.cpp.

string axcel::string::cpy ( int  c,
size_t  index = 0,
size_t  count = 1 
)

Overwrite string.

Parameters:
cCharacter to copy from
indexOffset of this string to copy to
countNumber of times to copy c
Returns:
string object result

Definition at line 2028 of file axcel.cpp.

size_t axcel::string::cspn ( const char *  reject,
size_t  index = 0 
)

Length of set.

Parameters:
acceptDisallowed characters
indexindex to start from (default = 0)
Returns:
Length of initial segment of string consisting entirely of characters not in accept

Definition at line 2058 of file axcel.cpp.

size_t axcel::string::cspn ( int  c,
size_t  index = 0 
)

Length of set.

Parameters:
cDisallowed character
indexindex to start from (default = 0)
Returns:
Length of initial segment of string consisting entirely of any character but c

Definition at line 2077 of file axcel.cpp.

string axcel::string::ctypes ( int(*)(int)  cfunc)

Extract characters by type.

Parameters:
cfuncFunction accepting character returning 1 or 0
Returns:
string containing (in order) all characters from this string that get a return value of 1 when passed to cfunc

Definition at line 2746 of file axcel.cpp.

string axcel::string::ctypes ( const char *  chrs)

Extract specific characters.

Parameters:
chrsAllowed characters
Returns:
string containing (in order) all characters from this string that are found in chrs

Definition at line 2760 of file axcel.cpp.

string axcel::string::cut ( )

Remove first character.

Returns:
This string with the first character removed (if it starts with \r\n then both are removed)

Definition at line 2564 of file axcel.cpp.

string axcel::string::dec ( )

Alnum decrement.

Returns:
The predecessor of this string

Decrements the alpanumeric portion of this string. Examples:

  • "ABC" -> "ABB"
  • "fs::file001" -> "fs::file000"
  • "Product XYZ" -> "Product XYY"
  • "299" -> "298"

Definition at line 2997 of file axcel.cpp.

string axcel::string::decn ( )

Digit decrement.

Returns:
The predecessor of this string (only digit characters decremented. see dec())

Definition at line 3035 of file axcel.cpp.

string axcel::string::digits ( )

Get digit characters.

Returns:
string containing all digit characters from this string

Definition at line 2812 of file axcel.cpp.

string axcel::string::dup ( int  i)

Duplicate.

Parameters:
iNumbers of times to duplicate
Returns:
This string concatenated to itself i - 1 times

Definition at line 2367 of file axcel.cpp.

bool axcel::string::empty ( )

Is string empty?

Returns:
true if no string content, false if not

Definition at line 1753 of file axcel.cpp.

bool axcel::string::ends ( const char *  s)

Ends with string?

Parameters:
sstring to compare
Returns:
true if this string ends with s, false if not

Definition at line 1960 of file axcel.cpp.

bool axcel::string::ends ( int  c)

Ends with character?

Parameters:
cCharacter to compare
Returns:
true if this string ends with c, false if not

Definition at line 1970 of file axcel.cpp.

string axcel::string::esc ( const char *  format,
const char *  chrs 
)

Escape characters.

Parameters:
formatEscaped character format
chrsWhich characters to escape
Returns:
Result of escaped string

For each character in the string, the character will be replaced using the format string if chrs contains that character. format uses the same format as used by a printf function, except the only token value provided is the value of that character.

This example will replace '%', '$', '&', and '*' characters with "\xAA" where AA is the 2-digit hex number value of the character: mystr.esc("\\x%02x", "$%&*");

Definition at line 1569 of file axcel.cpp.

string axcel::string::esc ( const char *  format,
int(*)(int)  charfilter = NULL 
)

Escape characters.

Parameters:
formatEscaped character format
charfilterCharacter type function
Returns:
Result of escaped string

For each character in the string, the character will be replaced using the format string if charfilter returns true on that character. format uses the same format as used by a printf function, except the only token value provided is the value of that character.

This example will replace all whitespace characters with "%XX" where XX is the 2 digit hex number value of the character: mystr.esc("%%%02x", isspace)

This next example will replace all punctuation characters with "&#D;"

where D is the decimal number value of the character: mystr.esc("&#%d;", ispunct);

Definition at line 1538 of file axcel.cpp.

char & axcel::string::front ( )

Get first character.

Returns:
this->buf[0]

Definition at line 1738 of file axcel.cpp.

string axcel::string::fry ( )

Randomize.

Returns:
Anagram of this string

Definition at line 2087 of file axcel.cpp.

int axcel::string::getc ( ) [virtual]

Read byte.

Returns:
Character read as an unsigned char cast to an int or EOF on end of file or error

Reads the next character from stream and returns it as an unsigned char cast to an int, or EOF on end of file or error. Before returning from the method, one of the following methods of the stream must be called:

  • If end of file is reached, the method must call drain()
  • If a small error occurs but the stream is still usable, the method must call hurt()
  • If a fatal error occurs and the stream is unusable, the method must call kill()
  • If successful, the method must call heal()

Reimplemented from axcel::data.

Definition at line 1416 of file axcel.cpp.

string axcel::string::graphs ( )

Get printable characters.

Returns:
string containing all printable characters (except space) from this string

Definition at line 2817 of file axcel.cpp.

string axcel::string::inc ( )

Alnum increment.

Returns:
The successor to this string

increments the alpanumeric portion of this string. Examples:

  • "ABC" -> "ABD"
  • "fs::file001" -> "fs::file002"
  • "Product XYZ" -> "Product XZA"
  • "299" -> "300"

Definition at line 2913 of file axcel.cpp.

string axcel::string::incn ( )

Digit increment.

Returns:
The successor to this string (only digit characters incremented. see inc())

Definition at line 2968 of file axcel.cpp.

string axcel::string::ins ( size_t  index,
const char *  str 
)

insert into string

Parameters:
indexindex of where to insert in this string
strstring to insert
Returns:
string object result

Definition at line 2303 of file axcel.cpp.

string axcel::string::ins ( size_t  index,
int  c 
)

insert into string

Parameters:
indexindex of where to insert in this string
strCharacter to insert
Returns:
string object result

Definition at line 2319 of file axcel.cpp.

bool axcel::string::is ( const char *  s)

Same string content?

Parameters:
sstring to compare
Returns:
true is this string has same content as s, false if not

Definition at line 1976 of file axcel.cpp.

bool axcel::string::is ( int  c)

Same string content?

Parameters:
cCharacter to compare
Returns:
true if this string contains only a single character matching c, false if not

Definition at line 1982 of file axcel.cpp.

bool axcel::string::isalnum ( )

Alphanumeric check.

Returns:
true if all characters in this string are alphanumeric

Definition at line 2852 of file axcel.cpp.

bool axcel::string::isalpha ( )

Alphabetical check.

Returns:
true if all characters in this string are alphabetical

Definition at line 2857 of file axcel.cpp.

bool axcel::string::iscntrl ( )

Control check.

Returns:
true if all characters in this string are control characters

Definition at line 2862 of file axcel.cpp.

bool axcel::string::isctype ( int(*)(int)  cfunc)

Compare character types.

Parameters:
chrsFunction accepting character returning 1 or 0
Returns:
true if all characters in this string get a return of 1 when passed to cfunc

Definition at line 2774 of file axcel.cpp.

bool axcel::string::isctype ( const char *  chrs)

Compare character types.

Parameters:
chrsAllowed characters
Returns:
true if all characters in this string are only the ones specified in chrs

Definition at line 2786 of file axcel.cpp.

bool axcel::string::isdigit ( )

Digit check.

Returns:
true if all characters in this string are digits

Definition at line 2867 of file axcel.cpp.

bool axcel::string::isgraph ( )

Graph check.

Returns:
true if all characters in this string are printable and there are no spaces

Definition at line 2872 of file axcel.cpp.

bool axcel::string::islower ( )

Lowercase check.

Returns:
true if all characters in this string are lowercase

Definition at line 2877 of file axcel.cpp.

bool axcel::string::isprint ( )

Printable check.

Returns:
true if all characters in this string are printable

Definition at line 2882 of file axcel.cpp.

bool axcel::string::ispunct ( )

Punctuation check.

Returns:
true if all characters in this string are punctuation characters

Definition at line 2887 of file axcel.cpp.

bool axcel::string::isspace ( )

Whitespace check.

Returns:
true if all characters in this string are whitespace

Definition at line 2892 of file axcel.cpp.

bool axcel::string::isupper ( )

Uppercase check.

Returns:
true if all characters in this string are uppercase

Definition at line 2897 of file axcel.cpp.

bool axcel::string::isxdigit ( )

Hex digit check.

Returns:
true if all characters in this string are hexadecimal digits

Definition at line 2902 of file axcel.cpp.

long axcel::string::itok ( size_t  index,
const char *  delim = " " 
)

index of token

Parameters:
indexToken index
delimDelimiting characters
Returns:
index of token in this string

Returns the index of where the token occurs in this string if it were to be split by delim.

Example:

        string mystr = "The quick brown fox";
        con.echo(mystr.itok(2, " "))

The above outputs the number 10.

Definition at line 2235 of file axcel.cpp.

long axcel::string::itok ( size_t  index,
int  delim 
)

index of token

Parameters:
indexToken index
delimDelimiting character
Returns:
index of token in this string

Returns the index of where the token occurs in this string if it were to be split by delim.

Example:

        string mystr = "The quick brown fox";
        con.echo(mystr.itok(2, ' '))

The above outputs the number 10.

Definition at line 2265 of file axcel.cpp.

string axcel::string::lc ( size_t  start = 0,
size_t  count = 0 
)

Lowercase.

Parameters:
startindex of substring
countLength of substring
Returns:
This string with the substring converted to lowercase

Definition at line 2442 of file axcel.cpp.

string axcel::string::left ( size_t  n)

Get left substring.

Parameters:
nNumber of left-most characters to extract
Returns:
string containing first n characters of this string

Definition at line 1988 of file axcel.cpp.

size_t axcel::string::len ( )

Length.

Returns:
Number of characters in this string (not including terminating null)

Definition at line 1758 of file axcel.cpp.

string axcel::string::lowers ( )

Get lowercase characters.

Returns:
string containing all lowercase characters from this string

Definition at line 2827 of file axcel.cpp.

string axcel::string::lpad ( size_t  newlen,
const char *  pad = " " 
)

Pad left.

Parameters:
newlenNew length
padLeft padding character pattern
Returns:
string object result

Definition at line 2657 of file axcel.cpp.

string axcel::string::lpad ( size_t  newlen,
int  pad 
)

Pad left.

Parameters:
newlenNew length
padLeft padding character
Returns:
string object result

Definition at line 2692 of file axcel.cpp.

string axcel::string::ltrim ( )

Left trim.

Returns:
This string with all leading whitespace removed

Definition at line 2477 of file axcel.cpp.

size_t axcel::string::msize ( ) const

Resize buffer.

Parameters:
iRequested size
Returns:
This object

Resizes the dynamically allocated character array member buf to fit i or more characters (including the terminating null byte).

Get capacity

Returns:
The number of bytes allocated to the dynamically allocated internal char array buf

Definition at line 1785 of file axcel.cpp.

string axcel::string::munch ( const char *  eat)

Delete starting string.

Parameters:
eatstring to delete
Returns:
This string with the string eat removed from the beginning of this string (if it exists)

Definition at line 2580 of file axcel.cpp.

string axcel::string::munch ( char  c)

Remove starting character.

Parameters:
cCharacter to remove
Returns:
This string with the starting character c removed if it exists

Definition at line 3118 of file axcel.cpp.

size_t axcel::string::nchr ( int  ch)

Count of character occurrences.

Parameters:
chCharacter to find and count
Returns:
Number of times ch appears in string

Definition at line 1923 of file axcel.cpp.

size_t axcel::string::nstr ( const char *  str)

Count of string occurrences.

Parameters:
strstring to find and count
Returns:
Number of times str appears in string

Definition at line 1935 of file axcel.cpp.

size_t axcel::string::ntok ( const char *  delim = " ")

Count tokens.

Parameters:
delimDelimiting characters
Returns:
Number of tokens

Returns the count of tokens if this string were to be split by delim.

Definition at line 2195 of file axcel.cpp.

size_t axcel::string::ntok ( int  delim)

Count tokens.

Parameters:
delimDelimiting character
Returns:
Number of tokens

Returns the count of tokens if this string were to be split by delim.

Definition at line 2215 of file axcel.cpp.

axcel::string::operator char * ( ) [inline, virtual]

Reimplemented from axcel::data.

Definition at line 823 of file axcel.h.

axcel::string::operator const char * ( ) [inline]

Definition at line 822 of file axcel.h.

axcel::string::operator string ( ) [virtual]

Convert to string.

The string represenation of this object is the hex values of all the bytes in the internal data buffer delimited by spaces.

Reimplemented from axcel::data.

Definition at line 285 of file axcel.cpp.

bool axcel::string::operator!= ( char  c)

Is not equal?

Parameters:
cCharacter to compare
Returns:
true if this string has more than 1 character and/or the first character does not match c, false if not

Definition at line 3254 of file axcel.cpp.

bool axcel::string::operator!= ( const char *  str)

Is not equal?

Parameters:
strstring to compare
Returns:
true if both string do not have equal content, false if not

Reimplemented from axcel::data.

Definition at line 3248 of file axcel.cpp.

string axcel::string::operator() ( )

Execute string.

Returns:
string output of command shell executing this string as a system command

Definition at line 3286 of file axcel.cpp.

string axcel::string::operator* ( int  i)

Duplicate.

Parameters:
iNumber of times to duplicate
Returns:
This string concatenated with itself i - 1 times

Definition at line 3266 of file axcel.cpp.

string & axcel::string::operator*= ( int  i)

Duplicate and assign.

Parameters:
iNumber of times to duplicate
Returns:
Reference to this string concatenated with itself i - 1 times

Definition at line 3278 of file axcel.cpp.

string axcel::string::operator+ ( char  c)

Concatenate.

Parameters:
cCharacter to append
Returns:
This string concatenated with c

Definition at line 3194 of file axcel.cpp.

string axcel::string::operator+ ( const char *  str)

Concatenate.

Parameters:
strstring to append
Returns:
This string concatenated with str

Definition at line 3188 of file axcel.cpp.

string & axcel::string::operator++ ( )

Digit increment.

Returns:
Reference to this digit incremented string (see incn())

Definition at line 3291 of file axcel.cpp.

string axcel::string::operator++ ( int  foo)

Digit increment.

Returns:
The current value of this string before digit incrementing it (see incn())

Definition at line 3296 of file axcel.cpp.

string & axcel::string::operator+= ( char  c)

Concatenate and assign.

Parameters:
cCharacter to append
Returns:
Reference to this string concatenated with c

Definition at line 3206 of file axcel.cpp.

string & axcel::string::operator+= ( const char *  str)

Concatenate and assign.

Parameters:
strstring to append
Returns:
Reference to this string concatenated with str

Definition at line 3200 of file axcel.cpp.

string axcel::string::operator- ( char  c)

Prepend.

Parameters:
cCharacter to prepend
Returns:
c prepended to this string

Definition at line 3218 of file axcel.cpp.

string axcel::string::operator- ( const char *  str)

Prepend.

Parameters:
strstring to prepend
Returns:
str prepended to this string

Definition at line 3212 of file axcel.cpp.

string axcel::string::operator-- ( int  foo)

Digit decrement.

Returns:
The current value of this string before digit decrementing it (see decn())

Definition at line 3306 of file axcel.cpp.

string & axcel::string::operator-- ( )

Digit decrement.

Returns:
Reference to this digit incremented string (see decn())

Definition at line 3301 of file axcel.cpp.

string & axcel::string::operator-= ( const char *  str)

Prepend and assign.

Parameters:
strstring to prepend
Returns:
Reference to str prepended to this string

Definition at line 3224 of file axcel.cpp.

string & axcel::string::operator-= ( char  c)

Prepend and assign.

Parameters:
cCharacter to prepend
Returns:
Reference to c prepended to this string

Definition at line 3230 of file axcel.cpp.

string & axcel::string::operator= ( const data d)

Definition at line 3899 of file axcel.cpp.

string & axcel::string::operator= ( string  s)

Definition at line 3162 of file axcel.cpp.

string & axcel::string::operator= ( const char *  s)

Reimplemented from axcel::data.

Definition at line 3171 of file axcel.cpp.

bool axcel::string::operator== ( const char *  str)

Is equal?

Parameters:
strstring to compare
Returns:
true if both strings have equal content, false if not

Reimplemented from axcel::data.

Definition at line 3236 of file axcel.cpp.

bool axcel::string::operator== ( char  c)

Is equal?

Parameters:
cCharacter to compare
Returns:
true if this string contains only 1 character which matches c, false if not

Definition at line 3242 of file axcel.cpp.

char & axcel::string::operator[] ( int  i)

Reference character.

Parameters:
iCharacter index
Returns:
Reference to character within this string

Reimplemented from axcel::data.

Definition at line 3260 of file axcel.cpp.

long axcel::string::pbrk ( const char *  accept,
size_t  index = 0 
)

Find any character.

Parameters:
acceptCharacters to search for
indexindex to start searching from
Returns:
index of result or -1 if not found

Locates the first occurrence in the string of any of the characters in string accept.

Definition at line 2114 of file axcel.cpp.

string axcel::string::prefix ( const char *  str)

Prepend if not existing.

Parameters:
strstring to prepend
Returns:
This string with str prepended to it if str is not already prepended

Definition at line 5092 of file axcel.cpp.

string axcel::string::prep ( const char *  s,
size_t  n = 0 
)

Prepend string.

Parameters:
sstring to prepend
nNumber of characters from s to append (default = all)
Returns:
string object result

Definition at line 1841 of file axcel.cpp.

string axcel::string::prep ( int  c,
size_t  n = 1 
)

Prepend character.

Parameters:
cCharacter to prepend
nNumber of times to prepend character (default = 1)
Returns:
string object result

Definition at line 1859 of file axcel.cpp.

string axcel::string::prints ( )

Get printable characters.

Returns:
string containing all printable characters from this string

Definition at line 2832 of file axcel.cpp.

string axcel::string::puncts ( )

Get punctuation characters.

Returns:
string containing all punctuation characters from this string

Definition at line 2822 of file axcel.cpp.

int axcel::string::putc ( int  c) [virtual]

Write byte.

Parameters:
cCharacter to write
Returns:
Character written or EOF on end of file or error

Writes character c to stream and returns a non-negative number on success or EOF on error. Before returning from within this method, one of the following methods must be called:

  • If end of file is reached, the method must call drain()
  • If an error occurs, the method must call kill()
  • If successful, the method must call heal()

Reimplemented from axcel::data.

Definition at line 1488 of file axcel.cpp.

string axcel::string::q ( )

Single-quote string.

Returns:
Value of this string enclosed in single-quotes '''.

Definition at line 1671 of file axcel.cpp.

string axcel::string::qq ( )

Double-quote string.

Returns:
Value of this string enclosed in double-quotes '"'.

Definition at line 1684 of file axcel.cpp.

string axcel::string::qx ( )

Execute string.

Returns:
string output of this string executed as a system shell command

Definition at line 1697 of file axcel.cpp.

string axcel::string::rburn ( char  c) [inline]

Remove starting from last character occurrence.

Parameters:
cCharacter to find
Returns:
This string with all characters removed starting from the last occurrence of c

Finds the last occurrence of c, and removes that character and all characters proceeding it in this string.

Definition at line 711 of file axcel.h.

string axcel::string::rburn ( const char *  s) [inline]

Remove starting from last string occurrence.

Parameters:
sstring to find
Returns:
This string with all characters removed starting from the last occurrence of s

Finds the last occurrence of s, and removes that string and all characters proceeding it in this string.

Definition at line 747 of file axcel.h.

long axcel::string::rchr ( int  c)

Find last character.

Parameters:
cCharacter to find
Returns:
Last index of character or -1 if not found

Definition at line 1888 of file axcel.cpp.

string axcel::string::rep ( const char *  oldstr,
const char *  newstr 
)

Search and replace.

Parameters:
oldstrstring to search
newstrstring to replace it with
Returns:
This string with all occurrences of oldstr replaced with newstr

Definition at line 5059 of file axcel.cpp.

string axcel::string::rep ( int  oldc,
int  newc 
)

Search and replace.

Parameters:
oldcCharacter to search
newcCharacter to replace it with
Returns:
This string with all occurrences of old replaced with newc

Definition at line 5081 of file axcel.cpp.

string axcel::string::rev ( size_t  start = 0,
size_t  count = 0 
)

Reverse.

Parameters:
startStarting index
countCount of characters in substring to reverse
Returns:
string object result

Definition at line 2345 of file axcel.cpp.

string axcel::string::right ( size_t  n)

Get right substring.

Parameters:
nNumber of right-most characters to extract
Returns:
string containing last n characters of this string

Definition at line 2000 of file axcel.cpp.

string axcel::string::rm ( size_t  index,
size_t  n 
)

Remove characters.

Parameters:
indexindex of where to start removing characters
nNumber of characters to remove
Returns:
string object result

Definition at line 2330 of file axcel.cpp.

string axcel::string::rol ( size_t  i = 1,
size_t  index = 0,
size_t  count = 0 
)

Rotate left.

Parameters:
iNumber of times to rotate
indexindex of substring to rotate
countLength of substring to rotate
Returns:
string object result

Definition at line 2383 of file axcel.cpp.

string axcel::string::ror ( size_t  i = 1,
size_t  index = 0,
size_t  count = 0 
)

Rotate right.

Parameters:
iNumber of times to rotate
indexindex of substring to rotate
countLength of substring to rotate
Returns:
string object result

Definition at line 2401 of file axcel.cpp.

string axcel::string::rpad ( size_t  newlen,
const char *  pad = " " 
)

Pad right.

Parameters:
newlenNew length
padRight padding character pattern
Returns:
string object result

Definition at line 2674 of file axcel.cpp.

string axcel::string::rpad ( size_t  newlen,
int  pad 
)

Pad right.

Parameters:
newlenNew length
padRight padding character
Returns:
string object result

Definition at line 2703 of file axcel.cpp.

long axcel::string::rpbrk ( const char *  accept,
size_t  index = 0 
)

Reverse find any character.

Parameters:
acceptCharacters to search for
indexindex to start searching from
Returns:
Last index of result or -1 if not found

Locates the last occurrence in the string of any of the characters in string accept.

Definition at line 2128 of file axcel.cpp.

string axcel::string::rslurp ( char  c) [inline]

Remove up to last character occurrence.

Parameters:
cCharacter to find
Returns:
This string with all characters removed up until passed the last occurrence of c

Finds the last occurrence of c, and removes that character and all characters preceeding it in this string.

Definition at line 693 of file axcel.h.

string axcel::string::rslurp ( const char *  s) [inline]

Remove up to first string occurrence.

Parameters:
sstring to find
Returns:
This string with all characters up until passed the end of the last occurrence of s

Finds the last occurrence of s, and removes that string and all characters preceeding it in this string.

Definition at line 729 of file axcel.h.

long axcel::string::rstr ( const char *  s)

Find last substring.

Parameters:
sstring to find
Returns:
Last index of string or -1 if not found

Definition at line 1911 of file axcel.cpp.

string axcel::string::rtrim ( )

Right trim.

Returns:
This string with all trailing whitespace removed

Definition at line 2489 of file axcel.cpp.

string axcel::string::shl ( size_t  n = 1)

Shift left.

Parameters:
nNumber of times to shift
Returns:
This string with the first n characters removed

Definition at line 2417 of file axcel.cpp.

string axcel::string::shr ( size_t  n = 1)

Shift right.

Parameters:
nNumber of times to shift
Returns:
This string with the last n characters removed

Definition at line 2428 of file axcel.cpp.

string axcel::string::slurp ( char  c) [inline]

Remove up to first character occurrence.

Parameters:
cCharacter to find
Returns:
This string with all characters removed up until passed the first occurrence of c

Finds the first occurrence of c, and removes that character and all characters preceeding it in this string.

Definition at line 684 of file axcel.h.

string axcel::string::slurp ( const char *  s) [inline]

Remove up to first string occurrence.

Parameters:
sstring to find
Returns:
This string with all characters removed up until passed the end of the first occurrence of s

Finds the first occurrence of s, and removes that string and all characters preceeding it in this string.

Definition at line 720 of file axcel.h.

string axcel::string::spaces ( )

Get whitespace characters.

Returns:
string containing all whitespace characters from this string

Definition at line 2837 of file axcel.cpp.

std::deque< axcel::string > axcel::string::split ( const char *  delim = " ")

Split string.

Parameters:
delimDelimiting characters
Returns:
deque of strings

Splits this string by delim, storing each string object token into a deque.

Definition at line 2278 of file axcel.cpp.

std::deque< axcel::string > axcel::string::split ( int  delim)

Split string.

Parameters:
delimDelimiting character
Returns:
deque of strings

Splits this string by delim, storing each string object token into a deque.

Definition at line 2296 of file axcel.cpp.

size_t axcel::string::spn ( int  c,
size_t  index = 0 
)

Length of set.

Parameters:
cAllowed character
indexindex to start from (default = 0)
Returns:
Length of initial segment of string consisting entirely of character c

Definition at line 2065 of file axcel.cpp.

size_t axcel::string::spn ( const char *  accept,
size_t  index = 0 
)

Length of set.

Parameters:
acceptAllowed characters
indexindex to start from (default = 0)
Returns:
Length of initial segment of string consisting entirely of characters in accept

Definition at line 2051 of file axcel.cpp.

string axcel::string::squeeze ( const char *  chrs = 0)

Remove repeating characters.

Parameters:
chrsCharacters to check for and shrink
Returns:
This string with all repeating characters specified in chrs shrunk to only one occurrence of that character at a time

Definition at line 2713 of file axcel.cpp.

string axcel::string::squeeze ( int  chr)

Remove repeating characters.

Parameters:
chrCharacter to check for and shrink
Returns:
This string with all repeating characters specified in chr shrunk to only one occurrence of that character at a time

Definition at line 2736 of file axcel.cpp.

bool axcel::string::starts ( const char *  s)

Starts with string?

Parameters:
sstring to compare
Returns:
true if this string starts with s, false if not

Definition at line 1948 of file axcel.cpp.

bool axcel::string::starts ( int  c)

Starts with character?

Parameters:
cCharacter to compare
Returns:
true if this string starts with c, false if not

Definition at line 1954 of file axcel.cpp.

long axcel::string::str ( const char *  s,
size_t  index = 0 
)

Find first substring.

Parameters:
sstring to find
indexindex to start searching from
Returns:
index of string or -1 if not found

Definition at line 1900 of file axcel.cpp.

string axcel::string::strip ( )

Strip whitespace.

Returns:
This string with all leading and trailing whitespace removed

Definition at line 2502 of file axcel.cpp.

string axcel::string::sub ( const char *  s)

Definition at line 3084 of file axcel.cpp.

string axcel::string::sub ( int  n)

Alnum decrement recursively.

Parameters:
nNumber of times to decrement
Returns:
This string decremented n times (see dec())

Definition at line 2958 of file axcel.cpp.

string axcel::string::subn ( const char *  s)

Definition at line 3141 of file axcel.cpp.

string axcel::string::subn ( int  n)

Digit decrement recursively.

Parameters:
nNumber of times to decrement
Returns:
This string decremented n times (see decn())

Definition at line 3140 of file axcel.cpp.

string axcel::string::substr ( size_t  start,
size_t  count 
)

Get substring.

Parameters:
startStarting index of substring
countLength of substring
Returns:
Substring string object

Definition at line 2141 of file axcel.cpp.

string axcel::string::suffix ( const char *  str)

Append if not existing.

Parameters:
strstring to append
Returns:
This string with str appended to it if str is not already appended

Definition at line 5102 of file axcel.cpp.

string & axcel::string::swap ( string s)

Swap string content.

Parameters:
sstring to swap content with
Returns:
Reference to this string

Definition at line 2593 of file axcel.cpp.

string axcel::string::tok ( size_t  index,
int  delim 
)

Extract token.

Parameters:
indexToken index
delimDelimiting character
Returns:
Token string object

Returns the index'th token of this string if it were to be split by delim.

Definition at line 2181 of file axcel.cpp.

string axcel::string::tok ( size_t  index,
const char *  delim = " " 
)

Extract token.

Parameters:
indexToken index
delimDelimiting characters
Returns:
Token string object

Returns the index'th token of this string if it were to be split by delim.

Definition at line 2158 of file axcel.cpp.

string axcel::string::type ( ) [virtual]

"data"

Reimplemented from axcel::data.

Definition at line 259 of file axcel.cpp.

string axcel::string::uc ( size_t  start = 0,
size_t  count = 0 
)

Uppercase.

Parameters:
startindex of substring
countLength of substring
Returns:
This string with the substring converted to uppercase

Definition at line 2460 of file axcel.cpp.

string axcel::string::uesc ( const char *  format,
int(*)(int)  charfilter = NULL 
)

Unescape string.

Parameters:
Formatof escaped character
charfilterctype-like function for which character group to unescape

Matches sub-strings containing the same format as format and replaces them with their real character values. A string escaped using esc("$%3d", iscntrl) can be unescaped using uesc("$%3d", iscntrl). Only characters yielding true from the function charfilter will be unescaped.

Definition at line 1624 of file axcel.cpp.

string axcel::string::uesc ( const char *  format,
const char *  chrs 
)

Unescape string.

Parameters:
formatFormat of escaped character
chrsCharacters to unescape

The inverse of esc(). Matches sub-strings containing the same format as format and replaces them with their real character values. A string escaped using esc("<%d>", "~!@#$") can be unescaped using uesc("<%d>", "~!@#$"). Only characters specified in chrs will be unescaped.

Definition at line 1594 of file axcel.cpp.

string axcel::string::untag ( int  opentag = '<',
int  closetag = '>' 
)

Strip tags.

Parameters:
opentagOpening tag character
closetagClosing tag character
Returns:
This string with all tags (characters enclosed with opentag and closetag) removed

Definition at line 5113 of file axcel.cpp.

string axcel::string::uppers ( )

Get uppercase characters.

Returns:
string containing all uppercase characters from this string

Definition at line 2842 of file axcel.cpp.

string axcel::string::wrap ( size_t  len,
const char *  eol = "\r\n" 
)

Definition at line 1804 of file axcel.cpp.

string axcel::string::xdigits ( )

Get hex digit characters.

Returns:
string containing all hexadecimal digit characters from this string

Definition at line 2847 of file axcel.cpp.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Defines