UA Server SDK C++ Bundle
1.4.1.271
|
OPC UA string handling class. More...
#include <uaunistring.h>
Public Member Functions | |
UaUniString () | |
Default constructor. More... | |
UaUniString (const UaByteArray &other) | |
Creates a copy of a UTF-16 encoded ByteArray. More... | |
UaUniString (const UaUniString &other) | |
Creates a copy of another UaUniString. More... | |
UaUniString (const UaUShort *other) | |
Creates a copy of the native OpcUa_String. More... | |
UaUniString (const char *other) | |
Creates a UaUniString from a UTF-8 encoded char* character string. | |
~UaUniString () | |
Destroys the string. More... | |
UaUniString & | operator= (const UaUniString &other) |
Assigns other to this string and returns a reference to this string. More... | |
int | length () const |
Returns the number of characters of this string. More... | |
int | size () const |
Returns the size in bytes that the internal UTF-16 representation needs to hold this string. More... | |
bool | isEmpty () const |
Returns true if the string is empty or a null string. More... | |
bool | isNull () const |
Returns true if the string is a null string. More... | |
void | clear () |
Clears a UaUniString. | |
UaUniString | left (int len) const |
Returns a UaUniString substring that contains the n leftmost characters of the string. More... | |
UaUniString | mid (int pos, int len=-1) const |
Returns a UaUniString string that contains n characters of the string, starting at the specified position. More... | |
UaUniString | right (int len) const |
Returns a UaUniString substring that contains the n rightmost characters of the string. More... | |
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. More... | |
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. More... | |
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 floating point number num, i.e., %%1, %%2, ..., %%9. More... | |
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. More... | |
UaUShort | at (int pos) const |
Returns a read only UTF-16 character. More... | |
bool | startsWith (const UaUniString &strToFind) const |
Check if the string starts with the search string. More... | |
bool | endsWith (const UaUniString &strToFind) const |
Check if the string ends with the search string. More... | |
UaUniString & | replace (const UaUniString &before, const UaUniString &after) |
Replaces every occurrence of the string before with the string after. More... | |
UaUniString & | replace (const UaUShort &before, const UaUShort &after) |
Replaces every occurrence of the character before with the character after. More... | |
UaUniString & | replace (int position, int n, const UaUniString &after) |
Replaces n characters starting at index position with the string after. More... | |
UaUniString & | replace (int position, const UaUShort &after) |
Replaces the character at index position with the character after. More... | |
UaUniStringList | split (const UaUniString &separator) const |
Splits the string into substrings wherever the separator occurs, and returns the list of those strings. More... | |
UaUniString & | append (const UaUniString &str) |
Appends the string str to end of this string. More... | |
UaUniString & | append (const UaUShort ch) |
Appends the character ch to end of this string. More... | |
UaUniString & | prepend (const UaUniString &str) |
Prepends the string str to the beginning of this string. More... | |
UaUniString & | prepend (const UaUShort ch) |
Prepends the UaUShort ch to the beginning of this string. More... | |
UaUniString | trimmed () const |
Returns a copy of this string which has whitespaces removed from start and end. More... | |
int | indexOf (const UaUniString &strToFind, int from=0) const |
Returns the index position of the first occurrence of the string strToFind in this string. More... | |
int | indexOf (const UaUShort charToFind, int from=0) const |
Returns the index position of the first occurrence of the character charToFind in this string. More... | |
int | lastIndexOf (const UaUniString &strToFind, int from=-1) const |
Returns the index position of the last occurrence of the string strToFind in this string. More... | |
int | lastIndexOf (const UaUShort charToFind, int from=-1) const |
Returns the index position of the last occurrence of the character charToFind in this string. More... | |
void | chop (int n) |
Removes n characters from the end of the string if n is greater than length(), the result is an empty string. | |
bool | operator== (const UaUniString &other) const |
Returns true if other is equal to this. More... | |
bool | operator!= (const UaUniString &other) const |
Returns true if other is not equal to this. More... | |
bool | operator< (const UaUniString &other) const |
This operator is mainly used to sort strings. More... | |
bool | operator> (const UaUniString &other) const |
This operator is mainly used to sort strings. More... | |
UaUniString & | operator+= (const UaUniString &other) |
Appends a string to the internal string. More... | |
const UaUShort * | toUtf16 () const |
Returns the string as a '\0'-terminated array of UTF-16 characters. More... | |
BSTR | toBSTR () const |
Create a BSTR using SysAllocString. More... | |
wchar_t * | toCOMWChar () const |
Creates a copy of the unicode string using CoTaskMemAlloc. More... | |
bool | isBiggerThan (const UaUniString &other, bool bCaseSensitive) const |
This operator is mainly used to sort strings in alphabetical order. More... | |
bool | isSmallerThan (const UaUniString &other, bool bCaseSensitive) const |
This operator is mainly used to sort strings in alphabetical order. More... | |
OPC UA string handling class.
This class encapsulates an UTF16 encoded string
UaUniString::UaUniString | ( | ) |
Default constructor.
Creates an empty UaUniString.
UaUniString::UaUniString | ( | const UaByteArray & | other | ) |
Creates a copy of a UTF-16 encoded ByteArray.
other | UaByteArray. |
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.
other | Source string. |
UaUniString::~UaUniString | ( | ) |
Destroys the string.
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.
num | The number that should be converted to string before inserted. |
fieldWidth | specifies the minimum amount of space that argument a shall occupy. If a requires less space than fieldWidth, it is padded to fieldWidth with '0'. |
base | The base used for the number to string conversion. This must be in the range of 2-36. |
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.
num | The number that should be converted to string before inserted. |
fieldWidth | specifies the minimum amount of space that argument a shall occupy. If a requires less space than fieldWidth, it is padded to fieldWidth with '0'. |
base | The base used for the number to string conversion. This must be in the range of 2-36. |
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 floating point number num, i.e., %%1, %%2, ..., %%9.
This function behaves like the function above, but works with a double.
num | The number that should be converted to string before inserted. |
fieldWidth | specifies 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. |
precision | Precisions of the floating pointer number. |
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().
text | The text that should be inserted. |
UaUShort UaUniString::at | ( | int | pos | ) | const |
Returns a read only UTF-16 character.
bool UaUniString::endsWith | ( | const UaUniString & | strToFind | ) | const |
Check if the string ends with the search string.
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.
bCaseSensitive | Flag indicating if the comparison is case sensitive or not. This method will return false if both string are equal. |
other | Other 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.
bCaseSensitive | Flag indicating if the comparison is case sensitive or not. |
other | Source 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 string length 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.
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. necessary 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.
bool UaUniString::operator> | ( | const UaUniString & | other | ) | const |
This operator is mainly used to sort strings.
That is e.g. necessary 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.
other | Other string to compare with. |
UaUniString & UaUniString::prepend | ( | const UaUniString & | str | ) |
Prepends the string str to the beginning of this string.
str | the string to prepend to. |
UaUniString & UaUniString::prepend | ( | const UaUShort | ch | ) |
Prepends the UaUShort ch to the beginning of this string.
ch | the string to prepend to. |
UaUniString & UaUniString::replace | ( | const UaUniString & | before, |
const UaUniString & | after | ||
) |
Replaces every occurrence of the string before 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::replace | ( | int | position, |
int | n, | ||
const UaUniString & | after | ||
) |
Replaces n characters starting at index position with the string after.
UaUniString & UaUniString::replace | ( | int | position, |
const UaUShort & | after | ||
) |
Replaces the character at index position 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 string length 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 the separator occurs, and returns the list of those strings.
If the separator 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'-terminated 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 '\n', '\t', '\v', '\f', '\r', and ' '.