#include <include/EST_String.h>
Public Types | |
typedef size_t | EST_string_size |
Type of string size field. More... | |
Public Member Functions | |
EST_String (void) | |
Construct an empty string. More... | |
EST_String (const char *s) | |
Construct from char *. More... | |
EST_String (const char *s, int start_or_fill, ssize_t len) | |
Construct from part of char * or fill with given character. More... | |
EST_String (const char *s, size_t s_size, size_t start, ssize_t len) | |
Construct from C string. More... | |
EST_String (const EST_String &s, size_t start, ssize_t len) | |
EST_String (const EST_String &s) | |
~EST_String () | |
Destructor. More... | |
size_t | length (void) const |
Length of string ({not} length of underlying chunk) More... | |
int | space (void) const |
Size of underlying chunk. More... | |
const char * | str (void) const |
Get a const-pointer to the actual memory. More... | |
char * | updatable_str (void) |
Get a writable pointer to the actual memory. More... | |
void | make_updatable (void) |
int | Int (bool &ok) const |
Convert to an integer. More... | |
int | Int (void) const |
long | Long (bool &ok) const |
Convert to a long. More... | |
long | Long (void) const |
float | Float (bool &ok) const |
Convert to a float. More... | |
float | Float (void) const |
double | Double (bool &ok) const |
Convert to a double. More... | |
double | Double (void) const |
EST_String & | ignore_volatile (void) volatile |
Before | |
EST_String | before (int pos, int len=0) const |
Part before position. More... | |
EST_String | before (const char *s, int pos=0) const |
Part before first matching substring after pos. More... | |
EST_String | before (const EST_String &s, int pos=0) const |
Part before first matching substring after pos. More... | |
EST_String | before (EST_Regex &e, int pos=0) const |
Part before first match of regexp after pos. More... | |
At | |
EST_String | at (int from, int len=0) const |
Return part at position. More... | |
EST_String | at (const char *s, int pos=0) const |
Return part where substring found (not useful, included for completeness) More... | |
EST_String | at (const EST_String &s, int pos=0) const |
Return part where substring found (not useful, included for completeness) More... | |
EST_String | at (EST_Regex &e, int pos=0) const |
Return part matching regexp. More... | |
After | |
EST_String | after (int pos, int len=1) const |
Part after pos+len. More... | |
EST_String | after (const char *s, int pos=0) const |
Part after substring. More... | |
EST_String | after (const EST_String &s, int pos=0) const |
Part after substring. More... | |
EST_String | after (EST_Regex &e, int pos=0) const |
Part after match of regular expression. More... | |
Search for something | |
size_t | search (const char *s, size_t len, size_t &mlen, ssize_t pos=0) const |
Find a substring. More... | |
size_t | search (const EST_String s, size_t &mlen, ssize_t pos=0) const |
Find a substring. More... | |
size_t | search (EST_Regex &re, size_t &mlen, ssize_t pos=0, size_t *starts=NULL, size_t *ends=NULL) const |
Find a match of the regular expression. More... | |
Get position of something | |
size_t | index (const char *s, ssize_t pos=0) const |
Position of substring (starting at pos) More... | |
size_t | index (const EST_String &s, ssize_t pos=0) const |
Position of substring (starting at pos) More... | |
size_t | index (EST_Regex &ex, ssize_t pos=0) const |
Position of match of regexp (starting at pos) More... | |
Does string contain something? | |
int | contains (const char *s, ssize_t pos=-1) const |
Does it contain this substring? More... | |
int | contains (const EST_String &s, ssize_t pos=-1) const |
Does it contain this substring? More... | |
int | contains (const char c, ssize_t pos=-1) const |
Does it contain this character? More... | |
int | contains (EST_Regex &ex, ssize_t pos=-1) const |
Does it contain a match for this regular expression? More... | |
Does string exactly match? | |
int | matches (const char *e, ssize_t pos=0) const |
Exactly match this string? More... | |
int | matches (const EST_String &e, ssize_t pos=0) const |
Exactly match this string? More... | |
int | matches (EST_Regex &e, ssize_t pos=0, size_t *starts=NULL, size_t *ends=NULL) const |
Exactly matches this regular expression, can return ends of sub-expressions. More... | |
Global replacement | |
int | gsub (const char *os, const EST_String &s) |
Substitute one string for another. More... | |
int | gsub (const char *os, const char *s) |
Substitute one string for another. More... | |
int | gsub (const EST_String &os, const EST_String &s) |
Substitute one string for another. More... | |
int | gsub (const EST_String &os, const char *s) |
Substitute one string for another. More... | |
int | gsub (EST_Regex &ex, const EST_String &s) |
Substitute string for matches of regular expression. More... | |
int | gsub (EST_Regex &ex, const char *s) |
Substitute string for matches of regular expression. More... | |
int | gsub (EST_Regex &ex, int bracket_num) |
Substitute string for matches of regular expression. More... | |
int | subst (EST_String source, size_t(&starts)[EST_Regex_max_subexpressions], size_t(&ends)[EST_Regex_max_subexpressions]) |
Substitute the result of a match into a string. More... | |
Frequency counts | |
size_t | freq (const char *s) const |
Number of occurrences of substring. More... | |
size_t | freq (const EST_String &s) const |
Number of occurrences of substring. More... | |
size_t | freq (EST_Regex &s) const |
Number of matches of regular expression. More... | |
Quoting | |
EST_String | quote (const char quotec) const |
Return the string in quotes with internal quotes protected. More... | |
EST_String | quote_if_needed (const char quotec) const |
Return in quotes if there is something to protect (e.g. spaces) More... | |
EST_String | unquote (const char quotec) const |
Remove quotes and unprotect internal quotes. More... | |
EST_String | unquote_if_needed (const char quotec) const |
Remove quotes if any. More... | |
Operators | |
char | operator() (int i) const |
Function style access to constant strings. More... | |
char & | operator[] (int i) |
Array style access to writable strings. More... | |
operator const char * () const | |
Cast to const char * by simply giving access to pointer. More... | |
operator const char * () | |
operator char * () | |
Cast to char *, may involve copying. More... | |
Add to end of string. | |
EST_String & | operator+= (const char *b) |
Add C string to end of EST_String. More... | |
EST_String & | operator+= (const EST_String b) |
Add EST_String to end of EST_String. More... | |
Assignment | |
EST_String & | operator= (const char *str) |
Assign C string to EST_String. More... | |
EST_String & | operator= (const char c) |
Assign single character to EST_String. More... | |
EST_String & | operator= (const EST_String &s) |
Assign EST_String to EST_String. More... | |
Static Public Member Functions | |
static EST_String | FromChar (const char c) |
Build string from a single character. More... | |
static EST_String | Number (int i, int base=10) |
Build string from an integer. More... | |
static EST_String | Number (long i, int base=10) |
Build string from a long integer. More... | |
static EST_String | Number (double d) |
Build string from a double. More... | |
static EST_String | Number (float f) |
Build string from a float. More... | |
static EST_String | cat (const EST_String s1, const EST_String s2=Empty, const EST_String s3=Empty, const EST_String s4=Empty, const EST_String s5=Empty, const EST_String s6=Empty, const EST_String s7=Empty, const EST_String s8=Empty, const EST_String s9=Empty) |
Static Public Attributes | |
static const char * | version = "CSTR String Class " STRING_VERSION " " STRING_DATE |
Global version string. More... | |
static const EST_String | Empty |
Constant empty string. More... | |
Friends | |
class | EST_Regex |
EST_String | operator* (const EST_String &s, int n) |
Repeat string N times. More... | |
EST_String | upcase (const EST_String &s) |
Convert to upper case. More... | |
EST_String | downcase (const EST_String &s) |
Convert to lower case. More... | |
ostream & | operator<< (ostream &s, const EST_String &str) |
Stream output for EST_String. More... | |
Concatenation | |
EST_String | operator+ (const EST_String &a, const EST_String &b) |
Concatenate two EST_Strings. More... | |
EST_String | operator+ (const char *a, const EST_String &b) |
Concatenate C String with EST_String. More... | |
EST_String | operator+ (const EST_String &a, const char *b) |
Concatenate EST_String with C String. More... | |
relational operators | |
int | operator== (const char *a, const EST_String &b) |
int | operator== (const EST_String &a, const char *b) |
int | operator== (const EST_String &a, const EST_String &b) |
int | operator!= (const char *a, const EST_String &b) |
int | operator!= (const EST_String &a, const char *b) |
int | operator!= (const EST_String &a, const EST_String &b) |
int | operator< (const char *a, const EST_String &b) |
int | operator< (const EST_String &a, const char *b) |
int | operator< (const EST_String &a, const EST_String &b) |
int | operator> (const char *a, const EST_String &b) |
int | operator> (const EST_String &a, const char *b) |
int | operator> (const EST_String &a, const EST_String &b) |
int | operator<= (const char *a, const EST_String &b) |
int | operator<= (const EST_String &a, const char *b) |
int | operator<= (const EST_String &a, const EST_String &b) |
int | operator>= (const char *a, const EST_String &b) |
int | operator>= (const EST_String &a, const char *b) |
int | operator>= (const EST_String &a, const EST_String &b) |
String comparison. | |
All these operators return -1, 0 or 1 to indicate the sort order of the strings. | |
int | compare (const EST_String &a, const EST_String &b) |
int | compare (const EST_String &a, const char *b) |
int | compare (const char *a, const EST_String &b) |
int | fcompare (const EST_String &a, const EST_String &b, const unsigned char *table) |
int | fcompare (const EST_String &a, const char *b, const unsigned char *table) |
int | fcompare (const EST_String &a, const EST_String &b, const EST_String &table) |
Split a string into parts. | |
These functions divide up a string producing an array of substrings. | |
int | split (const EST_String &s, EST_String result[], int max, const EST_String &seperator, char quote=0) |
Split at a given separator. More... | |
int | split (const EST_String &s, EST_String result[], int max, const char *seperator, char quote=0) |
Split at a given separator. More... | |
int | split (const EST_String &s, EST_String result[], int max, EST_Regex &seperator, char quote=0) |
Split at each match of the regular expression. More... | |
A non-copyleft implementation of a string class to use with compilers that aren't GNU C++.
Strings are reference-counted and reasonably efficient (eg you can pass them around, into and out of functions and so on without worrying too much about the cost).
The associated class EST_Regex can be used to represent regular expressions.
Definition at line 76 of file EST_String.h.
typedef size_t EST_String::EST_string_size |
Type of string size field.
Definition at line 113 of file EST_String.h.
|
inline |
Construct an empty string.
Definition at line 201 of file EST_String.h.
EST_String::EST_String | ( | const char * | s | ) |
Construct from char *.
Definition at line 818 of file EST_String.cc.
Construct from part of char * or fill with given character.
Definition at line 831 of file EST_String.cc.
EST_String::EST_String | ( | const char * | s, |
size_t | s_size, | ||
size_t | start, | ||
ssize_t | len | ||
) |
Construct from C string.
Definition at line 864 of file EST_String.cc.
EST_String::EST_String | ( | const EST_String & | s, |
size_t | start, | ||
ssize_t | len | ||
) |
Definition at line 878 of file EST_String.cc.
|
inline |
Copy constructor We have to declare our own copy constructor to lie to the compiler about the constness of the RHS.
Definition at line 219 of file EST_String.h.
|
inline |
Destructor.
Definition at line 225 of file EST_String.h.
|
inline |
Length of string ({not} length of underlying chunk)
Definition at line 231 of file EST_String.h.
|
inline |
Size of underlying chunk.
Definition at line 233 of file EST_String.h.
|
inline |
Get a const-pointer to the actual memory.
Definition at line 235 of file EST_String.h.
|
inline |
Get a writable pointer to the actual memory.
Definition at line 237 of file EST_String.h.
|
inline |
Definition at line 238 of file EST_String.h.
|
inlinestatic |
Build string from a single character.
Definition at line 242 of file EST_String.h.
|
static |
Build string from an integer.
Definition at line 1199 of file EST_String.cc.
|
static |
Build string from a long integer.
Definition at line 1224 of file EST_String.cc.
|
static |
Build string from a double.
Definition at line 1258 of file EST_String.cc.
|
static |
Build string from a float.
Definition at line 1249 of file EST_String.cc.
Convert to an integer.
Definition at line 258 of file EST_String.h.
|
inline |
Definition at line 259 of file EST_String.h.
|
inline |
Convert to a long.
Definition at line 262 of file EST_String.h.
|
inline |
Definition at line 263 of file EST_String.h.
|
inline |
Convert to a float.
Definition at line 266 of file EST_String.h.
|
inline |
Definition at line 267 of file EST_String.h.
|
inline |
Convert to a double.
Definition at line 270 of file EST_String.h.
|
inline |
Definition at line 271 of file EST_String.h.
|
inline |
Part before position.
Definition at line 276 of file EST_String.h.
|
inline |
Part before first matching substring after pos.
Definition at line 279 of file EST_String.h.
|
inline |
Part before first matching substring after pos.
Definition at line 282 of file EST_String.h.
|
inline |
Part before first match of regexp after pos.
Definition at line 285 of file EST_String.h.
|
inline |
Return part at position.
Definition at line 292 of file EST_String.h.
|
inline |
Return part where substring found (not useful, included for completeness)
Definition at line 295 of file EST_String.h.
|
inline |
Return part where substring found (not useful, included for completeness)
Definition at line 298 of file EST_String.h.
|
inline |
Return part matching regexp.
Definition at line 301 of file EST_String.h.
|
inline |
Part after pos+len.
Definition at line 308 of file EST_String.h.
|
inline |
Part after substring.
Definition at line 311 of file EST_String.h.
|
inline |
Part after substring.
Definition at line 314 of file EST_String.h.
|
inline |
Part after match of regular expression.
Definition at line 317 of file EST_String.h.
|
inline |
Find a substring.
Definition at line 324 of file EST_String.h.
|
inline |
Find a substring.
Definition at line 332 of file EST_String.h.
|
inline |
Find a match of the regular expression.
Definition at line 340 of file EST_String.h.
|
inline |
Position of substring (starting at pos)
Definition at line 352 of file EST_String.h.
|
inline |
Position of substring (starting at pos)
Definition at line 355 of file EST_String.h.
Position of match of regexp (starting at pos)
Definition at line 358 of file EST_String.h.
Does it contain this substring?
Definition at line 365 of file EST_String.h.
|
inline |
Does it contain this substring?
Definition at line 368 of file EST_String.h.
Does it contain this character?
Definition at line 371 of file EST_String.h.
Does it contain a match for this regular expression?
Definition at line 374 of file EST_String.h.
Exactly match this string?
Definition at line 651 of file EST_String.cc.
int EST_String::matches | ( | const EST_String & | e, |
ssize_t | pos = 0 |
||
) | const |
Exactly match this string?
Definition at line 668 of file EST_String.cc.
int EST_String::matches | ( | EST_Regex & | e, |
ssize_t | pos = 0 , |
||
size_t * | starts = NULL , |
||
size_t * | ends = NULL |
||
) | const |
Exactly matches this regular expression, can return ends of sub-expressions.
Definition at line 678 of file EST_String.cc.
|
inline |
Substitute one string for another.
Definition at line 391 of file EST_String.h.
|
inline |
Substitute one string for another.
Definition at line 394 of file EST_String.h.
|
inline |
Substitute one string for another.
Definition at line 397 of file EST_String.h.
|
inline |
Substitute one string for another.
Definition at line 400 of file EST_String.h.
|
inline |
Substitute string for matches of regular expression.
Definition at line 404 of file EST_String.h.
Substitute string for matches of regular expression.
Definition at line 407 of file EST_String.h.
Substitute string for matches of regular expression.
Definition at line 410 of file EST_String.h.
int EST_String::subst | ( | EST_String | source, |
size_t(&) | starts[EST_Regex_max_subexpressions], | ||
size_t(&) | ends[EST_Regex_max_subexpressions] | ||
) |
Substitute the result of a match into a string.
Definition at line 465 of file EST_String.cc.
size_t EST_String::freq | ( | const char * | s | ) | const |
Number of occurrences of substring.
Definition at line 985 of file EST_String.cc.
size_t EST_String::freq | ( | const EST_String & | s | ) | const |
Number of occurrences of substring.
Definition at line 970 of file EST_String.cc.
size_t EST_String::freq | ( | EST_Regex & | s | ) | const |
Number of matches of regular expression.
Definition at line 1003 of file EST_String.cc.
EST_String EST_String::quote | ( | const char | quotec | ) | const |
Return the string in quotes with internal quotes protected.
Definition at line 1017 of file EST_String.cc.
EST_String EST_String::quote_if_needed | ( | const char | quotec | ) | const |
Return in quotes if there is something to protect (e.g. spaces)
Definition at line 1056 of file EST_String.cc.
EST_String EST_String::unquote | ( | const char | quotec | ) | const |
Remove quotes and unprotect internal quotes.
Definition at line 1029 of file EST_String.cc.
EST_String EST_String::unquote_if_needed | ( | const char | quotec | ) | const |
Remove quotes if any.
Definition at line 1066 of file EST_String.cc.
|
inline |
Function style access to constant strings.
Definition at line 444 of file EST_String.h.
|
inline |
Array style access to writable strings.
Definition at line 446 of file EST_String.h.
|
inline |
Cast to const char * by simply giving access to pointer.
Definition at line 449 of file EST_String.h.
|
inline |
Definition at line 450 of file EST_String.h.
|
inline |
Cast to char *, may involve copying.
Definition at line 452 of file EST_String.h.
EST_String & EST_String::operator+= | ( | const char * | b | ) |
Add C string to end of EST_String.
Definition at line 772 of file EST_String.cc.
EST_String & EST_String::operator+= | ( | const EST_String | b | ) |
Add EST_String to end of EST_String.
Definition at line 795 of file EST_String.cc.
EST_String & EST_String::operator= | ( | const char * | str | ) |
Assign C string to EST_String.
Definition at line 909 of file EST_String.cc.
EST_String & EST_String::operator= | ( | const char | c | ) |
Assign single character to EST_String.
Definition at line 923 of file EST_String.cc.
EST_String & EST_String::operator= | ( | const EST_String & | s | ) |
Assign EST_String to EST_String.
Definition at line 930 of file EST_String.cc.
|
static |
Concatenate a number of strings. This is more efficient than multiple uses of + or +=
Definition at line 1084 of file EST_String.cc.
|
inline |
Definition at line 620 of file EST_String.h.
|
friend |
Definition at line 624 of file EST_String.h.
|
friend |
Concatenate two EST_Strings.
Definition at line 708 of file EST_String.cc.
|
friend |
Concatenate C String with EST_String.
Definition at line 726 of file EST_String.cc.
|
friend |
Concatenate EST_String with C String.
Definition at line 687 of file EST_String.cc.
|
friend |
Repeat string N times.
Definition at line 747 of file EST_String.cc.
|
friend |
Definition at line 1177 of file EST_String.cc.
|
friend |
Definition at line 492 of file EST_String.h.
|
friend |
Definition at line 1189 of file EST_String.cc.
|
friend |
Definition at line 498 of file EST_String.h.
|
friend |
Definition at line 501 of file EST_String.h.
|
friend |
Definition at line 504 of file EST_String.h.
|
friend |
Definition at line 508 of file EST_String.h.
|
friend |
Definition at line 511 of file EST_String.h.
|
friend |
Definition at line 514 of file EST_String.h.
|
friend |
Definition at line 517 of file EST_String.h.
|
friend |
Definition at line 520 of file EST_String.h.
|
friend |
Definition at line 523 of file EST_String.h.
|
friend |
Definition at line 526 of file EST_String.h.
|
friend |
Definition at line 529 of file EST_String.h.
|
friend |
Definition at line 532 of file EST_String.h.
|
friend |
Definition at line 535 of file EST_String.h.
|
friend |
Definition at line 538 of file EST_String.h.
|
friend |
Definition at line 541 of file EST_String.h.
|
friend |
Definition at line 1126 of file EST_String.cc.
|
friend |
Definition at line 1138 of file EST_String.cc.
|
friend |
Definition at line 557 of file EST_String.h.
|
friend |
Case folded comparison.
The table argument can defined how upper and lower case characters correspond. The default works for ASCII.
Definition at line 1150 of file EST_String.cc.
|
friend |
Definition at line 1163 of file EST_String.cc.
|
friend |
Definition at line 572 of file EST_String.h.
|
friend |
Split at a given separator.
Definition at line 587 of file EST_String.h.
|
friend |
Split at a given separator.
Definition at line 591 of file EST_String.h.
|
friend |
Split at each match of the regular expression.
Definition at line 595 of file EST_String.h.
|
friend |
Convert to upper case.
Definition at line 955 of file EST_String.cc.
|
friend |
Convert to lower case.
Definition at line 942 of file EST_String.cc.
|
friend |
Stream output for EST_String.
Definition at line 1075 of file EST_String.cc.
|
static |
Global version string.
Definition at line 107 of file EST_String.h.
|
static |
Constant empty string.
Definition at line 110 of file EST_String.h.