25 #ifndef COMMON_USTRING_H 26 #define COMMON_USTRING_H 32 #include <boost/functional/hash.hpp> 37 #include "utf8cpp/utf8.h" 50 typedef utf8::iterator<std::string::const_iterator>
iterator;
53 struct sless : std::binary_function<UString, UString, bool> {
55 return str1.
less(str2);
60 struct iless : std::binary_function<UString, UString, bool> {
71 UString(
const std::string &str);
75 UString(
const char *str,
size_t n);
123 const char *
c_str()
const;
228 boost::hash_combine<uint32>(seed, *it);
247 #endif // COMMON_USTRING_H size_t operator()(const UString &str) const
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.
size_t operator()(const UString &str) const
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.
bool lessIgnoreCase(const UString &str) const
bool less(const UString &str) const
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().
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?
Low-level type definitions to handle fixed width types portably.
iterator findLast(uint32 c) const
static bool isAlpha(uint32 c)
Is the character an ASCII alphabetic character?
bool operator()(const UString &str1, const UString &str2) const
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.
Low-level detection of architecture/system properties.
bool operator>(const UString &str) const
void erase(iterator from, iterator to)
Erase the character within this range.
bool operator()(const UString &str1, const UString &str2) const
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
static bool isSpace(uint32 c)
Is the character an ASCII space character?
static uint32 fromUTF16(uint16 c)