当前位置: 首页>>代码示例>>C++>>正文


C++ Money::currency方法代码示例

本文整理汇总了C++中Money::currency方法的典型用法代码示例。如果您正苦于以下问题:C++ Money::currency方法的具体用法?C++ Money::currency怎么用?C++ Money::currency使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Money的用法示例。


在下文中一共展示了Money::currency方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: checkCurrency

void Money::checkCurrency(Money& ans, const Money& v1, const Money& v2)
{
  if(v1.currency() == "" && v1.valueInCents() != 0){
    throw WException("Payment::Money::checkCurrency "
                     "money with no currency has value.");
  }

  if(v2.currency() == "" && v2.valueInCents() != 0){
    throw WException("Payment::Money::checkCurrency "
                     "money with no currency has value.");
  }

  if(v1.currency() == ""){
    ans.setCurrency(v2.currency());
    return;
  }

  if(v2.currency() == ""){
    ans.setCurrency(v1.currency());
    return;
  }

  if(v1.currency() != v2.currency()){
    throw WException("Payment::Money::checkCurrency different currency");
  }
}
开发者ID:913862627,项目名称:wt,代码行数:26,代码来源:Money.C

示例2: setModelData

//------------------------------------------------------------------------------
void ConditionValueDelegate::setModelData(QWidget* editor,
	QAbstractItemModel* model, const QModelIndex& index) const
{
	switch (field(index))
	{
	case AssignmentRule::Date:
	{
		QDateEdit* dateEditor = static_cast<QDateEdit*>(editor);
		QDate date = dateEditor->date();
		model->setData(index, date.toString(Qt::ISODate), Qt::EditRole);
	}
		break;

	case AssignmentRule::Amount:
	{
		MoneyEdit* moneyEditor = static_cast<MoneyEdit*>(editor);
		Money amount = moneyEditor->value();
		QString newVal = QString("%1,%2")
			.arg(amount.amount()).arg(amount.currency().code());
		model->setData(index, newVal, Qt::EditRole);
	}
		break;

	default:
	{
		LineEdit* stringEditor = static_cast<LineEdit*>(editor);
		model->setData(index, stringEditor->text(), Qt::EditRole);
	}

	}
}
开发者ID:vimofthevine,项目名称:UnderBudget,代码行数:32,代码来源:ConditionValueDelegate.cpp

示例3: if

 Decimal operator/(const Money& m1, const Money& m2) {
     if (m1.currency() == m2.currency()) {
         return m1.value()/m2.value();
     } else if (Money::conversionType == Money::BaseCurrencyConversion) {
         Money tmp1 = m1;
         convertToBase(tmp1);
         Money tmp2 = m2;
         convertToBase(tmp2);
         return tmp1/tmp2;
     } else if (Money::conversionType == Money::AutomatedConversion) {
         Money tmp = m2;
         convertTo(tmp, m1.currency());
         return m1/tmp;
     } else {
         QL_FAIL("currency mismatch and no conversion specified");
     }
 }
开发者ID:SePTimO7,项目名称:QuantLib,代码行数:17,代码来源:money.cpp

示例4: close_enough

 bool close_enough(const Money& m1, const Money& m2, Size n) {
     if (m1.currency() == m2.currency()) {
         return close_enough(m1.value(),m2.value(),n);
     } else if (Money::conversionType == Money::BaseCurrencyConversion) {
         Money tmp1 = m1;
         convertToBase(tmp1);
         Money tmp2 = m2;
         convertToBase(tmp2);
         return close_enough(tmp1,tmp2,n);
     } else if (Money::conversionType == Money::AutomatedConversion) {
         Money tmp = m2;
         convertTo(tmp, m1.currency());
         return close_enough(m1,tmp,n);
     } else {
         QL_FAIL("currency mismatch and no conversion specified");
     }
 }
开发者ID:SePTimO7,项目名称:QuantLib,代码行数:17,代码来源:money.cpp

示例5: exchange

 Money ExchangeRate::exchange(const Money& amount) const {
     switch (type_) {
       case Direct:
         if (amount.currency() == source_)
             return Money(amount.value()*rate_, target_);
         else if (amount.currency() == target_)
             return Money(amount.value()/rate_, source_);
         else
             QL_FAIL("exchange rate not applicable");
       case Derived:
         if (amount.currency() == rateChain_.first->source() ||
             amount.currency() == rateChain_.first->target())
             return rateChain_.second->exchange(
                                      rateChain_.first->exchange(amount));
         else if (amount.currency() == rateChain_.second->source() ||
                    amount.currency() == rateChain_.second->target())
             return rateChain_.first->exchange(
                                      rateChain_.second->exchange(amount));
         else
             QL_FAIL("exchange rate not applicable");
       default:
         QL_FAIL("unknown exchange-rate type");
     }
 }
开发者ID:androidYibo,项目名称:documents,代码行数:24,代码来源:exchangerate.cpp


注:本文中的Money::currency方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。