#include <nstring.h>
Public Member Functions | |
~nstring () | |
nstring () | |
nstring (const char *arg) | |
nstring (const char *data, size_t len) | |
nstring (string_ty *arg) | |
nstring (const nstring &arg) | |
nstring & | operator= (const nstring &arg) |
const char * | c_str () const |
bool | empty () const |
size_t | size () const |
size_t | length () const |
nstring | catenate (const nstring &arg) const |
join two strings together | |
nstring | operator+ (const nstring &arg) const |
nstring & | operator+= (const nstring &arg) |
nstring | cat_three (const nstring &str2, const nstring &str3) const |
joing strings together | |
operator bool () const | |
test a boolean | |
bool | operator! () const |
nstring | upcase () const |
convert to upper case | |
nstring | downcase () const |
convert to lower case | |
nstring | capitalize () const |
convert to title case | |
nstring | field (char sep, int nth) const |
extract a field | |
bool | equal (const nstring &arg) const |
test string equality | |
bool | operator== (const nstring &arg) const |
bool | operator!= (const nstring &arg) const |
bool | operator< (const nstring &arg) const |
bool | operator<= (const nstring &arg) const |
bool | operator> (const nstring &arg) const |
bool | operator>= (const nstring &arg) const |
nstring | quote_c () const |
quote C meta-characters | |
nstring | quote_shell () const |
quote shell meta-characters | |
nstring | trim () const |
remove excess white space | |
nstring | trim_lines () const |
remove excess white space | |
nstring | trim_extension () const |
nstring | get_extension () const |
nstring | snip () const |
remove excess white space | |
bool | valid () const |
check is valid | |
string_ty * | get_ref () const |
bool | starts_with (const nstring &prefix) const |
bool | ends_with (const nstring &suffix) const |
bool | ends_with_nocase (const nstring &suffix) const |
bool | gmatch (const char *pattern) const |
bool | gmatch (const nstring &pattern) const |
bool | gmatch (const nstring_list &pattern) const |
nstring | identifier () const |
nstring | replace (const nstring &lhs, const nstring &rhs, int maximum=-1) const |
char | operator[] (size_t n) const |
void | clear () |
nstring | url_quote () const |
nstring | url_unquote () const |
nstring | html_quote (bool para=false) const |
nstring | html_unquote () const |
long | to_long () const |
nstring | substring (long start, long nbytes) const |
nstring | dirname () const |
nstring | first_dirname () const |
nstring | basename (const nstring &suffix="") const |
str_hash_ty | get_hash () const |
Static Public Member Functions | |
static nstring | format (const char *fmt,...) |
format text | |
static nstring | vformat (const char *fmt, va_list ap) |
format text | |
Static Private Member Functions | |
static string_ty * | get_empty_ref () |
Private Attributes | |
string_ty * | ref |
This is a narrow string class, using ordinary char as the internal character type. For wide strings, which use wchar_t as the internal character type, see the wstring class.
Definition at line 35 of file nstring.h.
nstring::~nstring | ( | ) | [inline] |
nstring::nstring | ( | const char * | arg | ) | [inline] |
nstring::nstring | ( | const char * | data, | |
size_t | len | |||
) | [inline] |
nstring::nstring | ( | string_ty * | arg | ) | [inline, explicit] |
nstring::nstring | ( | const nstring & | arg | ) | [inline] |
const char* nstring::c_str | ( | ) | const [inline] |
join two strings together
The str_catenate function is used to join two strings togther to form a new string. The are joined in the order given.
arg | A string to be joined. Will not be modified. |
joing strings together
The str_cat_three function is used to join three strings together to form a new string. The are joined in the order given.
str2 | A string to be joined. Will not be modified. | |
str3 | A string to be joined. Will not be modified. |
nstring::operator bool | ( | ) | const |
test a boolean
The str_bool function is used to test the value of a string, as if it contained a number. If it doesn't contain a number, it is as if the strings was "1".
bool nstring::operator! | ( | ) | const |
The logical netation operator. Returns the negation of the bool() operator.
nstring nstring::upcase | ( | ) | const |
convert to upper case
The str_upcase function is used to create a new string where the lower case characters in the input string are converted to upper case.
nstring nstring::downcase | ( | ) | const |
convert to lower case
The str_downcase function is used to create a new string where the upper case characters in the input string are converted to lower case.
nstring nstring::capitalize | ( | ) | const |
convert to title case
The str_capitalize function is used to create a new string where the first letter or each word of the inopuyt string are upper case, and the remaining letters in each word are lower case. (Sometimes called Title Case.)
nstring nstring::field | ( | char | sep, | |
int | nth | |||
) | const |
extract a field
The str_field function is used to extract the nth field, where each field is separated by the sep string.
sep | The string which separates each field. | |
nth | The number of the field to be extracted. Zero based. If too high, the emtry string is returned. |
static nstring nstring::format | ( | const char * | fmt, | |
... | ||||
) | [static] |
format text
The str_format function is used to create a new string by interpreting the fmt string. All formats understood by the ANSI C printf(3) are understood by this function (but probably not your favorite proprietary extension). In addition the 'S' specifier expects a string_ty * argument.
fmt | The format string to be interpreted when constructing the return value. |
static nstring nstring::vformat | ( | const char * | fmt, | |
va_list | ap | |||
) | [static] |
format text
The str_vformat function is used to create a new string by interpreting the fmt string. All formats understood by the ANSI C printf(3) are understood by this function (but probably not your favorite proprietary extension). In addition the 'S' specifier expects a string_ty * argument.
fmt | The format string to be interpreted when constructing the return value. | |
ap | Where to obtain additional arguments required by the fmt string. |
bool nstring::equal | ( | const nstring & | arg | ) | const [inline] |
test string equality
The str_equal function is used to test to see if two strings are exactly the same.
arg | A string to be compared. Will not be modified. |
bool nstring::operator== | ( | const nstring & | arg | ) | const [inline] |
bool nstring::operator!= | ( | const nstring & | arg | ) | const [inline] |
bool nstring::operator< | ( | const nstring & | arg | ) | const |
The less-than operator.
rhs | The right hans side of the comparison. |
bool nstring::operator<= | ( | const nstring & | arg | ) | const |
The less-than-or-equal operator.
rhs | The right hans side of the comparison. |
bool nstring::operator> | ( | const nstring & | arg | ) | const |
The greater-than operator.
rhs | The right hans side of the comparison. |
bool nstring::operator>= | ( | const nstring & | arg | ) | const |
The greater-than-or-equal operator.
rhs | The right hans side of the comparison. |
nstring nstring::quote_c | ( | ) | const |
quote C meta-characters
The quote_c method is used to create a new string which quotes the C meta-characters in the input string.
nstring nstring::quote_shell | ( | ) | const |
quote shell meta-characters
The str_quote_shell function is used to create a new string which quotes the shell meta-characters in the input string.
nstring nstring::trim | ( | ) | const |
remove excess white space
The trim method is used to remove white space from the beginning and end of the string, and replace all other runs of one or more white space characters with a single space.
nstring nstring::trim_lines | ( | ) | const |
remove excess white space
The trim_lines method is used to remove white space from the beginning and end of lines within the string, and replace all other runs of one or more white space characters with a single space.
nstring nstring::trim_extension | ( | ) | const |
The trim_extension method is used to build a new string without the file extension. For example, the string "a/b.c" will return "a/b".
nstring nstring::get_extension | ( | ) | const |
The get_extension method is used to build a new string containing the file extension, if any, without the dot. For example, the string "a/b.c" will return "c".
nstring nstring::snip | ( | ) | const |
remove excess white space
The snip method is used to remove white space from the beginning and end of the string. Interior white space is left unchanged.
bool nstring::valid | ( | ) | const [inline] |
string_ty* nstring::get_ref | ( | ) | const [inline] |
The get_ref method is used to extract the reference to the underlying reference counted string object. If the ref pointer is NULL a pointer to a common empty string object is returned.
Once the sources cease using string_ty directly, this method will become private.
bool nstring::starts_with | ( | const nstring & | prefix | ) | const |
The starts_with method is ised to test whether this string starts with the given prefix.
prefix | The string to test for. |
bool nstring::ends_with | ( | const nstring & | suffix | ) | const |
The ends_with method is ised to test whether this string ends with the given suffix.
suffix | The string to test for. |
bool nstring::ends_with_nocase | ( | const nstring & | suffix | ) | const |
The ends_with_nocase method is ised to test whether this string ends with the given suffix. The comparison will be case insensitive.
suffix | The string to test for. |
bool nstring::gmatch | ( | const char * | pattern | ) | const |
The gmatch function is used to match the string against a file globbing pattern.
The pattern to try against the string.
bool nstring::gmatch | ( | const nstring & | pattern | ) | const |
The gmatch function is used to match the string against a file globbing pattern.
The pattern to try against the string.
bool nstring::gmatch | ( | const nstring_list & | pattern | ) | const |
The gmatch function is used to match the string against a set of file globbing patterns.
The patterns to try against the string.
nstring nstring::identifier | ( | ) | const |
The identifier method is used to convert all non-C-identifier characters in the string to underscores. The intention is to create a valid C identifier from the string.
The replace method may be used to alter a string by replacing one constant substring with another.
lhs | The substring to look for. | |
rhs | The substring to replace lhs if found. | |
maximum | The maximum number of times to perform the replacement. Defaults to "infinity". |
char nstring::operator[] | ( | size_t | n | ) | const [inline] |
The indexing operator is used to extract the nth character of a string. Indexes out of range will result in the NUL character ('') being returned.
n | The character to extract. Zero based. |
void nstring::clear | ( | ) |
The clear method is used to delete to contents of the string, and replace it with the empty string/
nstring nstring::url_quote | ( | ) | const |
The url_quote mwthod is used to form a string suitable for use within an HTML href="" string, or similar. This means that special characters and unprintable characters are replaced with NN escape sequences.
nstring nstring::url_unquote | ( | ) | const |
The url_unquote method is used to form a normal string given an HTML href="" string, or similar. This means that NN escape sequences are replaced with single bytes.
nstring nstring::html_quote | ( | bool | para = false |
) | const |
The html_quote method is used to form a string suitable for use withing an HTML paragraph. This means that special characters and unprintable characters are replaced with &DDD; escape sequences. Some special characters are also replaced, e.g. <
para | Whether or not to translate and as |
nstring nstring::html_unquote | ( | ) | const |
The html_unquote method is used to form a normal string given text from an HTML paragraph. This means that &DDD; escape sequences are replaced by single bytes. Some special characters are also replaced, e.g. <
long nstring::to_long | ( | ) | const |
The to_long method attempts to turn a string into a long value. It returns zero on failure.
nstring nstring::substring | ( | long | start, | |
long | nbytes | |||
) | const |
The substring method may be used to extract a substring from this string.
start | The offset into the string where the substring starts. If negative, is measured from the end. | |
nbytes | The number of bytes to extract, if that many available. If negative, measured to the left (text not reversed). |
nstring nstring::dirname | ( | ) | const |
The dirname method is used to extract the directory part of a filename. If there is no directory part, "." is returned.
nstring nstring::first_dirname | ( | ) | const |
The first_dirname method is used to extract the first directory part of a filename. If there is no directory part, "." is returned.
The basename method is used to generate a new string from this one with any leading directory components removed. If specified, also remove a trailing suffix.
str_hash_ty nstring::get_hash | ( | ) | const [inline] |
static string_ty* nstring::get_empty_ref | ( | ) | [static, private] |
The get_empty_ref() class method is used to get a pointer to an underlying string object of length zero.
string_ty* nstring::ref [private] |