本文整理汇总了C++中UnicodeString::isEmpty方法的典型用法代码示例。如果您正苦于以下问题:C++ UnicodeString::isEmpty方法的具体用法?C++ UnicodeString::isEmpty怎么用?C++ UnicodeString::isEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnicodeString
的用法示例。
在下文中一共展示了UnicodeString::isEmpty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: VariableFound
/**
* Override this method to perform any custom logic when a variable assignment is found. Note that the same
* variable may be assigned different values at different times within the same function.
* The symbol will be constructed in the following way:
*
* Example assignment: $name = $this->getName()->toString();
*
* Variable: The variable's ChainList will contain the variable's name in index 0: "$name"
* ChainList: This is a list of properties / methods
* that were successively invoked.
* In this example, the expression chain list will have 3 items in
* the chain list "$this" "->getName()" and "->toString()".
*
* The variable itself may contain an array key in it; like so: $person['name'] = $this->getName()->toString();
* In this case, Variable ChainList will contain 1 item: "$name" and the Variable Array Key will contain "name"
*
*
* @param const UnicodeString& namespace the fully qualified namespace of the containing class / function.
* @param const UnicodeString& className class where the variable was found. may be empty is variable is scoped
* inside a function or is global.
* @param const UnicodeString& methodName function/method name where the variable was found. may be empty if
* variable is globally scoped.
* @param const VariableClass& variable the name of the variable that was found, along with any array keys that were used
* in the left hand of the assignment.
* @param const ExpressionClass& expression the expression assigned to the variable
* @param const UnicodeString& comment PHPDoc attached to the variable
*
* @see pelet::VariableClass
*/
virtual void VariableFound(const UnicodeString& namespaceName, const UnicodeString& className, const UnicodeString& methodName,
const pelet::VariableClass& variable, pelet::ExpressionClass* expression, const UnicodeString& comment) {
UFILE* ufout = u_finit(stdout, NULL, NULL);
UnicodeString scope;
if (className.isEmpty() && methodName.isEmpty()) {
scope = UNICODE_STRING_SIMPLE("<global>");
}
else if (className.isEmpty() && !methodName.isEmpty()) {
scope = methodName;
}
else {
scope = className + UNICODE_STRING_SIMPLE("::") + methodName;
}
UnicodeString type;
if (variable.IsPhpDocVariable && !variable.PhpDocType.isEmpty()) {
type += UNICODE_STRING_SIMPLE("Variable is decorated with a PHPDoc comment: ");
type += variable.PhpDocType;
}
else if (pelet::ExpressionClass::ARRAY == expression->ExpressionType) {
type = UNICODE_STRING_SIMPLE("Variable is an array");
}
else if (pelet::ExpressionClass::SCALAR == expression->ExpressionType) {
type = UNICODE_STRING_SIMPLE("Variable is a primitive");
}
else if (pelet::ExpressionClass::VARIABLE == expression->ExpressionType) {
type = UNICODE_STRING_SIMPLE("Variable is a variable expression. ");
type += UNICODE_STRING_SIMPLE("Chain list is: ");
pelet::VariableClass* srcVariable = (pelet::VariableClass*) expression;
for (size_t i = 0; i < srcVariable->ChainList.size(); ++i) {
if (srcVariable->ChainList[i].IsStatic && i > 0) {
type += UNICODE_STRING_SIMPLE("::");
}
else if (i > 0) {
type += UNICODE_STRING_SIMPLE("->");
}
type += srcVariable->ChainList[i].Name;
if (srcVariable->ChainList[i].IsFunction) {
type += UNICODE_STRING_SIMPLE("()");
}
if (i < (srcVariable->ChainList.size() - 1)) {
type += UNICODE_STRING_SIMPLE(", ");
}
}
}
else if (pelet::ExpressionClass::UNKNOWN == expression->ExpressionType) {
type = UNICODE_STRING_SIMPLE("Variable is of unknown type.");
}
u_fprintf(ufout, "Variable Found: %.*S in scope %S. %S\n",
variable.ChainList[0].Name.length(), variable.ChainList[0].Name.getBuffer(),
scope.getTerminatedBuffer(),
type.getTerminatedBuffer());
}
示例2: if
bool t4p::WorkingCacheClass::Update(const UnicodeString& code, const t4p::SymbolTableClass& previousSymbolTable) {
pelet::LintResultsClass results;
// allow empty code to be valid; that way code completion works
// on newly created files
bool ret = false;
if (!code.isEmpty()) {
ret = SymbolTable.CreateSymbols(code, previousSymbolTable);
} else if (code.isEmpty()) {
ret = true;
}
return ret;
}
示例3: getTimeZoneDisplayName
// A default, lightweight implementation of getDisplayNames.
// Overridden in tznames_impl.cpp.
void
TimeZoneNames::getDisplayNames(const UnicodeString& tzID, const UTimeZoneNameType types[], int32_t numTypes, UDate date, UnicodeString dest[], UErrorCode& status) const {
if (U_FAILURE(status)) { return; }
if (tzID.isEmpty()) { return; }
UnicodeString mzID;
for (int i = 0; i < numTypes; i++) {
getTimeZoneDisplayName(tzID, types[i], dest[i]);
if (dest[i].isEmpty()) {
if (mzID.isEmpty()) {
getMetaZoneID(tzID, date, mzID);
}
getMetaZoneDisplayName(mzID, types[i], dest[i]);
}
}
}
示例4: tagSearch
std::vector<t4p::PhpTagClass> t4p::TagCacheClass::AllMemberTags(const UnicodeString& fullyQualifiedClassName,
int fileTagId, std::vector<wxFileName>& sourceDirs) {
std::vector<t4p::PhpTagClass> allMatches;
// add the double colon so that we search for all members
// first search for all members of the given class that is also in the given file
t4p::TagSearchClass tagSearch(fullyQualifiedClassName + UNICODE_STRING_SIMPLE("::"));
tagSearch.SetFileItemId(fileTagId);
tagSearch.SetTraits(TagFinderList->ClassUsedTraits(fullyQualifiedClassName, tagSearch.GetParentClasses(),
tagSearch.GetMethodName(), sourceDirs));
TagFinderList->NearMatchesFromAll(tagSearch, allMatches, sourceDirs);
// now get all parent class (look in all files) also look for inherited members and traits
UnicodeString parentClassName = TagFinderList->ParentClassName(fullyQualifiedClassName, fileTagId);
if (!parentClassName.isEmpty()) {
t4p::TagSearchClass hierarchySearch(parentClassName + UNICODE_STRING_SIMPLE("::"));
hierarchySearch.SetParentClasses(TagFinderList->ClassParents(parentClassName, hierarchySearch.GetMethodName()));
hierarchySearch.SetTraits(TagFinderList->ClassUsedTraits(parentClassName, hierarchySearch.GetParentClasses(),
hierarchySearch.GetMethodName(), sourceDirs));
// search classes from the enabled source directories only
hierarchySearch.SetSourceDirs(sourceDirs);
TagFinderList->NearMatchesFromAll(hierarchySearch, allMatches, sourceDirs);
TagFinderList->NearMatchTraitAliasesFromAll(hierarchySearch, allMatches);
}
return allMatches;
}
示例5: getCanonicalCountry
UnicodeString& U_EXPORT2
ZoneMeta::getSingleCountry(const UnicodeString &tzid, UnicodeString &country) {
UErrorCode status = U_ZERO_ERROR;
// Get canonical country for the zone
getCanonicalCountry(tzid, country);
if (!country.isEmpty()) {
UResourceBundle *supplementalDataBundle = ures_openDirect(NULL, gSupplementalData, &status);
UResourceBundle *zoneFormatting = ures_getByKey(supplementalDataBundle, gZoneFormattingTag, NULL, &status);
UResourceBundle *multizone = ures_getByKey(zoneFormatting, gMultizoneTag, NULL, &status);
if (U_SUCCESS(status)) {
while (ures_hasNext(multizone)) {
int32_t len;
const UChar* multizoneCountry = ures_getNextString(multizone, &len, NULL, &status);
if (country.compare(multizoneCountry, len) == 0) {
// Included in the multizone country list
country.remove();
break;
}
}
}
ures_close(multizone);
ures_close(zoneFormatting);
ures_close(supplementalDataBundle);
}
return country;
}
示例6: intl_charFromString
/* {{{ intl_charFromString
* faster than doing intl_convert_utf16_to_utf8(&res, &res_len,
* from.getBuffer(), from.length(), &status),
* but consumes more memory */
int intl_charFromString(const UnicodeString &from, char **res, int *res_len, UErrorCode *status)
{
if (from.isBogus()) {
return FAILURE;
}
//the number of UTF-8 code units is not larger than that of UTF-16 code
//units * 3 + 1 for the terminator
int32_t capacity = from.length() * 3 + 1;
if (from.isEmpty()) {
*res = (char*)emalloc(1);
**res = '\0';
*res_len = 0;
return SUCCESS;
}
*res = (char*)emalloc(capacity);
*res_len = 0; //tbd
const UChar *utf16buf = from.getBuffer();
int32_t actual_len;
u_strToUTF8WithSub(*res, capacity - 1, &actual_len, utf16buf, from.length(),
U_SENTINEL, NULL, status);
if (U_FAILURE(*status)) {
efree(*res);
*res = NULL;
return FAILURE;
}
(*res)[actual_len] = '\0';
*res_len = (int)actual_len;
return SUCCESS;
}
示例7: addChineseIndexCharacters
UBool AlphabeticIndex::addChineseIndexCharacters(UErrorCode &errorCode) {
UnicodeSet contractions;
ucol_getContractionsAndExpansions(collatorPrimaryOnly_->getUCollator(),
contractions.toUSet(), NULL, FALSE, &errorCode);
if (U_FAILURE(errorCode)) { return FALSE; }
UnicodeString firstHanBoundary;
UBool hasPinyin = FALSE;
UnicodeSetIterator iter(contractions);
while (iter.next()) {
const UnicodeString &s = iter.getString();
if (s.startsWith(BASE, BASE_LENGTH)) {
initialLabels_->add(s);
if (firstHanBoundary.isEmpty() ||
collatorPrimaryOnly_->compare(s, firstHanBoundary, errorCode) < 0) {
firstHanBoundary = s;
}
UChar c = s.charAt(s.length() - 1);
if (0x41 <= c && c <= 0x5A) { // A-Z
hasPinyin = TRUE;
}
}
}
if (hasPinyin) {
initialLabels_->add(0x41, 0x5A); // A-Z
}
if (!firstHanBoundary.isEmpty()) {
// The hardcoded list of script boundaries includes U+4E00
// which is tailored to not be the first primary
// in all Chinese tailorings except "unihan".
// Replace U+4E00 with the first boundary string from the tailoring.
// TODO: This becomes obsolete when the root collator gets
// reliable script-first-primary mappings.
int32_t hanIndex = binarySearch(
*firstCharsInScripts_, UnicodeString((UChar)0x4E00), *collatorPrimaryOnly_);
if (hanIndex >= 0) {
UnicodeString *fh = new UnicodeString(firstHanBoundary);
if (fh == NULL) {
errorCode = U_MEMORY_ALLOCATION_ERROR;
return FALSE;
}
firstCharsInScripts_->setElementAt(fh, hanIndex);
}
return TRUE;
} else {
return FALSE;
}
}
示例8: while
UBool
FCDUIterCollationIterator::previousSegment(UErrorCode &errorCode) {
if(U_FAILURE(errorCode)) { return FALSE; }
U_ASSERT(state == ITER_CHECK_BWD);
// The input text [(iter index)..limit[ passes the FCD check.
pos = iter.getIndex(&iter, UITER_CURRENT);
// Collect the characters being checked, in case they need to be normalized.
UnicodeString s;
uint8_t nextCC = 0;
for(;;) {
// Fetch the previous character and its fcd16 value.
UChar32 c = uiter_previous32(&iter);
if(c < 0) { break; }
uint16_t fcd16 = nfcImpl.getFCD16(c);
uint8_t trailCC = (uint8_t)fcd16;
if(trailCC == 0 && !s.isEmpty()) {
// FCD boundary after this character.
uiter_next32(&iter);
break;
}
s.append(c);
if(trailCC != 0 && ((nextCC != 0 && trailCC > nextCC) ||
CollationFCD::isFCD16OfTibetanCompositeVowel(fcd16))) {
// Fails FCD check. Find the previous FCD boundary and normalize.
while(fcd16 > 0xff) {
c = uiter_previous32(&iter);
if(c < 0) { break; }
fcd16 = nfcImpl.getFCD16(c);
if(fcd16 == 0) {
(void)uiter_next32(&iter);
break;
}
s.append(c);
}
s.reverse();
if(!normalize(s, errorCode)) { return FALSE; }
limit = pos;
start = pos - s.length();
state = IN_NORM_ITER_AT_START;
pos = normalized.length();
return TRUE;
}
nextCC = (uint8_t)(fcd16 >> 8);
if(nextCC == 0) {
// FCD boundary before the following character.
break;
}
}
start = pos - s.length();
U_ASSERT(pos != start);
iter.move(&iter, s.length(), UITER_CURRENT);
state = ITER_IN_FCD_SEGMENT;
return TRUE;
}
示例9: getPreferredLanguage
std::string GlobalizationNDK::getPreferredLanguage()
{
const Locale& loc = Locale::getDefault();
UnicodeString disp;
loc.getDisplayLanguage(loc, disp);
if (disp.isEmpty())
return resultInJson("English"); // FIXME: what should be the default language?
std::string utf8;
disp.toUTF8String(utf8);
return resultInJson(utf8);
}
示例10:
UBool
FCDUIterCollationIterator::nextSegment(UErrorCode &errorCode) {
if(U_FAILURE(errorCode)) { return FALSE; }
U_ASSERT(state == ITER_CHECK_FWD);
// The input text [start..(iter index)[ passes the FCD check.
pos = iter.getIndex(&iter, UITER_CURRENT);
// Collect the characters being checked, in case they need to be normalized.
UnicodeString s;
uint8_t prevCC = 0;
for(;;) {
// Fetch the next character and its fcd16 value.
UChar32 c = uiter_next32(&iter);
if(c < 0) { break; }
uint16_t fcd16 = nfcImpl.getFCD16(c);
uint8_t leadCC = (uint8_t)(fcd16 >> 8);
if(leadCC == 0 && !s.isEmpty()) {
// FCD boundary before this character.
uiter_previous32(&iter);
break;
}
s.append(c);
if(leadCC != 0 && (prevCC > leadCC || CollationFCD::isFCD16OfTibetanCompositeVowel(fcd16))) {
// Fails FCD check. Find the next FCD boundary and normalize.
for(;;) {
c = uiter_next32(&iter);
if(c < 0) { break; }
if(nfcImpl.getFCD16(c) <= 0xff) {
uiter_previous32(&iter);
break;
}
s.append(c);
}
if(!normalize(s, errorCode)) { return FALSE; }
start = pos;
limit = pos + s.length();
state = IN_NORM_ITER_AT_LIMIT;
pos = 0;
return TRUE;
}
prevCC = (uint8_t)fcd16;
if(prevCC == 0) {
// FCD boundary after the last character.
break;
}
}
limit = pos + s.length();
U_ASSERT(pos != limit);
iter.move(&iter, -s.length(), UITER_CURRENT);
state = ITER_IN_FCD_SEGMENT;
return TRUE;
}
示例11: nullTerminatedPath
void
ResourceBundle::constructForLocale(const UnicodeString& path,
const Locale& locale,
UErrorCode& error)
{
if (path.isEmpty()) {
fResource = ures_open(NULL, locale.getName(), &error);
}
else {
UnicodeString nullTerminatedPath(path);
nullTerminatedPath.append((UChar)0);
fResource = ures_openU(nullTerminatedPath.getBuffer(), locale.getName(), &error);
}
}
示例12: mergeTimeZoneKey
// Merge the MZ_PREFIX and mzId
static void mergeTimeZoneKey(const UnicodeString& mzID, char* result) {
if (mzID.isEmpty()) {
result[0] = '\0';
return;
}
char mzIdChar[ZID_KEY_MAX + 1];
int32_t keyLen;
int32_t prefixLen = uprv_strlen(gMZPrefix);
keyLen = mzID.extract(0, mzID.length(), mzIdChar, ZID_KEY_MAX + 1, US_INV);
uprv_memcpy((void *)result, (void *)gMZPrefix, prefixLen);
uprv_memcpy((void *)(result + prefixLen), (void *)mzIdChar, keyLen);
result[keyLen + prefixLen] = '\0';
}
示例13: format
UnicodeString &SimpleFormatter::formatAndReplace(
const UnicodeString *const *values, int32_t valuesLength,
UnicodeString &result,
int32_t *offsets, int32_t offsetsLength, UErrorCode &errorCode) const {
if (U_FAILURE(errorCode)) {
return result;
}
if (isInvalidArray(values, valuesLength) || isInvalidArray(offsets, offsetsLength)) {
errorCode = U_ILLEGAL_ARGUMENT_ERROR;
return result;
}
const UChar *cp = compiledPattern.getBuffer();
int32_t cpLength = compiledPattern.length();
if (valuesLength < getArgumentLimit(cp, cpLength)) {
errorCode = U_ILLEGAL_ARGUMENT_ERROR;
return result;
}
// If the pattern starts with an argument whose value is the same object
// as the result, then we keep the result contents and append to it.
// Otherwise we replace its contents.
int32_t firstArg = -1;
// If any non-initial argument value is the same object as the result,
// then we first copy its contents and use that instead while formatting.
UnicodeString resultCopy;
if (getArgumentLimit(cp, cpLength) > 0) {
for (int32_t i = 1; i < cpLength;) {
int32_t n = cp[i++];
if (n < ARG_NUM_LIMIT) {
if (values[n] == &result) {
if (i == 2) {
firstArg = n;
} else if (resultCopy.isEmpty() && !result.isEmpty()) {
resultCopy = result;
}
}
} else {
i += n - ARG_NUM_LIMIT;
}
}
}
if (firstArg < 0) {
result.remove();
}
return format(cp, cpLength, values,
result, &resultCopy, FALSE,
offsets, offsetsLength, errorCode);
}
示例14: TraitAliasFound
/**
* Override this method to perform custom logic when a trait method has been aliased
*
* @param const UnicodeString& namespace the fully qualified namespace of the class that uses the trait
* @param traitUsedClassName the class name of the trait to be aliased
* @param traitMethodName the fully qualified name of the trait method that is to be aliased (hidden)
* this may be empty if the trait adaptation only changes the visibility and
* does not need to resolve a trait conflict
* @param alias the name of the new alias. alias may be empty when ONLY the visibility is changed.
* @param visibility the visbility of the trait method. may be PUBLIC if the visibility was not changed.
*/
virtual void TraitAliasFound(const UnicodeString& namespaceName, const UnicodeString& className, const UnicodeString& traitUsedClassName,
const UnicodeString& traitMethodName,
const UnicodeString& alias, pelet::TokenClass::TokenIds visibility) {
UFILE* ufout = u_finit(stdout, NULL, NULL);
if (!alias.isEmpty()) {
const char* visibilityStr;
if (pelet::TokenClass::PRIVATE == visibility) {
visibilityStr = "private";
}
else if (pelet::TokenClass::PROTECTED == visibility) {
visibilityStr = "protected";
}
else {
visibilityStr = "public";
}
u_fprintf(ufout, "Trait Alias Found in class %.*S in namespace %.*S. Trait Class %.*S Trait Method %.*S Trait Alias %.*S New Visibility %s \n",
className.length(), className.getBuffer(),
namespaceName.length(), namespaceName.getBuffer(),
traitUsedClassName.length(), traitUsedClassName.getBuffer(),
traitMethodName.length(), traitMethodName.getBuffer(),
alias.length(), alias.getBuffer(),
visibilityStr
);
}
else {
const char* visibilityStr;
if (pelet::TokenClass::PRIVATE == visibility) {
visibilityStr = "private";
}
else if (pelet::TokenClass::PROTECTED == visibility) {
visibilityStr = "protected";
}
else {
visibilityStr = "public";
}
u_fprintf(ufout, "Trait Change in visbility Found in class %.*S in namespace %.*S. Trait Class %.*S Trait Method %.*S New Visibility %s\n",
className.length(), className.getBuffer(),
namespaceName.length(), namespaceName.getBuffer(),
traitUsedClassName.length(), traitUsedClassName.getBuffer(),
traitMethodName.length(), traitMethodName.getBuffer(),
visibilityStr
);
}
u_fclose(ufout);
}
示例15: UnicodeString
UnicodeString& U_EXPORT2
TimeZoneNamesImpl::getDefaultExemplarLocationName(const UnicodeString& tzID, UnicodeString& name) {
if (tzID.isEmpty() || tzID.startsWith(gEtcPrefix, gEtcPrefixLen)
|| tzID.startsWith(gSystemVPrefix, gSystemVPrefixLen) || tzID.indexOf(gRiyadh8, gRiyadh8Len, 0) > 0) {
name.setToBogus();
return name;
}
int32_t sep = tzID.lastIndexOf((UChar)0x2F /* '/' */);
if (sep > 0 && sep + 1 < tzID.length()) {
name.setTo(tzID, sep + 1);
name.findAndReplace(UnicodeString((UChar)0x5f /* _ */),
UnicodeString((UChar)0x20 /* space */));
} else {
name.setToBogus();
}
return name;
}