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

void UnicodeString::releaseBuffer ( int32_t  newLength = -1  ) 

Release a read/write buffer on a UnicodeString object with an "open" getBuffer(minCapacity). This function must be called in a matched pair with getBuffer(minCapacity). releaseBuffer(newLength) must be called if and only if a getBuffer(minCapacity) is "open".

It will set the string length to newLength, at most to the current capacity. If newLength==-1 then it will set the length according to the first NUL in the buffer, or to the capacity if there is no NUL.

After calling releaseBuffer(newLength) the UnicodeString is back to normal operation.

newLength the new length of the UnicodeString object; defaults to the current capacity if newLength is greater than that; if newLength==-1, it defaults to u_strlen(buffer) but not more than the current capacity of the string
See also:
getBuffer(int32_t minCapacity) ICU 2.0

Definition at line 1491 of file unistr.cpp.

References getCapacity().

Referenced by MessageFormat::autoQuoteApostrophe(), ReplaceableGlue::extractBetween(), fromUTF32(), Locale::getDisplayCountry(), Locale::getDisplayLanguage(), Locale::getDisplayName(), Locale::getDisplayScript(), Locale::getDisplayVariant(), RegexMatcher::input(), UXMLParser::parseFile(), RegexPattern::pattern(), StringEnumeration::setChars(), and UnicodeStringTest::TestMiscellaneous().

  if(fFlags&kOpenGetBuffer && newLength>=-1) {
    // set the new fLength
    int32_t capacity=getCapacity();
    if(newLength==-1) {
      // the new length is the string length, capped by fCapacity
      const UChar *array=getArrayStart(), *p=array, *limit=array+capacity;
      while(p<limit && *p!=0) {
    } else if(newLength>capacity) {

Generated by  Doxygen 1.6.0   Back to index