本文整理汇总了C++中Currency::data方法的典型用法代码示例。如果您正苦于以下问题:C++ Currency::data方法的具体用法?C++ Currency::data怎么用?C++ Currency::data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Currency
的用法示例。
在下文中一共展示了Currency::data方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: to_string
std::string to_string(Currency const& currency)
{
static Currency const sIsoBits ("FFFFFFFFFFFFFFFFFFFFFFFF000000FFFFFFFFFF");
// Characters we are willing to allow in the ASCII representation of a
// three-letter currency code.
static std::string const allowed_characters =
"abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"0123456789"
"<>(){}[]|[email protected]#$%^&*";
if (currency == zero)
return systemCurrencyCode();
if (currency == vbcCurrency())
return systemCurrencyCodeVBC();
if (currency == noCurrency())
return "1";
if ((currency & sIsoBits).isZero ())
{
// The offset of the 3 character ISO code in the currency descriptor
int const isoOffset = 12;
std::string const iso(
currency.data () + isoOffset,
currency.data () + isoOffset + 3);
// Specifying the system currency code using ISO-style representation
// is not allowed.
if ((iso != systemCurrencyCode()) && (iso != systemCurrencyCodeVBC()) &&
(iso.find_first_not_of (allowed_characters) == std::string::npos))
{
return iso;
}
}
return strHex (currency.begin (), currency.size ());
}