Elm
1.0
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
|
#include <elm/string/String.h>
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 * | operator& (void) 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 |
An immutable implementation of the string data type. Refer to StringBuffer for long concatenation string building.
elm::String::String | ( | void | ) |
Build an empty string.
Referenced by substring().
elm::String::String | ( | const char * | str, |
int | _len | ||
) |
Build a string from a character array.
str | Character array base. |
_len | Character array length. |
elm::String::String | ( | const char * | str | ) |
Build an ELM string from a C string.
str | C string. |
elm::String::String | ( | cstring | str | ) |
Build a string from a CString.
str | CString object to use. |
References elm::CString::chars(), and elm::CString::length().
elm::String::~String | ( | void | ) |
char elm::String::charAt | ( | int | index | ) | const |
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 ltrim(), operator[](), and rtrim().
const char * elm::String::chars | ( | void | ) | const |
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 compare(), elm::CString::concat(), concat(), elm::CString::endsWith(), endsWith(), elm::HashKey< String >::hash(), indexOf(), lastIndexOf(), elm::io::Output::print(), elm::sys::ProcessBuilder::run(), elm::CString::startsWith(), startsWith(), toCString(), and elm::option::ValueOption< T >::ValueOption().
int elm::String::compare | ( | const String & | str | ) | const |
Compare two strings with ASCII order.
str | String to compare with. |
References chars().
Referenced by elm::operator!=(), elm::operator<(), elm::operator<=(), elm::operator==(), elm::operator>(), and elm::operator>=().
int elm::String::compare | ( | const CString | str | ) | const |
Compare this string with a CString object using ASCII order.
str | String to compare with. |
References elm::CString::chars(), chars(), and elm::CString::length().
Concatenate a string with a C string.
str | C string to concatenate after. |
References elm::CString::chars(), chars(), concat(), and elm::CString::length().
Referenced by concat().
bool elm::String::endsWith | ( | const char * | str | ) | const |
Test if the string ends with the given C string.
str | C string to compare. |
References CString.
bool elm::String::endsWith | ( | const CString | str | ) | const |
Test if the string ends with the given string.
str | String to compare. |
References elm::CString::chars(), chars(), and elm::CString::length().
bool elm::String::endsWith | ( | const String & | str | ) | const |
int elm::String::indexOf | ( | char | chr | ) | const |
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 indexOf().
Referenced by elm::ini::Section::getList(), indexOf(), elm::ini::File::load(), elm::Version::operator=(), elm::option::Manager::parse(), and elm::sys::Plugger::Plugger().
int elm::String::indexOf | ( | char | chr, |
int | pos | ||
) | const |
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 chars().
int elm::String::indexOf | ( | const String & | string, |
int | pos = 0 |
||
) |
Find the first occurence of a substring.
string | String to look for. |
pos | Start position. |
References indexOf(), length(), and substring().
bool elm::String::isEmpty | ( | void | ) | const |
Test if string is empty.
Referenced by operator bool().
int elm::String::lastIndexOf | ( | char | chr | ) | const |
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 lastIndexOf(), and length().
Referenced by elm::sys::Path::basePart(), elm::sys::Path::extension(), lastIndexOf(), and elm::sys::Path::setExtension().
int elm::String::lastIndexOf | ( | char | chr, |
int | pos | ||
) | const |
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 chars().
int elm::String::lastIndexOf | ( | const String & | str | ) |
References lastIndexOf(), and length().
Referenced by lastIndexOf().
int elm::String::lastIndexOf | ( | const String & | string, |
int | pos | ||
) |
Find the last occurence of a substring.
string | String to look for. |
pos | Position to start to look before. |
References lastIndexOf(), length(), and substring().
int elm::String::length | ( | void | ) | const |
Get the length of the string.
Referenced by elm::CString::concat(), concat(), elm::log::Debug::debugPrefix(), elm::sys::Path::PathIter::ended(), elm::CString::endsWith(), elm::HashKey< String >::hash(), indexOf(), elm::sys::Path::isAbsolute(), elm::sys::Path::isHomeRelative(), elm::sys::Plugger::Iterator::item(), lastIndexOf(), elm::ini::File::load(), ltrim(), elm::option::Option::Option(), elm::option::Manager::parse(), elm::io::Output::print(), elm::checksum::MD5::put(), rtrim(), elm::CString::startsWith(), startsWith(), and elm::io::Input::swallow().
string elm::String::ltrim | ( | void | ) | const |
Remove blanks at left of the current string.
References charAt(), length(), and substring().
Referenced by trim().
const char * elm::String::operator& | ( | void | ) | const |
Assign a CString object to the current string.
str | CString object to assign. |
References elm::CString::chars(), and elm::CString::length().
String & elm::String::operator= | ( | const char * | str | ) |
Assign a C string to the current string.
str | C string to assign. |
string elm::String::rtrim | ( | void | ) | const |
Remove blanks at right of the current string.
References charAt(), length(), and substring().
Referenced by trim().
bool elm::String::startsWith | ( | const char * | str | ) | const |
Test if the string starts with the given C string.
str | C string to compare. |
References CString.
Referenced by elm::sys::Path::contains(), elm::sys::evaluate(), and elm::sys::Plugger::plug().
bool elm::String::startsWith | ( | const CString | str | ) | const |
Test if the string starts with the given C string.
str | C string to compare. |
References elm::CString::chars(), chars(), and elm::CString::length().
bool elm::String::startsWith | ( | const String & | str | ) | const |
String elm::String::substring | ( | int | _off | ) | const |
References String().
Referenced by elm::sys::Path::absolute(), elm::sys::Path::basePart(), elm::log::Debug::debugPrefix(), elm::sys::Path::dirPart(), elm::sys::evaluate(), elm::sys::Path::extension(), elm::ini::Section::getList(), indexOf(), elm::sys::Plugger::Iterator::item(), elm::sys::Path::PathIter::item(), lastIndexOf(), elm::ini::File::load(), ltrim(), elm::sys::Path::namePart(), elm::Version::operator=(), elm::sys::Path::parent(), elm::option::Manager::parse(), elm::sys::Plugger::Plugger(), and rtrim().
CString elm::String::toCString | ( | void | ) | const |
Convert the current string to a CString object.
References chars().
Referenced by elm::io::WinInStream::lastErrorMessage(), elm::serial2::XOMSerializer::onValue(), operator&(), and elm::xom::Serializer::writeXMLDeclaration().
string elm::String::trim | ( | void | ) | const |