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


C++ OTString::ToLong方法代码示例

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


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

示例1: ProcessXMLNode


//.........这里部分代码省略.........
		SetAssetID(ASSET_ID);
		SetCurrencyID(CURRENCY_TYPE_ID);
		// ------------------------------------
		const OTString strScale	= xml->getAttributeValue("marketScale");
		const int64_t lScale		= strScale.Exists() ? atol(strScale.Get()) : 0; // if it doesn't exist, the 0 here causes the below error to fire.
				
		if (false == isPowerOfTen( lScale ))
		{
			OTLog::vOutput(0, "OTOffer::ProcessXMLNode: Failure: marketScale *must* be 1, or a power of 10. Instead I got: %lld.\n",
						   lScale);
			return (-1);
		}
		else
			SetScale(lScale);
		// ------------------------------------
		const OTString strPriceLimit = xml->getAttributeValue("priceLimit");
		const int64_t lPriceLimit       = strPriceLimit.Exists() ? atol(strPriceLimit.Get()) : 0; // if it doesn't exist, the 0 here causes the below error to fire.
        
        // NOTE: Market Orders (new) have a 0 price, so this error condition was changed.
		if (!strPriceLimit.Exists())
//      if (lPriceLimit < 1)
		{
			OTLog::vOutput(0, "OTOffer::ProcessXMLNode: Failure: priceLimit *must* be provided.\n",
						   lPriceLimit);
			return (-1);
		}
		else
			SetPriceLimit(lPriceLimit);
		// ------------------------------------
		const OTString strTotal	= xml->getAttributeValue("totalAssetsOnOffer");
		const int64_t lTotal		= strTotal.Exists() ? atol(strTotal.Get()) : 0; // if it doesn't exist, the 0 here causes the below error to fire.
		if (lTotal < 1)
		{
			OTLog::vOutput(0, "OTOffer::ProcessXMLNode: Failure: totalAssetsOnOffer *must* be larger than 0. Instead I got: %lld.\n",
						   lTotal);
			return (-1);
		}
		else
			SetTotalAssetsOnOffer(lTotal);
		// ------------------------------------
		const OTString strFinished	= xml->getAttributeValue("finishedSoFar");
		const int64_t lFinished		= strFinished.Exists() ? atol(strFinished.Get()) : 0; // if it doesn't exist, the 0 here causes the below error to fire.
		if (lFinished < 0)
		{
			OTLog::vOutput(0, "OTOffer::ProcessXMLNode: Failure: finishedSoFar *must* be 0 or larger. Instead I got: %lld.\n",
						   lFinished);
			return (-1);
		}
		else
			SetFinishedSoFar(lFinished);
		// ------------------------------------
		const OTString	strMinInc	= xml->getAttributeValue("minimumIncrement");
		const int64_t		lMinInc		= strMinInc.Exists() ? atol(strMinInc.Get()) : 0; // if it doesn't exist, the 0 here causes the below error to fire.
		if ((lMinInc < 1) || (lMinInc > lTotal)) // Minimum increment cannot logically be higher than the total assets on offer...
		{
			OTLog::vOutput(0, "OTOffer::ProcessXMLNode: Failure: minimumIncrement *must* be 1 or larger, \n"
						   "and must also be less than the total assets on offer. Instead I got: %lld.\n",
						   lMinInc);
			return (-1);
		}
		else
			SetMinimumIncrement(lMinInc);
		// -----------------------------------
		const OTString strTransNum = xml->getAttributeValue("transactionNum");
		const int64_t lTransNum = strTransNum.Exists() ? atol(strTransNum.Get()) : 0;
		
		SetTransactionNum(lTransNum);
		// ----------------------------------------------------------------
        const OTString str_valid_from = xml->getAttributeValue("validFrom");
        const OTString str_valid_to   = xml->getAttributeValue("validTo");
        
        int64_t tValidFrom  = str_valid_from.Exists() ? str_valid_from.ToLong() : 0;
		int64_t tValidTo    = str_valid_to.Exists  () ? str_valid_to.ToLong()   : 0;
        
		if ((tValidTo < tValidFrom) && (tValidTo != 0))
		{
			OTLog::vOutput(0, "OTOffer::%s: Failure: validTo date (%" PRId64") cannot be earlier than "
                           "validFrom date (%" PRId64").\n", __FUNCTION__, tValidFrom, tValidTo);
			return (-1);
		}
        // ----------------------------------------------------------------
        SetValidFrom(OTTimeGetTimeFromSeconds(tValidFrom));
        SetValidTo(OTTimeGetTimeFromSeconds(tValidTo));
		// ----------------------------------------------------------------
		OTLog::vOutput(4,
					   "\n\nOffer. Transaction Number: %lld\n Valid From: %" PRId64"\n Valid To: %" PRId64"\n"
					   " AssetTypeID: %s\n  CurrencyTypeID: %s\n ServerID: %s\n"
					   " Price Limit: %lld,  Total Assets on Offer: %lld,  %s so far: %lld\n "
					   " Scale: %lld.   Minimum Increment: %lld.  This offer is a%s.\n", 
					   m_lTransactionNum, tValidFrom, tValidTo,
					   strAssetTypeID.Get(), strCurrencyTypeID.Get(), strServerID.Get(),
					   GetPriceLimit(), GetTotalAssetsOnOffer(),  (m_bSelling ? "sold" : "bought"), 
					   GetFinishedSoFar(), GetScale(), GetMinimumIncrement(), 
					   (m_bSelling ? "n ASK" : " BID"));
        // ----------------------------------------------------------------
		nReturnVal = 1;
	}
    // ----------------
	return nReturnVal;
}
开发者ID:Guratri,项目名称:Open-Transactions,代码行数:101,代码来源:OTOffer.cpp


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