GnuCash c935c2f+
Loading...
Searching...
No Matches
Public Member Functions
GncQuotes Class Reference

Public Member Functions

 GncQuotes ()
 Create a GncQuotes object.
 
void fetch (QofBook *book)
 Fetch quotes for all commodities in our db that have a quote source set.
 
void fetch (CommVec &commodities)
 Fetch quotes for a vector of commodities.
 
void fetch (gnc_commodity *comm)
 Fetch quote for a single commodity.
 
void report (const char *source, const StrVec &commodities, bool verbose=false)
 Report quote results from Finance::Quote to std::cout.
 
const std::string & version () noexcept
 Get the installed Finance::Quote version.
 
const QuoteSources & sources () noexcept
 Get the available Finance::Quote sources as a std::vector.
 
bool had_failures () noexcept
 Report if there were quotes requested but not retrieved.
 
const QFVec & failures () noexcept
 Report the commodities for which quotes were requested but not successfully retrieved.
 
const std::string report_failures () noexcept
 

Detailed Description

Definition at line 65 of file gnc-quotes.hpp.

Constructor & Destructor Documentation

◆ GncQuotes()

GncQuotes::GncQuotes ( )

Create a GncQuotes object.

Throws a GncQuoteException if Finance::Quote is not installed or fails to initialize.

Definition at line 1061 of file gnc-quotes.cpp.

1062{
1063 try
1064 {
1065 m_impl = std::make_unique<GncQuotesImpl>();
1066 } catch (const GncQuoteSourceError &err) {
1067 throw(GncQuoteException(err.what()));
1068 }
1069}

Member Function Documentation

◆ failures()

const QFVec & GncQuotes::failures ( )
noexcept

Report the commodities for which quotes were requested but not successfully retrieved.

This does not include requested commodities that didn't have a quote source.

Returns
a reference to a vector of QuoteFailure tuples.
Note
The vector and its contents belong to the GncQuotes object and will be destroyed with it.

Definition at line 1113 of file gnc-quotes.cpp.

1114{
1115 return m_impl->failures();
1116}

◆ fetch() [1/3]

void GncQuotes::fetch ( CommVec &  commodities)

Fetch quotes for a vector of commodities.

Parameters
commoditiesstd::vector of the gnc_commodity* to get quotes for.
Note
Commodities without a quote source will be silently ignored.

Definition at line 1078 of file gnc-quotes.cpp.

1079{
1080 m_impl->fetch (commodities);
1081}

◆ fetch() [2/3]

void GncQuotes::fetch ( gnc_commodity *  comm)

Fetch quote for a single commodity.

Parameters
commCommodity for which to retrieve a quote
Note
Commodity must have a quote source set or the call will silently fail.

Definition at line 1083 of file gnc-quotes.cpp.

1084{
1085 m_impl->fetch (comm);
1086}

◆ fetch() [3/3]

void GncQuotes::fetch ( QofBook book)

Fetch quotes for all commodities in our db that have a quote source set.

Parameters
bookThe current book.

Definition at line 1073 of file gnc-quotes.cpp.

1074{
1075 m_impl->fetch (book);
1076}

◆ had_failures()

bool GncQuotes::had_failures ( )
noexcept

Report if there were quotes requested but not retrieved.

Returns
True if there were quote failures.

Definition at line 1107 of file gnc-quotes.cpp.

1108{
1109 return m_impl->had_failures();
1110}

◆ report()

void GncQuotes::report ( const char *  source,
const StrVec &  commodities,
bool  verbose = false 
)

Report quote results from Finance::Quote to std::cout.

Parameters
sourceA valid quote source
commoditiesA std::vector of symbols to request quotes for.
Note
If requesting currency rates the first symbol is the to-currency and the rest are from-currencies. For example, {"USD", "EUR", "CAD"} will print the price of 1 Euro and 1 Canadian Dollar in US Dollars.
Parameters
verboseIgnored for currency queries. If false it will print the six fields GnuCash uses regardless of whether a value was returned; if true it will print all of the fields for which Finanace::Quote returned values.

Definition at line 1088 of file gnc-quotes.cpp.

1090{
1091 m_impl->report(source, commodities, verbose);
1092}

◆ report_failures()

const std::string GncQuotes::report_failures ( )
noexcept

Definition at line 1119 of file gnc-quotes.cpp.

1120{
1121 return m_impl->report_failures();
1122}

◆ sources()

const QuoteSources & GncQuotes::sources ( )
noexcept

Get the available Finance::Quote sources as a std::vector.

Returns
The quote sources configured in Finance::Quote

Definition at line 1099 of file gnc-quotes.cpp.

1100{
1101 return m_impl->sources ();
1102}

◆ version()

const std::string & GncQuotes::version ( )
noexcept

Get the installed Finance::Quote version.

Returns
the Finance::Quote version string

Definition at line 1094 of file gnc-quotes.cpp.

1095{
1096 return m_impl->version ();
1097}

The documentation for this class was generated from the following files: