本文整理汇总了C++中Currency::convertTo方法的典型用法代码示例。如果您正苦于以下问题:C++ Currency::convertTo方法的具体用法?C++ Currency::convertTo怎么用?C++ Currency::convertTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Currency
的用法示例。
在下文中一共展示了Currency::convertTo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fixup_sub
//.........这里部分代码省略.........
i = 0;
v = fixup_sub(str, errors, calculated) * v;
} else if(i == input.length() - 1) {
input = input.left(i);
} else if(i == 0) {
input = input.right(input.length() - 1);
}
v = fixup_sub(input, errors, calculated) * v;
}
calculated = true;
return v;
}
if(o_currency) {
QString reg_exp_str = "[\\d\\+\\-\\^";
reg_exp_str += '\\';
reg_exp_str += budget->monetary_decimal_separator;
reg_exp_str += '\\';
reg_exp_str += budget->monetary_group_separator;
if(budget->monetary_decimal_separator != "." && budget->monetary_group_separator != ".") {
reg_exp_str += '\\';
reg_exp_str += '.';
}
reg_exp_str += "]";
int i = input.indexOf(QRegExp(reg_exp_str));
if(i >= 1) {
QString scur = input.left(i).trimmed();
Currency *cur = budget->findCurrency(scur);
if(!cur && budget->defaultCurrency()->symbol(false) == scur) cur = budget->defaultCurrency();
if(!cur) cur = budget->findCurrencySymbol(scur, true);
if(cur) {
QString value = input.right(input.length() - i);
double v = fixup_sub(value, errors, calculated);
if(cur != o_currency) {
v = cur->convertTo(v, o_currency);
}
calculated = true;
return v;
}
errors << tr("Unknown or ambiguous currency, or unrecognized characters, in expression: %1.").arg(scur);
}
if(i >= 0) {
i = input.lastIndexOf(QRegExp(reg_exp_str));
if(i >= 0 && i < input.length() - 1) {
QString scur = input.right(input.length() - (i + 1)).trimmed();
Currency *cur = budget->findCurrency(scur);
if(!cur && budget->defaultCurrency()->symbol(false) == scur) cur = budget->defaultCurrency();
if(!cur) cur = budget->findCurrencySymbol(scur, true);
if(cur) {
QString value = input.left(i + 1);
double v = fixup_sub(value, errors, calculated);
if(cur != o_currency) {
v = cur->convertTo(v, o_currency);
}
calculated = true;
return v;
}
errors << tr("Unknown or ambiguous currency, or unrecognized characters, in expression: %1.").arg(scur);
}
} else {
Currency *cur = budget->findCurrency(input);
if(!cur && budget->defaultCurrency()->symbol(false) == input) cur = budget->defaultCurrency();
if(!cur) cur = budget->findCurrencySymbol(input, true);
if(cur) {
double v = 1.0;
if(cur != o_currency) {
v = cur->convertTo(v, o_currency);