29 #include <boost/algorithm/string/replace.hpp> 53 *
this = std::string(str, n);
62 for (; (sBegin != sEnd) && *sBegin; ++sBegin)
85 *
this = std::string(str);
148 return *
this += ustr;
154 return *
this += ustr;
159 utf8::append(c, std::back_inserter(
_string));
160 }
catch (
const std::exception &se) {
173 for (; (it1 !=
end()) && (it2 != str.
end()); ++it1, ++it2) {
183 if ((it1 ==
end()) && (it2 == str.
end()))
195 for (; (it1 !=
end()) && (it2 != str.
end()); ++it1, ++it2) {
205 if ((it1 ==
end()) && (it2 == str.
end()))
271 if (index != std::string::npos) {
272 std::string::const_iterator it =
_string.begin();
273 std::advance(it, index);
290 }
while (it !=
begin());
305 while ((myIt !=
end()) && (withIt != with.
end()))
306 if (*myIt++ != *withIt++)
309 if ((myIt ==
end()) && (withIt != with.
end()))
325 while ((myIt !=
begin()) && (withIt != with.
begin()))
326 if (*myIt-- != *withIt--)
329 if (withIt == with.
begin())
330 return (*myIt == *withIt);
371 for (; itEnd !=
begin(); --itEnd) {
373 if ((c !=
'\0') && (c !=
' ')) {
379 if (itEnd ==
begin()) {
381 if ((c !=
'\0') && (c !=
' '))
387 for (; itStart != itEnd; ++itStart)
391 _string = std::string(itStart.base(), itEnd.base());
402 for (; itStart !=
end(); ++itStart)
406 _string = std::string(itStart.base(),
end().base());
417 for (; itEnd !=
begin(); --itEnd) {
419 if ((c !=
'\0') && (c !=
' ')) {
425 if (itEnd ==
begin()) {
427 if ((c !=
'\0') && (c !=
' '))
439 std::string newString;
440 newString.reserve(
_string.size());
443 std::string::iterator it =
_string.begin();
445 std::string::iterator prev = it;
452 for (; prev != it; ++prev)
453 newString.push_back(*prev);
456 utf8::append(with, std::back_inserter(newString));
463 }
catch (
const std::exception &se) {
503 for (
size_t i = 0; (i < n) && (it !=
end()); i++, ++it);
522 for (it =
begin(); it != pos; ++it)
527 for ( ; it !=
end(); ++it)
542 for (it =
begin(); it != pos; ++it)
547 for ( ; it !=
end(); ++it)
562 for (it =
begin(); it != pos; ++it)
567 for (++it; it !=
end(); ++it)
582 for (it =
begin(); it != pos; ++it)
592 for ( ; it !=
end(); ++it)
605 for ( ; it != from; ++it)
608 for ( ; it != to; ++it);
610 for ( ; it !=
end(); ++it)
625 if (splitPoint ==
begin()) {
629 if (splitPoint ==
end()) {
635 for ( ; it != splitPoint; ++it)
641 for ( ; it !=
end(); ++it)
656 tokens.push_back(collect);
665 }
else if (state == 1) {
672 tokens.back() += collect;
677 }
else if (c ==
'>') {
681 tokens.push_back(collect);
701 tokens.push_back(collect);
703 tokens.back() += collect;
710 for ( ; it != from; ++it);
712 for ( ; it != to; ++it)
738 t.
split(point, left, right,
true);
741 length =
MAX(length, left.
size());
742 texts.push_back(left);
749 length =
MAX(length, t.
size());
760 }
catch (
const std::exception &se) {
774 return std::tolower(c);
782 return std::toupper(c);
786 return (c & 0xFFFFFF80) == 0;
790 return isASCII(c) && std::isspace(c);
794 return isASCII(c) && std::isdigit(c);
798 return isASCII(c) && std::isalpha(c);
802 return isASCII(c) && std::isalnum(c);
806 return isASCII(c) && std::iscntrl(c);
810 std::string utf8result;
813 utf8::utf16to8(&c, &c + 1, std::back_inserter(utf8result));
814 }
catch (
const std::exception &se) {
819 return *
iterator(utf8result.begin(), utf8result.begin(), utf8result.end());
void insert(iterator pos, uint32 c)
Insert character c in front of this position.
UString operator+(const UString &str) const
A class holding an UTF-8 string.
bool beginsWith(const UString &with) const
UString & operator=(const UString &str)
bool equalsIgnoreCase(const UString &str) const
bool endsWith(const UString &with) const
void truncate(const iterator &it)
iterator getPosition(size_t n) const
Convert a numerical position into an iterator.
UString & operator+=(const UString &str)
iterator findFirst(uint32 c) const
void swap(UString &str)
Swap the contents of the string with this string's.
void makeUpper()
Convert the string to uppercase.
Exception that provides a stack of explanations.
bool lessIgnoreCase(const UString &str) const
bool less(const UString &str) const
Basic exceptions to throw.
bool contains(const UString &what) const
UString substr(iterator from, iterator to) const
utf8::iterator< std::string::const_iterator > iterator
const char * c_str() const
Return the (utf8 encoded) string data.
void replaceAll(uint32 what, uint32 with)
Replace all occurrences of a character with another character.
static UString format(const char *s,...) GCC_PRINTF(1
Print formatted data into an UString object, similar to sprintf().
Utility templates and functions.
static void splitTextTokens(const UString &text, std::vector< UString > &tokens)
bool operator<(const UString &str) const
bool equals(const UString &str) const
bool empty() const
Is the string empty?
iterator findLast(uint32 c) const
static bool isAlpha(uint32 c)
Is the character an ASCII alphabetic character?
void replace(iterator pos, uint32 c)
Replace the character at this position with c.
bool operator==(const UString &str) const
int strcmp(const UString &str) const
UString()
Construct an empty string.
UString toLower() const
Return a lowercased copy of the string.
bool operator!=(const UString &str) const
static bool isASCII(uint32 c)
Is the character an ASCII character?
size_t size() const
Return the size of the string, in characters.
bool operator>(const UString &str) const
void erase(iterator from, iterator to)
Erase the character within this range.
static bool isDigit(uint32 c)
Is the character an ASCII digit character?
void split(iterator splitPoint, UString &left, UString &right, bool remove=false) const
static bool isCntrl(uint32 c)
Is the character an ASCII control character?
UString toUpper() const
Return an uppercased copy of the string.
void clear()
Clear the string's contents.
std::string _string
Internal string holding the actual data.
void makeLower()
Convert the string to lowercase.
static bool isAlNum(uint32 c)
Is the character an ASCII alphanumeric character?
int stricmp(const UString &str) const
void SWAP(T &a, T &b)
Template method which swaps the values of its two parameters.
static bool isSpace(uint32 c)
Is the character an ASCII space character?
static uint32 fromUTF16(uint16 c)