QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
Classes | Related Functions | List of all members
Currency Class Reference

Currency specification More...

#include <currency.hpp>

+ Inheritance diagram for Currency:
+ Collaboration diagram for Currency:

Classes

struct  Data
 

Public Member Functions

Constructors
 Currency ()=default
 default constructor More...
 
 Currency (const std::string &name, const std::string &code, Integer numericCode, const std::string &symbol, const std::string &fractionSymbol, Integer fractionsPerUnit, const Rounding &rounding, const Currency &triangulationCurrency=Currency(), const std::set< std::string > &minorUnitCodes={})
 
QL_DEPRECATED Currency (const std::string &name, const std::string &code, Integer numericCode, const std::string &symbol, const std::string &fractionSymbol, Integer fractionsPerUnit, const Rounding &rounding, const std::string &formatString, const Currency &triangulationCurrency=Currency(), const std::set< std::string > &minorUnitCodes={})
 
Inspectors
const std::string & name () const
 currency name, e.g, "U.S. Dollar" More...
 
const std::string & code () const
 ISO 4217 three-letter code, e.g, "USD". More...
 
Integer numericCode () const
 ISO 4217 numeric code, e.g, "840". More...
 
const std::string & symbol () const
 symbol, e.g, "$" More...
 
const std::string & fractionSymbol () const
 fraction symbol, e.g, "¢" More...
 
Integer fractionsPerUnit () const
 number of fractionary parts in a unit, e.g, 100 More...
 
const Roundingrounding () const
 rounding convention More...
 
std::string format () const
 output format More...
 

Related Functions

(Note that these are not member functions.)

QL_DEPRECATED_ENABLE_WARNING bool operator== (const Currency &, const Currency &)
 
bool operator!= (const Currency &, const Currency &)
 
std::ostream & operator<< (std::ostream &, const Currency &)
 

Other information

ext::shared_ptr< Datadata_
 
bool empty () const
 is this a usable instance? More...
 
const CurrencytriangulationCurrency () const
 currency used for triangulated exchange when required More...
 
const std::set< std::string > & minorUnitCodes () const
 minor unit codes, e.g. GBp, GBX for GBP More...
 
void checkNonEmpty () const
 

Detailed Description

Currency specification

Definition at line 36 of file currency.hpp.

Constructor & Destructor Documentation

◆ Currency() [1/3]

Currency ( )
default

default constructor

Instances built via this constructor have undefined behavior. Such instances can only act as placeholders and must be reassigned to a valid currency before being used.

◆ Currency() [2/3]

Currency ( const std::string &  name,
const std::string &  code,
Integer  numericCode,
const std::string &  symbol,
const std::string &  fractionSymbol,
Integer  fractionsPerUnit,
const Rounding rounding,
const Currency triangulationCurrency = Currency(),
const std::set< std::string > &  minorUnitCodes = {} 
)

Definition at line 63 of file currency.cpp.

◆ Currency() [3/3]

Currency ( const std::string &  name,
const std::string &  code,
Integer  numericCode,
const std::string &  symbol,
const std::string &  fractionSymbol,
Integer  fractionsPerUnit,
const Rounding rounding,
const std::string &  formatString,
const Currency triangulationCurrency = Currency(),
const std::set< std::string > &  minorUnitCodes = {} 
)
Deprecated:
Use the constructor without formatString. Deprecated in version 1.33.

Definition at line 82 of file currency.cpp.

Member Function Documentation

◆ name()

const std::string & name ( ) const

currency name, e.g, "U.S. Dollar"

Definition at line 173 of file currency.hpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ code()

const std::string & code ( ) const

ISO 4217 three-letter code, e.g, "USD".

Definition at line 178 of file currency.hpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ numericCode()

Integer numericCode ( ) const

ISO 4217 numeric code, e.g, "840".

Definition at line 183 of file currency.hpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ symbol()

const std::string & symbol ( ) const

symbol, e.g, "$"

Definition at line 188 of file currency.hpp.

+ Here is the call graph for this function:

◆ fractionSymbol()

const std::string & fractionSymbol ( ) const

fraction symbol, e.g, "¢"

Definition at line 193 of file currency.hpp.

+ Here is the call graph for this function:

◆ fractionsPerUnit()

Integer fractionsPerUnit ( ) const

number of fractionary parts in a unit, e.g, 100

Definition at line 198 of file currency.hpp.

+ Here is the call graph for this function:

◆ rounding()

const Rounding & rounding ( ) const

rounding convention

Definition at line 203 of file currency.hpp.

+ Here is the call graph for this function:

◆ format()

QL_DEPRECATED_DISABLE_WARNING std::string format ( ) const

output format

The format will be fed three positional parameters, namely, value, code, and symbol, in this order.

Deprecated:
Copy the formatting into your project if you need it. Deprecated in version 1.33.

Definition at line 210 of file currency.hpp.

+ Here is the call graph for this function:

◆ empty()

is this a usable instance?

Definition at line 217 of file currency.hpp.

+ Here is the caller graph for this function:

◆ triangulationCurrency()

const Currency & triangulationCurrency ( ) const

currency used for triangulated exchange when required

Definition at line 221 of file currency.hpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ minorUnitCodes()

const std::set< std::string > & minorUnitCodes ( ) const

minor unit codes, e.g. GBp, GBX for GBP

Definition at line 226 of file currency.hpp.

+ Here is the call graph for this function:

◆ checkNonEmpty()

void checkNonEmpty ( ) const
private

Definition at line 169 of file currency.hpp.

+ Here is the caller graph for this function:

Friends And Related Function Documentation

◆ operator==()

QL_DEPRECATED_ENABLE_WARNING bool operator== ( const Currency ,
const Currency  
)
related

Definition at line 231 of file currency.hpp.

+ Here is the call graph for this function:

◆ operator!=()

bool operator!= ( const Currency ,
const Currency  
)
related

Definition at line 236 of file currency.hpp.

◆ operator<<()

std::ostream & operator<< ( std::ostream &  ,
const Currency  
)
related

Definition at line 25 of file currency.cpp.

+ Here is the call graph for this function:

Member Data Documentation

◆ data_

ext::shared_ptr<Data> data_
protected

Definition at line 108 of file currency.hpp.