UaUniString Class Reference

#include <uaunistring.h>

List of all members.

Public Member Functions

 UaUniString ()
 UaUniString (const UaByteArray &other)
 UaUniString (const UaUniString &other)
 UaUniString (const UaUShort *other)
 UaUniString (const char *other)
 ~UaUniString ()
UaUniStringoperator= (const UaUniString &other)
int length () const
int size () const
bool isEmpty () const
bool isNull () const
void clear ()
UaUniString left (int len) const
UaUniString mid (int pos, int len=-1) const
UaUniString right (int len) const
UaUniString arg (unsigned int num, int fieldWidth=0, int base=10)
UaUniString arg (int num, int fieldWidth=0, int base=10)
UaUniString arg (double num, int fieldWidth=0, char format= 'g', int precision=-1)
UaUniString arg (const UaUniString &text)
const UaUShort at (int pos) const
bool startsWith (const UaUniString &strToFind) const
UaUniString replace (const UaUniString &before, const UaUniString &after)
UaUniString replace (const UaUShort &before, const UaUShort &after)
UaUniString replace (int position, int n, const UaUniString &after)
UaUniString replace (int position, const UaUShort &after)
UaUniStringList split (const UaUniString &separator) const
UaUniString append (const UaUniString &str)
UaUniString append (const UaUShort ch)
UaUniString prepend (const UaUniString &str)
UaUniString prepend (const UaUShort ch)
UaUniString trimmed () const
int indexOf (const UaUniString &strToFind, int from=0) const
int indexOf (const UaUShort charToFind, int from=0) const
int lastIndexOf (const UaUniString &strToFind, int from=-1) const
int lastIndexOf (const UaUShort charToFind, int from=-1) const
void chop (int n)
bool operator== (const UaUniString &other) const
bool operator!= (const UaUniString &other) const
bool operator< (const UaUniString &other) const
bool operator> (const UaUniString &other) const
UaUniStringoperator+= (const UaUniString &other)
const UaUShort * toUtf16 () const
BSTR toBSTR () const
wchar_t * toCOMWChar () const
bool isBiggerThan (const UaUniString &other, bool bCaseSensitive) const
bool isSmallerThan (const UaUniString &other, bool bCaseSensitive) const

Friends

class UaUniStringList

Detailed Description

OPC UA string handling class. This class encapsulates an UTF16 encoded string


Constructor & Destructor Documentation

UaUniString::UaUniString (  )

Default constructor. Creates an empty UaUniString.

UaUniString::UaUniString ( const UaByteArray other )

Creates a copy of a UTF-16 encoded ByteArray.

Parameters:
otherUaByteArray.
UaUniString::UaUniString ( const UaUniString other )

Creates a copy of another UaUniString. This operation takes constant time, because UaUniString is implicitly shared. This makes returning a UaUniString from a function very fast. If a shared instance is modified, it will be copied (copy-on-write), and that takes linear time.

UaUniString::UaUniString ( const UaUShort *  other )

Creates a copy of the native OpcUa_String.

Parameters:
otherSource string.
UaUniString::UaUniString ( const char *  other )

Creates a UaUniString from a UTF-8 encoded char* character string.

UaUniString::~UaUniString (  )

Destroyes the string.


Member Function Documentation

UaUniString UaUniString::append ( const UaUniString str )

Appends the string str to end of this string.

UaUniString UaUniString::append ( const UaUShort  ch )

Appends the character ch to end of this string.

UaUniString UaUniString::arg ( unsigned int  num,
int  fieldWidth = 0,
int  base = 10 
)

Returns a copy of this string with the lowest numbered place marker replaced by the given number num, i.e., %1, %2, ..., %9.

Parameters:
numThe number that should be converted to string before inserted.
fieldWidthspecifies the minimum amount of space that argument a shall occupy. If a requires less space than fieldWidth, it is padded to fieldWidth with '0'.
baseThe base used for the number to string conversion. This must be in the range of 2-36.
Returns:
The new string. This example shows how we might create a status string for reporting progress while processing a list of files:
 unsigned int i;          // current file's number
 unsigned int total;      // number of files to process
 UaUniString fileName;    // current file's name

 UaUniString status = UaUniString("Processing file %1 of %2: %3")
     .arg(i).arg(total).arg(fileName);
