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

UnicodeString::UnicodeString ( UChar *  buffer,
int32_t  buffLength,
int32_t  buffCapacity 

Writable-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 write-through semantics: For as long as the capacity of the buffer is sufficient, write operations will directly affect the buffer. When more capacity is necessary, then a new buffer will be allocated and the contents copied as with regularly constructed strings. In an assignment to another UnicodeString, the buffer will be copied. The extract(UChar *dst) function detects whether the dst pointer is the same as the string buffer itself and will in this case not copy the contents.

buffer The characters to alias for the UnicodeString.
buffLength The number of Unicode characters in buffer to alias.
buffCapacity The size of buffer in UChars. ICU 2.0

Definition at line 255 of file unistr.cpp.

References NULL, and setToBogus().

  : fShortLength(0),
  if(buff == NULL) {
    // treat as an empty string, do not alias
  } else if(buffLength < -1 || buffCapacity < 0 || buffLength > buffCapacity) {
  } else {
    if(buffLength == -1) {
      // fLength = u_strlen(buff); but do not look beyond buffCapacity
      const UChar *p = buff, *limit = buff + buffCapacity;
      while(p != limit && *p != 0) {
      buffLength = (int32_t)(p - buff);
    setArray(buff, buffLength, buffCapacity);

Generated by  Doxygen 1.6.0   Back to index