91 template <
typename QStringType,
typename QCoreApp>
95 template <
typename QStringType>
106 inline void setFromUtf8(
const unsigned char* utf8,
int len = -1 );
107 inline void setFromUtf8(
const std::string& utf8 );
111 inline void setFromLatin1(
const char* latin,
int len = -1 );
115 inline void setFromUtf16(
const unsigned short* utf16,
int len = -1 );
119 inline void setFromUtf32(
const unsigned int* utf32,
int len = -1 );
127 inline void setFromAscii(
const char* ascii,
int len = -1 );
130 template <
typename QStringType>
135 inline void toAscii( std::string& str )
const;
136 inline std::string
toAscii()
const;
140 inline void toLatin1( std::string& str )
const;
141 inline std::string
toLatin1()
const;
144 inline void toUtf8( std::string& str )
const;
145 inline std::string
toUtf8()
const;
152 template <
typename QStringType>
156 template <
typename QStringType>
157 inline void toQString( QStringType& qstr )
const;
176 inline size_t length()
const;
212 virtual bool snipFront(
const char ch,
bool toLastCh =
false );
213 virtual bool snipBack(
const char ch,
bool fromFirstCh =
false );
227 inline void resize(
int size );
242 inline explicit DtUcString(
const unsigned short* utf16,
int len = -1 );
245 inline explicit DtUcString(
const unsigned int* utf32,
int len = -1 );
248 inline explicit DtUcString(
const std::string& ascii );
273 inline void resize(
size_t newSize );
286 inline size_t size()
const;
295 inline bool unique()
const;
298 inline bool empty()
const;
321 size_t seed = 2166136261U;
323 size_t last = val.
length();
324 size_t stride = 1 + last / 10;
330 for ( ; first < last; first += stride )
332 seed = 16777619U * seed ^ (size_t)val.
codeUnits()[first];
339 #include "vlUnicode.inl"
DtUcString operator+(const DtUcString &str) const
Append two strings together.
static DtUcString fromQString(QStringType qstr)
Template function for setting from Qt 4 style string.
std::string toUtf8() const
void concat(const CodeUnitArray &other)
Concat another array, supports concat operations on itself.
DtUcString()
CTOR creates an empty string.
QStringType toQString() const
Template function for outputting a Qt 4 style string.
bool operator!=(const DtUcString &other) const
Test if two strings are not identical.
void setFromUtf16(const unsigned short *utf16, int len=-1)
Set from an UTF-16 encoded string, the string MUST be zero terminated if the length is not passed...
Definition: vlUnicode.h:233
void setFromWCharArray(const wchar_t utf16[], int len=-1)
Set from an wchar string, the string MUST be zero terminated if the length is not passed...
int lastIndexOf(const DtUnicodeChar &x, size_t pos=0) const
Search for a character starting a pos, returns index, or -1 if not found.
static DtUcString tr(const char *ascii)
Ascii translation function, used to be compatible with Qt's translation tools.
void setFromQString(QStringType qstr)
Template function for setting from Qt 4 style string.
static DtUcString fromUtf32(const unsigned int *utf32, int len=-1)
Create a unicode string from an UTF-32 encoded string, the string MUST be zero terminated if the leng...
size_t length() const
Get the length in Code Units.
volatile long * count
Definition: vlUnicode.h:306
size_t sizeInBytes() const
Get the size in 8bit bytes.
void setFromUtf8(const unsigned char *utf8, int len=-1)
Set from an UTF-8 encoded string, the string MUST be zero terminated if the length is not passed...
size_t size() const
Return size in bytes.
bool empty() const
Am I empty.
CodeUnitArray & operator=(const CodeUnitArray &)
Assignment operator.
std::string toAscii() const
size_t calculateCapacity(size_t necessarySize)
Calculate the capacity.
const CodeUnit * codeUnits() const
Get an array of code units.
Contains the DtUnicodeChar class declaration/definition.
CodeUnit * begin
Definition: vlUnicode.h:307
void setFromLatin1(const char *latin, int len=-1)
Set from an UTF-8 encoded string, the string MUST be zero terminated if the length is not passed...
static DtUcString fromUtf16(const unsigned short *utf16, int len=-1)
Create a unicode string from an UTF-16 encoded string, the string MUST be zero terminated if the leng...
void resize(int size)
Resize a string to a new size, if the size < 0 the string will be empty.
DtUcString & operator+=(const DtUcString &str)
Append a string to the end.
void resize(size_t newSize)
Resize the array.
A unicode string.
Definition: vlUnicode.h:27
static DtUcString fromWCharArray(const wchar_t utf16[], int len=-1)
Set from a wchar_t array, compiler encoding specific, the string MUST be zero terminated if the lengt...
~DtUcString()
DTOR may NOT deallocate memory as this string may share data.
std::string toLatin1() const
static DtUcString fromWideString(const std::wstring &str)
Set from a std::wstring.
Definition: vlUnicode.h:235
DtUcString & operator=(const DtUcString &str)
Assignment operator copies the string, this function will NOT allocate memory for the string...
A single unicode character.
Definition: vlUnicodeChar.h:16
virtual bool snipBack(const char ch, bool fromFirstCh=false)
Truncates everything before or after the character, including the character, respectively.
Internal structure used to store the code units.
Definition: vlUnicode.h:257
int indexOf(const DtUnicodeChar &x, size_t pos=0) const
Search for a character starting a pos, returns index, or -1 if not found.
void dec_ref()
Decrement the reference count.
CodeUnitArray myCodeUnits
Definition: vlUnicode.h:313
bool unique() const
Am I unique.
static DtUcString fromAscii(const std::string &ascii)
Create a unicode string from an ascii string, the string MUST be zero terminated if the length is not...
void setFromUtf32(const unsigned int *utf32, int len=-1)
Set from an UTF-32 encoded string, the string MUST be zero terminated if the length is not passed...
bool operator<(const DtUcString &other) const
Test if a string is less than another based on their first different character or the length...
QStringType translate() const
Utility function for translating a DtUcString variable initialized using the static DtUcString::tr fu...
static DtUcString fromUtf8(const unsigned char *utf8, int len=-1)
Create a unicode string from an UTF-16 encoded string, the string MUST be zero terminated if the leng...
void reserve(size_t capacity)
Ensure the array's capacity is at least capacity, do not change size.
CodeUnit * last
Definition: vlUnicode.h:309
size_t calculateCodePoints() const
Calculate the number of Code Points.
Encoding
Definition: vlUnicode.h:231
virtual bool snipFront(const char ch, bool toLastCh=false)
Truncates everything before or after the character, including the character, respectively.
std::wstring toWideString() const
CodeUnit * end
Definition: vlUnicode.h:308
void clear()
Resize the array to 0, does not change the memory allocation if the array is unique.
std::size_t hash_value(const DtUcString &val)
Definition: vlUnicode.h:318
void add_ref()
Increment the reference count.
bool operator==(const DtUcString &other) const
Test if two strings are identical.
Definition: vlUnicode.h:234
DtUcString subString(size_t pos=0, int len=-1) const
Create a substring starting at position, for n characters.
void setFromAscii(const std::string &ascii)
Set from an ascii string, the string MUST be zero terminated if the length is not passed...
size_t capacity() const
Return capacity in bytes.
void push_back(const DtUnicodeChar &x)
Append a unicode character to the string.
unsigned short CodeUnit
Definition: vlUnicode.h:31