First, arg(i) replaces 1. Then arg(total) replaces 2. Finally, arg(fileName) replaces 3. One advantage of using arg() over sprintf() is that the order of the numbered place markers can change, if the application's strings are translated into other languages, but each arg() will still replace the lowest numbered unreplaced place marker, no matter where it appears. This functions always replaces the lowest number found. Place marker numbers must be in the range 1 to 9.
UaUniString UaUniString::arg ( int  num,
int  fieldWidth = 0,
int  base = 10 
)

Returns a copy of this string with the lowest numbered place marker replaced by the given number num, i.e., %1, %2, ..., %9. This function behaves like the function above, but works with signed int.

Parameters:
numThe number that should be converted to string before inserted.
fieldWidthspecifies the minimum amount of space that argument a shall occupy. If a requires less space than fieldWidth, it is padded to fieldWidth with '0'.
baseThe base used for the number to string conversion. This must be in the range of 2-36.
Returns:
The new string. This function overloads arg().
UaUniString UaUniString::arg ( double  num,
int  fieldWidth = 0,
char  format = 'g',
int  precision = -1 
)

Returns a copy of this string with the lowest numbered place marker replaced by the given floatingpoint number num, i.e., %1, %2, ..., %9. This function behaves like the function above, but works with a double.

Parameters:
numThe number that should be converted to string before inserted.
fieldWidthspecifies the minimum amount of space that argument a shall occupy. If a requires less space than fieldWidth, it is padded to fieldWidth with '0'.
format'g', 'f', or 'e'. This parameter conforms to the snprintf format specifier.
precisionPrecisions of the floating pointer number.
Returns:
The new string. This function overloads arg().
UaUniString UaUniString::arg ( const UaUniString text )

Returns a copy of this string with the lowest numbered place marker replaced by the given string text, i.e., %1, %2, ..., %9. This function overloads arg().

Parameters:
textThe text that should be inserted.
Returns:
The new string.
const UaUShort UaUniString::at ( int  pos ) const

Returns a read only UTF-16 character.

See also:
replace()
void UaUniString::chop ( int  n )

Removes n characters from the end of the string if n is greater than length(), the result is an empty string

void UaUniString::clear (  )

Clears a UaUniString

int UaUniString::indexOf ( const UaUniString strToFind,
int  from = 0 
) const

Returns the index position of the first occurrence of the string strToFind in this string. Searching forward from index position from. Returns -1 if strToFind is not found. If from is -1, the search starts at the last character; if it is -2, at the next to last character and so on.

int UaUniString::indexOf ( const UaUShort  charToFind,
int  from = 0 
) const

Returns the index position of the first occurrence of the character charToFind in this string. Searching forward from index position from. Returns -1 if charToFind is not found. If from is -1, the search starts at the last character; if it is -2, at the next to last character and so on.

bool UaUniString::isBiggerThan ( const UaUniString other,
bool  bCaseSensitive 
) const

This operator is mainly used to sort strings in alphabetical order.

Parameters:
bCaseSensitiveFlag indicating if the comparison is case sensitive or not. This method will return false if both string are equal.
otherOther string to compare with.
bool UaUniString::isEmpty (  ) const

Returns true if the string is empty or a null string.

bool UaUniString::isNull (  ) const

Returns true if the string is a null string. Returns false if the string is an empty string.

bool UaUniString::isSmallerThan ( const UaUniString other,
bool  bCaseSensitive 
) const

This operator is mainly used to sort strings in alphabetical order.

Parameters:
bCaseSensitiveFlag indicating if the comparison is case sensitive or not.
otherSource string. This method will return false if both string are equal.
int UaUniString::lastIndexOf ( const UaUniString strToFind,
int  from = -1 
) const

Returns the index position of the last occurrence of the string strToFind in this string. Searching backward from index position from. Returns -1 if strToFind is not found. If from is -1, the search starts at the last character; if it is -2, at the next to last character and so on.

int UaUniString::lastIndexOf ( const UaUShort  charToFind,
int  from = -1 
) const

Returns the index position of the last occurrence of the character charToFind in this string. Searching backward from index position from. If from is -1 (the default), the search starts at the last character. If form is -2, at the next to last character and so on. Returns -1 if str is not found.

