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

Make this UnicodeString object invalid. The string will test TRUE with isBogus().

A bogus string has no value. It is different from an empty string. It can be used to indicate that no string value is available. getBuffer() and getTerminatedBuffer() return NULL, and length() returns 0.

This utility function is used throughout the UnicodeString implementation to indicate that a UnicodeString operation failed, and may be used in other functions, especially but not exclusively when such functions do not take a UErrorCode for simplicity.

The following methods, and no others, will clear a string object's bogus flag:

The simplest ways to turn a bogus string into an empty one is to use the remove() function. Examples for other functions that are equivalent to "set to empty string":

 if(s.isBogus()) {
   s.remove();           // set to an empty string (remove all), or
   s.remove(0, INT32_MAX); // set to an empty string (remove all), or
   s.truncate(0);        // set to an empty string (complete truncation), or
   s=UnicodeString();    // assign an empty string, or
   s.setTo((UChar32)-1); // set to a pseudo code point that is out of range, or
   static const UChar nul=0;
   s.setTo(&nul, 0);     // set to an empty C Unicode string
 }
See also:
isBogus() ICU 2.0

Definition at line 1069 of file unistr.cpp.

Referenced by MessageFormat::autoQuoteApostrophe(), Normalizer::concatenate(), SimpleDateFormat::construct(), LocaleKey::currentDescriptor(), LocaleKey::fallback(), fromUTF32(), ZoneMeta::getCanonicalCLDRID(), ZoneMeta::getCanonicalCountry(), RuleBasedNumberFormat::getDefaultRuleSetName(), LocaleKeyFactory::getDisplayName(), TestFactory::getDisplayName(), SimpleFactory::getDisplayName(), TestMultipleKeyStringFactory::getDisplayName(), CFactory::getDisplayName(), ICUService::getDisplayName(), ZoneMeta::getMetazoneID(), RuleBasedNumberFormat::getRuleSetDisplayName(), ZoneMeta::getSingleCountry(), Formattable::getString(), ZoneMeta::getZoneIdByMetazone(), Formattable::init(), LocaleKey::LocaleKey(), CanonicalIterator::next(), Normalizer2WithImpl::normalize(), Normalizer::normalize(), FilteredNormalizer2::normalize(), SimpleDateFormat::processOverrideString(), setTo(), SimpleDateFormat::SimpleDateFormat(), SelectFormat::toPattern(), PluralFormat::toPattern(), MessageFormat::toPattern(), and UnicodeString().

{
  releaseArray();

  fShortLength = 0;
  fUnion.fFields.fArray = 0;
  fUnion.fFields.fCapacity = 0;
  fFlags = kIsBogus;
}

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index