Elm
2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
|
#include <elm/string/String.h>
Classes | |
class | Iter |
Public Member Functions | |
String (void) | |
String (const char *str, int _len) | |
String (const char *str) | |
String (cstring str) | |
String (const String &str) | |
~String (void) | |
String & | operator= (const String &str) |
String & | operator= (const CString str) |
String & | operator= (const char *str) |
int | length (void) const |
const char * | chars (void) const |
int | compare (const String &str) const |
int | compare (const CString str) const |
bool | isEmpty (void) const |
operator bool (void) const | |
CString | toCString (void) const |
const char * | asNullTerminated () const |
const char * | asSysString () const |
char | charAt (int index) const |
char | operator[] (int index) const |
String | substring (int _off) const |
String | substring (int _off, int _len) const |
String | concat (const CString str) const |
String | concat (const String &str) const |
int | indexOf (char chr) const |
int | indexOf (char chr, int pos) const |
int | indexOf (const String &str, int pos=0) |
int | lastIndexOf (char chr) const |
int | lastIndexOf (char chr, int pos) const |
int | lastIndexOf (const String &str) |
int | lastIndexOf (const String &str, int pos) |
bool | startsWith (const char *str) const |
bool | startsWith (const CString str) const |
bool | startsWith (const String &str) const |
bool | endsWith (const char *str) const |
bool | endsWith (const CString str) const |
bool | endsWith (const String &str) const |
String | trim (void) const |
String | ltrim (void) const |
String | rtrim (void) const |
String | replace (String pat, String sub) |
Iter | begin () const |
Iter | end () const |
template<class C > | |
String | join (const C &coll) |
Static Public Member Functions | |
static String | make (char chr) |
static String | make (String chr, int n) |
An immutable implementation of the string data type. Refer to StringBuffer for long concatenation string building.
Build an empty string.
Referenced by String::make(), and String::substring().
|
inline |
Build a string from a character array.
str | Character array base. |
_len | Character array length. |
References elm::str().
|
inline |
Build a string from a CString.
str | CString object to use. |
References String::chars(), String::length(), and elm::str().
|
inline |
Convert the current string to a null-terminated character array (C standard). The ownership of the character array is retained by the string. Modifying this array modifies also the original string.
References CString::chars(), and String::toCString().
Referenced by String::asSysString().
|
inline |
Convert the current string to a null-terminated character array usable with the current OS calls. The ownership of the character array is retained by the string. Modifying this array modifies also the original string.
References String::asNullTerminated().
Referenced by Element::parse().
|
inline |
|
inline |
Get a character at some position in the string.
index | Index of the character to get (It is an error to give a negative index or an index greater or equal to the string length). |
Referenced by String::ltrim(), String::operator[](), and String::rtrim().
|
inline |
Get access to internal representation of the string. Use it with caution and recall that the got buffer may be shared by many different strings.
Referenced by String::compare(), CString::concat(), String::concat(), CString::endsWith(), String::endsWith(), HashKey< String >::hash(), String::indexOf(), String::lastIndexOf(), String::operator=(), Output::print(), MD5::put(), ProcessBuilder::run(), CString::startsWith(), String::startsWith(), String::String(), and String::toCString().
|
inline |
Compare this string with a CString object using ASCII order.
str | String to compare with. |
References String::chars(), String::length(), and elm::str().
|
inline |
Compare two strings with ASCII order.
str | String to compare with. |
References String::chars(), and elm::str().
Referenced by elm::operator!=(), elm::operator<(), elm::operator<=(), elm::operator==(), elm::operator>(), and elm::operator>=().
Concatenate a string with a C string.
str | C string to concatenate after. |
References String::chars(), String::concat(), String::length(), and elm::str().
Referenced by String::concat().
Concatenate two strings.
str | String to concatenate after. |
References String::chars(), String::concat(), String::length(), and elm::str().
Referenced by String::concat().
|
inline |
References String::length().
|
inline |
Test if the string ends with the given C string.
str | C string to compare. |
References String::CString, and elm::str().
Referenced by elm::sys::isLibrary().
Test if the string ends with the given string.
str | String to compare. |
References String::chars(), String::length(), and elm::str().
Test if the string ends with the given string.
str | String to compare. |
References String::chars(), and elm::str().
|
inline |
Get the first index of a character in the string.
chr | Character to look for. |
index | Index of the character in the string or -1 if not found. |
References String::indexOf().
Referenced by Section::getList(), String::indexOf(), File::load(), Version::operator=(), Manager::parse(), String::replace(), and VarExpander::write().
|
inline |
Get the first index of a character in the string from the given position.
chr | Character to look for. |
pos | Position to start to look for (it is an error to pass a negative position or a position greater or equal to the string length). |
index | Index of the character in the string or -1 if not found. |
References String::chars(), and elm::io::p().
int indexOf | ( | const String & | string, |
int | pos = 0 |
||
) |
Find the first occurrence of a substring.
string | String to look for. |
pos | Start position. |
References String::indexOf(), String::length(), and String::substring().
Test if string is empty.
Referenced by Path::isEmpty(), and String::operator bool().
|
inline |
Join the items of the given collection into a string where each item is separated by the current string. The items must be string or writable to an Output channel.
coll | Collection of items to join (must be iterable). |
C | Type of the collection. |
References StringBuffer::toString().
|
inline |
Get the last index of a character in the string.
chr | Character to look for. |
index | Index of the character in the string or -1 if not found. |
References String::lastIndexOf(), and String::length().
Referenced by Path::basePart(), Path::extension(), String::lastIndexOf(), Path::setExtension(), and Path::withoutExt().
|
inline |
Get the last index of a character in the string from the given position.
chr | Character to look for. |
pos | Position to start to look for (it is an error to pass a negative or null position or a position greater to the string length). |
index | Index of the character in the string or -1 if not found. |
References String::chars(), and elm::io::p().
|
inline |
References String::lastIndexOf(), String::length(), and elm::str().
Referenced by String::lastIndexOf().
int lastIndexOf | ( | const String & | string, |
int | pos | ||
) |
Find the last occurrence of a substring.
string | String to look for. |
pos | Position to start to look before. |
References String::lastIndexOf(), String::length(), and String::substring().
|
inline |
Get the length of the string.
Referenced by String::Iter::atEnd(), String::compare(), CString::concat(), String::concat(), Debug::debugPrefixFunction(), Debug::debugPrefixWrapped(), Path::PathSplit::end(), String::end(), StringSplit::ended(), Path::PathIter::ended(), CString::endsWith(), String::endsWith(), VarExpander::expand(), HashKey< String >::hash(), String::indexOf(), Path::isAbsolute(), Path::isHomeRelative(), Path::isPrefixOf(), Plugger::Iter::item(), String::lastIndexOf(), File::load(), String::ltrim(), StringSplit::next(), Path::PathIter::next(), String::operator=(), Option::Option(), Manager::parse(), Output::print(), MD5::put(), String::replace(), String::rtrim(), CString::startsWith(), String::startsWith(), String::String(), Input::swallow(), and VarExpander::write().
Remove blanks at left of the current string.
References String::charAt(), String::length(), and String::substring().
Referenced by String::trim().
|
static |
Build a string with a single character.
chr | Character containing the string. |
References String::String().
Build a string by repeating n times the argument string.
str | String to repeat. |
n | Number of repetitions. |
References elm::str(), and StringBuffer::toString().
Same as isEmpty().
References String::isEmpty().
|
inline |
Assign a C string to the current string.
str | C string to assign. |
References elm::str().
Assign a CString object to the current string.
str | CString object to assign. |
References String::chars(), String::length(), and elm::str().
Assign a string to the current one.
str | String to assign. |
References elm::str().
|
inline |
Same as charAt().
References String::charAt().
Replace any instance of pat by sub in the current string.
References String::indexOf(), String::length(), elm::io::p(), String::substring(), and StringBuffer::toString().
Remove blanks at right of the current string.
References String::charAt(), String::length(), and String::substring().
Referenced by String::trim().
|
inline |
Test if the string starts with the given C string.
str | C string to compare. |
References String::CString, and elm::str().
Referenced by Path::isPrefixOf(), Plugger::plug(), and Path::subPathOf().
Test if the string starts with the given C string.
str | C string to compare. |
References String::chars(), String::length(), and elm::str().
Test if the string starts with the given string.
str | String to compare. |
References String::chars(), String::length(), and elm::str().
|
inline |
References String::String().
Referenced by Path::absolute(), Path::basePart(), Debug::debugPrefixFunction(), Debug::debugPrefixWrapped(), Path::dirPart(), Path::extension(), Section::getList(), String::indexOf(), StringSplit::item(), Plugger::Iter::item(), Path::PathIter::item(), String::lastIndexOf(), File::load(), String::ltrim(), Path::namePart(), Version::operator=(), Path::parent(), Manager::parse(), Path::relativeTo(), String::replace(), String::rtrim(), and Path::withoutExt().
|
inline |
References String::String().
Convert the current string to a CString object.
References String::chars().
Referenced by String::asNullTerminated(), Path::asSysString(), VarExpander::expand(), Attribute::getValue(), WinInStream::lastErrorMessage(), XOMElementSerializer::onValue(), Plugger::plugFile(), access_t< string >::set(), access_t< const string & >::set(), VarExpander::write(), Serializer::writeXMLDeclaration(), and XOMUnserializer::XOMUnserializer().
Remove blanks at left and right of the current string.
References String::ltrim(), and String::rtrim().