UaUniString UaUniString::left ( int  len ) const

Returns a UaUniString substring that contains the n leftmost characters of the string. If len is greater than the stringlength or less than zero the entire string is returned

int UaUniString::length (  ) const

Returns the number of characters of this string. You will need this function for displaying it. With UTF-16 strings the number of characters and the size in bytes will differ.

UaUniString UaUniString::mid ( int  pos,
int  len = -1 
) const

Returns a UaUniString string that contains n characters of the string, starting at the specified position. If pos is bigger than the length a null string is returned If len is greater than the stringlength-pos or len == -1 than all characters from the position are returned.

bool UaUniString::operator!= ( const UaUniString other ) const

Returns true if other is not equal to this.

See also:
operator==
UaUniString & UaUniString::operator+= ( const UaUniString other )

Appends a string to the internal string. This creates a copy of the string because the internal data needs to changed.

bool UaUniString::operator< ( const UaUniString other ) const

This operator is mainly used to sort strings. That is e.g. necesarry to use it as a key in a binary tree. Note that this comparison is based on the length of the strings and on the numeric Unicode values - not alphabetical.

UaUniString & UaUniString::operator= ( const UaUniString other )

Assigns other to this string and returns a reference to this string.

bool UaUniString::operator== ( const UaUniString other ) const

Returns true if other is equal to this.

See also:
operator!=
bool UaUniString::operator> ( const UaUniString other ) const

This operator is mainly used to sort strings. That is e.g. necesarry to use it as a key in a binary tree. Note that this comparison is based on the length of the strings and on the numeric Unicode values - not alphabetical.

Parameters:
otherOther string to compare with.
UaUniString UaUniString::prepend ( const UaUniString str )

Prepends the string str to the beginning of this string.

Parameters:
strthe string to prepend to.
Returns:
a new created string.
UaUniString UaUniString::prepend ( const UaUShort  ch )

Prepends the UaUShort ch to the beginning of this string.

Parameters:
chthe string to prepend to.
Returns:
a new created string.
UaUniString UaUniString::replace ( int  position,
const UaUShort &  after 
)

Replaces the character at index position with the character after.

UaUniString UaUniString::replace ( const UaUniString before,
const UaUniString after 
)

Replaces every occurrence of the string before with the string after.

UaUniString UaUniString::replace ( int  position,
int  n,
const UaUniString after 
)

Replaces n characters starting at index position with the string after.

UaUniString UaUniString::replace ( const UaUShort &  before,
const UaUShort &  after 
)

Replaces every occurrence of the character before with the character after.

UaUniString UaUniString::right ( int  len ) const

Returns a UaUniString substring that contains the n rightmost characters of the string. If len is greater than the stringlength or less than zero the entire string is returned

int UaUniString::size (  ) const

Returns the size in bytes that the internal UTF-16 representation needs to hold this string. You will only need this function, if you want to allocate a native UTF-16 string that should be big enough to hold this string.

UaUniStringList UaUniString::split ( const UaUniString separator ) const

Splits the string into substrings wherever sep occurs, and returns the list of those strings. If sep does not match anywhere in the string, split() returns a single-element list containing this string.

bool UaUniString::startsWith ( const UaUniString strToFind ) const

Check if the string starts with the search string.

BSTR UaUniString::toBSTR (  ) const

Create a BSTR using SysAllocString. This string must be freed using SysFreeString.

wchar_t * UaUniString::toCOMWChar (  ) const

Creates a copy of the unicode string using CoTaskMemAlloc. This is used for strings the are passed via COM borders. This string must be freed using CoTaskMemFree.

const UaUShort * UaUniString::toUtf16 (  ) const

Returns the string as a '\0'-terminatde array of UTF-16 characters. The result remains valid until the string is modified.

UaUniString UaUniString::trimmed (  ) const

Returns a copy of this string which has whitespaces removed from start and end. This also removes ASCII characters '
', '', '', '', '', and ' '.


The documentation for this class was generated from the following files:
  • /home/buildbot/work/uasdkcpp/src/uabase/uabasecpp/uaunistring.h
  • /home/buildbot/work/uasdkcpp/src/uabase/uabasecpp/uaunistring.cpp