Logo Search packages:      
Sourcecode: icu version File versions  Download package

UnicodeString::UnicodeString ( UBool  isTerminated,
const UChar *  text,
int32_t  textLength 

Readonly-aliasing UChar* constructor. The text will be used for the UnicodeString object, but it will not be released when the UnicodeString is destroyed. This has copy-on-write semantics: When the string is modified, then the buffer is first copied into newly allocated memory. The aliased buffer is never modified. In an assignment to another UnicodeString, the text will be aliased again, so that both strings then alias the same readonly-text.

isTerminated specifies if text is NUL-terminated. This must be true if textLength==-1.
text The characters to alias for the UnicodeString.
textLength The number of Unicode characters in text to alias. If -1, then this constructor will determine the length by calling u_strlen(). ICU 2.0

Definition at line 232 of file unistr.cpp.

References NULL, setToBogus(), and u_strlen().

  : fShortLength(0),
  if(text == NULL) {
    // treat as an empty string, do not alias
  } else if(textLength < -1 ||
            (textLength == -1 && !isTerminated) ||
            (textLength >= 0 && isTerminated && text[textLength] != 0)
  ) {
  } else {
    if(textLength == -1) {
      // text is terminated, or else it would have failed the above test
      textLength = u_strlen(text);
    setArray((UChar *)text, textLength, isTerminated ? textLength + 1 : textLength);

Generated by  Doxygen 1.6.0   Back to index