本文整理汇总了C++中NFRule::getType方法的典型用法代码示例。如果您正苦于以下问题:C++ NFRule::getType方法的具体用法?C++ NFRule::getType怎么用?C++ NFRule::getType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NFRule
的用法示例。
在下文中一共展示了NFRule::getType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
void
NFRuleSet::parseRules(UnicodeString& description, const RuleBasedNumberFormat* owner, UErrorCode& status)
{
// start by creating a Vector whose elements are Strings containing
// the descriptions of the rules (one rule per element). The rules
// are separated by semicolons (there's no escape facility: ALL
// semicolons are rule delimiters)
if (U_FAILURE(status)) {
return;
}
// ensure we are starting with an empty rule list
rules.deleteAll();
// dlf - the original code kept a separate description array for no reason,
// so I got rid of it. The loop was too complex so I simplified it.
UnicodeString currentDescription;
int32_t oldP = 0;
while (oldP < description.length()) {
int32_t p = description.indexOf(gSemicolon, oldP);
if (p == -1) {
p = description.length();
}
currentDescription.setTo(description, oldP, p - oldP);
NFRule::makeRules(currentDescription, this, rules.last(), owner, rules, status);
oldP = p + 1;
}
// for rules that didn't specify a base value, their base values
// were initialized to 0. Make another pass through the list and
// set all those rules' base values. We also remove any special
// rules from the list and put them into their own member variables
int64_t defaultBaseValue = 0;
// (this isn't a for loop because we might be deleting items from
// the vector-- we want to make sure we only increment i when
// we _didn't_ delete aything from the vector)
uint32_t i = 0;
while (i < rules.size()) {
NFRule* rule = rules[i];
switch (rule->getType()) {
// if the rule's base value is 0, fill in a default
// base value (this will be 1 plus the preceding
// rule's base value for regular rule sets, and the
// same as the preceding rule's base value in fraction
// rule sets)
case NFRule::kNoBase:
rule->setBaseValue(defaultBaseValue, status);
if (!isFractionRuleSet()) {
++defaultBaseValue;
}
++i;
break;
// if it's the negative-number rule, copy it into its own
// data member and delete it from the list
case NFRule::kNegativeNumberRule:
if (negativeNumberRule) {
delete negativeNumberRule;
}
negativeNumberRule = rules.remove(i);
break;
// if it's the improper fraction rule, copy it into the
// correct element of fractionRules
case NFRule::kImproperFractionRule:
if (fractionRules[0]) {
delete fractionRules[0];
}
fractionRules[0] = rules.remove(i);
break;
// if it's the proper fraction rule, copy it into the
// correct element of fractionRules
case NFRule::kProperFractionRule:
if (fractionRules[1]) {
delete fractionRules[1];
}
fractionRules[1] = rules.remove(i);
break;
// if it's the master rule, copy it into the
// correct element of fractionRules
case NFRule::kMasterRule:
if (fractionRules[2]) {
delete fractionRules[2];
}
fractionRules[2] = rules.remove(i);
break;
// if it's a regular rule that already knows its base value,
// check to make sure the rules are in order, and update
// the default base value for the next rule
default:
if (rule->getBaseValue() < defaultBaseValue) {
// throw new IllegalArgumentException("Rules are not in order");
status = U_PARSE_ERROR;
//.........这里部分代码省略.........