GnuCash  5.0
Files | Data Structures | Typedefs | Enumerations | Enumerator | Functions | Variables

GnuCash Options System for Book, Report, and Stylesheet Options. More...

Files

file  gnc-option-date.hpp
 Relative date enumeration and manipulation functions.
 
file  gnc-option-impl.hpp
 Implementation templates and specializtions for GncOption values.
 
file  gnc-option-uitype.hpp
 OptionUITypes.
 
file  gnc-option.hpp
 C++ Public interface for individual options.
 
file  gnc-optiondb-impl.hpp
 Implementation details for GncOptionDB.
 
file  gnc-optiondb.h
 C public interface for the Options Database.
 
file  gnc-optiondb.hpp
 The primary C++ interface to options for books, reports, and stylesheets.
 

Data Structures

struct  OptionClassifier
 This class is the parent of all option implementations. More...
 
class  GncOptionValue< ValueType >
 The generic option-value class. More...
 
struct  GncOwnerDeleter
 class GncOptionGncOwnerValue More...
 
class  GncOptionGncOwnerValue
 
class  GncOptionQofInstanceValue
 
class  GncOptionCommodityValue
 class GncOptionCommodityValue Commodities are stored with their namespace and mnemonic instead of their gncGUID so that they can be correctly retrieved even if they're deleted and recreated. More...
 
struct  is_GncOwnerValue< T >
 
struct  is_QofInstanceValue< T >
 
struct  is_QofQueryValue< T >
 
class  GncOptionRangeValue< ValueType >
 Used for numeric ranges and plot sizes. More...
 
class  GncOptionMultichoiceValue
 Multichoice options have a vector of valid options (GncMultichoiceOptionChoices) and validate the selection as being one of those values. More...
 
class  GncOptionAccountListValue
 Set one or more accounts on which to report, optionally restricted to certain account types. More...
 
class  GncOptionAccountSelValue
 
class  GncOptionDateValue
 A legal date value is a pair of either a RelativeDatePeriod, the absolute flag and a time64, or for legacy purposes the absolute flag and a timespec. More...
 
struct  is_OptionClassifier< T >
 
struct  is_same_decayed< T, U >
 
struct  is_RangeValue< T >
 
class  GncOption
 Represents the public interface for an option. More...
 
class  GncOptionSection
 class GncOptionSection The upper-level classification implementation. More...
 
struct  GncOptionDBCallback
 
class  GncOptionDB
 Holds all of the options for a book, report, or stylesheet, organized by GncOptionSections. More...
 

Typedefs

using RelativeDatePeriodVec = std::vector< RelativeDatePeriod >
 
using GncOwnerPtr = std::unique_ptr< GncOwner, GncOwnerDeleter >
 
using GncItem = std::pair< QofIdTypeConst, GncGUID >
 class GncOptionQofinstanceValue More...
 
using GncMultichoiceOptionEntry = std::tuple< const std::string, const std::string, GncOptionMultichoiceKeyType >
 
using GncMultichoiceOptionIndexVec = std::vector< uint16_t >
 
using GncMultichoiceOptionChoices = std::vector< GncMultichoiceOptionEntry >
 
using GncOptionAccountList = std::vector< GncGUID >
 
using GncOptionAccountTypeList = std::vector< GNCAccountType >
 
using GncOptionUIItemPtr = std::unique_ptr< GncOptionUIItem >
 
using GncOwner = _gncOwner
 
using QofQuery = _QofQuery
 A Query.
 
using QofInstance = QofInstance_s
 
using GncOptionReportPlacement = std::tuple< uint32_t, uint32_t, uint32_t >
 
using GncOptionReportPlacementVec = std::vector< GncOptionReportPlacement >
 
using GncOptionVariant = std::variant< GncOptionValue< std::string >, GncOptionValue< bool >, GncOptionValue< int64_t >, GncOptionQofInstanceValue, GncOptionGncOwnerValue, GncOptionValue< const QofQuery * >, GncOptionValue< GncOptionReportPlacementVec >, GncOptionAccountListValue, GncOptionAccountSelValue, GncOptionMultichoiceValue, GncOptionRangeValue< int >, GncOptionRangeValue< double >, GncOptionCommodityValue, GncOptionDateValue >
 
using GncOptionVariantPtr = std::unique_ptr< GncOptionVariant >
 
using GncOptionVec = std::vector< GncOption >
 
using GncOptionSectionPtr = std::shared_ptr< GncOptionSection >
 
using GncOptionDBChangeCallback = void(*)(void *user_data)
 
using GncCallbackVec = std::vector< GncOptionDBCallback >
 
using GncOptionDBPtr = std::unique_ptr< GncOptionDB >
 
using GncOptionAccountList = std::vector< GncGUID >
 
using GncOptionAccountTypeList = std::vector< GNCAccountType >
 
using GncMultichoiceOptionEntry = std::tuple< const std::string, const std::string, GncOptionMultichoiceKeyType >
 
using GncMultichoiceOptionChoices = std::vector< GncMultichoiceOptionEntry >
 

Enumerations

enum  RelativeDatePeriod : int {
  ABSOLUTE = -1, TODAY, ONE_WEEK_AGO, ONE_WEEK_AHEAD,
  ONE_MONTH_AGO, ONE_MONTH_AHEAD, THREE_MONTHS_AGO, THREE_MONTHS_AHEAD,
  SIX_MONTHS_AGO, SIX_MONTHS_AHEAD, ONE_YEAR_AGO, ONE_YEAR_AHEAD,
  START_THIS_MONTH, END_THIS_MONTH, START_PREV_MONTH, END_PREV_MONTH,
  START_NEXT_MONTH, END_NEXT_MONTH, START_CURRENT_QUARTER, END_CURRENT_QUARTER,
  START_PREV_QUARTER, END_PREV_QUARTER, START_NEXT_QUARTER, END_NEXT_QUARTER,
  START_CAL_YEAR, END_CAL_YEAR, START_PREV_YEAR, END_PREV_YEAR,
  START_NEXT_YEAR, END_NEXT_YEAR, START_ACCOUNTING_PERIOD, END_ACCOUNTING_PERIOD
}
 Reporting periods relative to the current date. More...
 
enum  GncOptionUIType : unsigned int {
  INTERNAL, BOOLEAN, STRING, TEXT,
  CURRENCY, COMMODITY, MULTICHOICE, DATE_ABSOLUTE,
  DATE_RELATIVE, DATE_BOTH, ACCOUNT_LIST, ACCOUNT_SEL,
  LIST, NUMBER_RANGE, COLOR, FONT,
  PLOT_SIZE, BUDGET, PIXMAP, RADIOBUTTON,
  DATE_FORMAT, OWNER, CUSTOMER, VENDOR,
  EMPLOYEE, INVOICE, JOB, TAX_TABLE,
  INV_REPORT, QUERY, REPORT_PLACEMENT, MAX_VALUE
}
 Used by GncOptionClassifier to indicate to dialog-options what control should be displayed for the option.
 
enum  GncOptionMultichoiceKeyType { SYMBOL, STRING, NUMBER }
 
enum  RelativeDateUI : uint8_t { ABSOLUTE, RELATIVE, BOTH }
 

Functions

bool gnc_relative_date_is_single (RelativeDatePeriod)
 Report whether the relative date represents a period offset to today's date rather than the beginning or end of a date range. More...
 
bool gnc_relative_date_is_starting (RelativeDatePeriod)
 Report whether the relative date represents the beginning of a date range. More...
 
bool gnc_relative_date_is_ending (RelativeDatePeriod)
 Report whether the relative date represents the end of a date range. More...
 
const char * gnc_relative_date_storage_string (RelativeDatePeriod)
 Provide the string representation of a relative date for persisting the value. More...
 
const char * gnc_relative_date_display_string (RelativeDatePeriod)
 Provide the string representation of a relative date for displaying value to a user. More...
 
const char * gnc_relative_date_description (RelativeDatePeriod)
 Provide the description of a relative date. More...
 
RelativeDatePeriod gnc_relative_date_from_storage_string (const char *)
 Convert a relative date storage string back to a RelativeDatePeriod value. More...
 
time64 gnc_relative_date_to_time64 (RelativeDatePeriod)
 Convert a RelativeDatePeriod value to a concrete time64 by applying the value to the current time. More...
 
std::ostream & operator<< (std::ostream &, const RelativeDatePeriod)
 Add the display string to the provided std::ostream. More...
 
QofInstanceqof_instance_from_string (const std::string &str, GncOptionUIType type)
 
QofInstanceqof_instance_from_guid (GncGUID *, GncOptionUIType type)
 
std::string qof_instance_to_string (const QofInstance *inst)
 
template<class OptType , typename std::enable_if_t< is_OptionClassifier_v< OptType > &&!(is_QofInstanceValue_v< OptType >||is_RangeValue_v< OptType >), int > = 0>
std::ostream & operator<< (std::ostream &oss, const OptType &opt)
 
template<>
std::ostream & operator<<< GncOptionValue< bool >> (std::ostream &oss, const GncOptionValue< bool > &opt)
 
std::ostream & operator<< (std::ostream &oss, const GncOptionCommodityValue &opt)
 
template<class OptType , typename std::enable_if_t< is_OptionClassifier_v< OptType > &&!(is_QofInstanceValue_v< OptType >||is_RangeValue_v< OptType >), int > = 0>
std::istream & operator>> (std::istream &iss, OptType &opt)
 
std::istream & operator>> (std::istream &iss, GncOptionCommodityValue &opt)
 
template<>
std::istream & operator>>< GncOptionValue< bool >> (std::istream &iss, GncOptionValue< bool > &opt)
 
template<>
std::istream & operator>>< GncOptionValue< GncOptionReportPlacementVec >> (std::istream &iss, GncOptionValue< GncOptionReportPlacementVec > &opt)
 
template<>
std::ostream & operator<<< GncOptionMultichoiceValue > (std::ostream &oss, const GncOptionMultichoiceValue &opt)
 
template<>
std::istream & operator>>< GncOptionMultichoiceValue > (std::istream &iss, GncOptionMultichoiceValue &opt)
 
template<>
std::ostream & operator<<< GncOptionAccountListValue > (std::ostream &oss, const GncOptionAccountListValue &opt)
 
template<>
std::istream & operator>>< GncOptionAccountListValue > (std::istream &iss, GncOptionAccountListValue &opt)
 
template<>
std::ostream & operator<<< GncOptionAccountSelValue > (std::ostream &oss, const GncOptionAccountSelValue &opt)
 
template<>
std::istream & operator>>< GncOptionAccountSelValue > (std::istream &iss, GncOptionAccountSelValue &opt)
 
template<>
std::ostream & operator<<< GncOptionDateValue > (std::ostream &oss, const GncOptionDateValue &opt)
 
template<>
std::istream & operator>>< GncOptionDateValue > (std::istream &iss, GncOptionDateValue &opt)
 
bool operator< (const GncOption &right, const GncOption &left)
 
std::ostream & operator<< (std::ostream &oss, const GncOption &opt)
 
std::istream & operator>> (std::istream &iss, GncOption &opt)
 
std::ostream & output_color_value (std::ostream &oss, const std::string &value)
 
template<typename ValueType >
GncOptiongnc_make_option (const char *section, const char *name, const char *key, const char *doc_string, ValueType value, GncOptionUIType ui_type)
 Free function wrapping GncOption's constructor. More...
 
bool operator< (const GncOptionSectionPtr &right, const GncOptionSectionPtr &left)
 
GncOptionDBgnc_option_db_new (void)
 Create an empty option database. More...
 
void gnc_option_db_destroy (GncOptionDB *odb)
 Destruct and release a GncOptionDB. More...
 
GList * gnc_option_db_commit (GncOptionDB *odb)
 Write all changed ui_item values to their options. More...
 
void gnc_option_db_clean (GncOptionDB *odb)
 Reset all ui_items to the option value. More...
 
void gnc_option_db_load (GncOptionDB *odb, QofBook *book)
 Load a book's options into the GncOptionDB. More...
 
void gnc_option_db_save (GncOptionDB *odb, QofBook *book, gboolean clear_options)
 Save the GncOptionDB contents into a book's options store. More...
 
void gnc_option_db_book_options (GncOptionDB *)
 Register the standard option set for a QofBook. More...
 
const QofInstancegnc_option_db_lookup_qofinstance_value (GncOptionDB *, const char *, const char *)
 Retrieve the QofInstance value of an option in the GncOptionDB. More...
 
GncOptionAccountList gnc_account_list_from_types (QofBook *book, const GncOptionAccountTypeList &types)
 Extract a list of accounts in the book having one of the GNCAccountTypes in types. More...
 
void gnc_register_string_option (GncOptionDB *db, const char *section, const char *name, const char *key, const char *doc_string, std::string value)
 Create a new string option and register it in the options database. More...
 
void gnc_register_string_option (const GncOptionDBPtr &db, const char *section, const char *name, const char *key, const char *doc_string, std::string value)
 As above but takes a const GncOptionDBPtr& (const std::unique_ptr<GncOptionDB>&) for calling from C++.
 
void gnc_register_text_option (GncOptionDB *db, const char *section, const char *name, const char *key, const char *doc_string, std::string value)
 Create a new text option and register it in the options database. More...
 
void gnc_register_text_option (const GncOptionDBPtr &db, const char *section, const char *name, const char *key, const char *doc_string, std::string value)
 As above but takes a const GncOptionDBPtr& (const std::unique_ptr<GncOptionDB>&) for calling from C++.
 
void gnc_register_font_option (GncOptionDB *db, const char *section, const char *name, const char *key, const char *doc_string, std::string value)
 Create a new font option and register it in the options database. More...
 
void gnc_register_font_option (const GncOptionDBPtr &db, const char *section, const char *name, const char *key, const char *doc_string, std::string value)
 As above but takes a const GncOptionDBPtr& (const std::unique_ptr<GncOptionDB>&) for calling from C++.
 
void gnc_register_budget_option (GncOptionDB *db, const char *section, const char *name, const char *key, const char *doc_string, GncBudget *value)
 Create a new budget option and register it in the options database. More...
 
void gnc_register_budget_option (const GncOptionDBPtr &db, const char *section, const char *name, const char *key, const char *doc_string, GncBudget *value)
 As above but takes a const GncOptionDBPtr& (const std::unique_ptr<GncOptionDB>&) for calling from C++.
 
void gnc_register_commodity_option (GncOptionDB *db, const char *section, const char *name, const char *key, const char *doc_string, gnc_commodity *value)
 Create a new commodity option and register it in the options database. More...
 
void gnc_register_commodity_option (const GncOptionDBPtr &db, const char *section, const char *name, const char *key, const char *doc_string, gnc_commodity *value)
 As above but takes a const GncOptionDBPtr& (const std::unique_ptr<GncOptionDB>&) for calling from C++.
 
void gnc_register_commodity_option (GncOptionDB *db, const char *section, const char *name, const char *key, const char *doc_string, const char *value)
 As above but with a const char* value, which should be the symbol for the commodity. More...
 
void gnc_register_commodity_option (const GncOptionDBPtr &db, const char *section, const char *name, const char *key, const char *doc_string, const char *value)
 As above but takes a const GncOptionDBPtr& (const std::unique_ptr<GncOptionDB>&) for calling from C++.
 
void gnc_register_simple_boolean_option (GncOptionDB *db, const char *section, const char *name, const char *key, const char *doc_string, bool value)
 Create a new simple boolean option and register it in the options database. More...
 
void gnc_register_simple_boolean_option (const GncOptionDBPtr &db, const char *section, const char *name, const char *key, const char *doc_string, bool value)
 As above but takes a const GncOptionDBPtr& (const std::unique_ptr<GncOptionDB>&) for calling from C++.
 
void gnc_register_pixmap_option (GncOptionDB *db, const char *section, const char *name, const char *key, const char *doc_string, std::string value)
 Create a new pixmap option and register it in the options database. More...
 
void gnc_register_pixmap_option (GncOptionDBPtr &db, const char *section, const char *name, const char *key, const char *doc_string, std::string value)
 As above but takes a const GncOptionDBPtr& (const std::unique_ptr<GncOptionDB>&) for calling from C++.
 
void gnc_register_account_list_limited_option (GncOptionDB *db, const char *section, const char *name, const char *key, const char *doc_string, const GncOptionAccountList &value, GncOptionAccountTypeList &&allowed)
 Create a new limited account list option and register it in the options database. More...
 
void gnc_register_account_list_limited_option (GncOptionDBPtr &db, const char *section, const char *name, const char *key, const char *doc_string, const GncOptionAccountList &value, GncOptionAccountTypeList &&allowed)
 As above but takes a const GncOptionDBPtr& (const std::unique_ptr<GncOptionDB>&) for calling from C++.
 
void gnc_register_account_list_option (GncOptionDB *db, const char *section, const char *name, const char *key, const char *doc_string, const GncOptionAccountList &value)
 Create a new account list option and register it in the options database. More...
 
void gnc_register_account_list_option (GncOptionDBPtr &db, const char *section, const char *name, const char *key, const char *doc_string, const GncOptionAccountList &value)
 As above but takes a const GncOptionDBPtr& (const std::unique_ptr<GncOptionDB>&) for calling from C++.
 
void gnc_register_account_sel_limited_option (GncOptionDB *db, const char *section, const char *name, const char *key, const char *doc_string, const Account *value, GncOptionAccountTypeList &&allowed)
 Create a limited account selection option and register it in the options database. More...
 
void gnc_register_account_sel_limited_option (GncOptionDBPtr &db, const char *section, const char *name, const char *key, const char *doc_string, const Account *value, GncOptionAccountTypeList &&allowed)
 As above but takes a const GncOptionDBPtr& (const std::unique_ptr<GncOptionDB>&) for calling from C++.
 
void gnc_register_multichoice_option (GncOptionDB *db, const char *section, const char *name, const char *key, const char *doc_string, const char *default_val, GncMultichoiceOptionChoices &&value)
 Create a new multichoice option and register it in the options database. More...
 
void gnc_register_multichoice_option (GncOptionDBPtr &db, const char *section, const char *name, const char *key, const char *doc_string, const char *default_val, GncMultichoiceOptionChoices &&value)
 As above but takes a const GncOptionDBPtr& (const std::unique_ptr<GncOptionDB>&) for calling from C++.
 
void gnc_register_list_option (GncOptionDB *db, const char *section, const char *name, const char *key, const char *doc_string, const char *value, GncMultichoiceOptionChoices &&list)
 Create a new list option and register it in the options database. More...
 
void gnc_register_list_option (GncOptionDBPtr &db, const char *section, const char *name, const char *key, const char *doc_string, const char *value, GncMultichoiceOptionChoices &&list)
 As above but takes a const GncOptionDBPtr& (const std::unique_ptr<GncOptionDB>&) for calling from C++.
 
template<typename ValueType >
void gnc_register_number_range_option (GncOptionDB *db, const char *section, const char *name, const char *key, const char *doc_string, ValueType value, ValueType min, ValueType max, ValueType step)
 Create a new number range option and register it in the options database. More...
 
template<typename ValueType >
void gnc_register_number_range_option (GncOptionDBPtr &db, const char *section, const char *name, const char *key, const char *doc_string, ValueType value, ValueType min, ValueType max, ValueType step)
 As above but takes a const GncOptionDBPtr& (const std::unique_ptr<GncOptionDB>&) for calling from C++.
 
void gnc_register_number_plot_size_option (GncOptionDB *db, const char *section, const char *name, const char *key, const char *doc_string, int value)
 Create a new plot-size option and register it in the options database. More...
 
void gnc_register_number_plot_size_option (GncOptionDB *db, const char *section, const char *name, const char *key, const char *doc_string, float value)
 
void gnc_register_number_plot_size_option (const GncOptionDBPtr &db, const char *section, const char *name, const char *key, const char *doc_string, int value)
 As above but takes a const GncOptionDBPtr& (const std::unique_ptr<GncOptionDB>&) for calling from C++.
 
void gnc_register_number_plot_size_option (const GncOptionDBPtr &db, const char *section, const char *name, const char *key, const char *doc_string, float value)
 
void gnc_register_query_option (GncOptionDB *db, const char *section, const char *name, const QofQuery *value)
 Create a new QofQuery option and register it in the options database. More...
 
void gnc_register_query_option (GncOptionDBPtr &db, const char *section, const char *name, const QofQuery *value)
 As above but takes a const GncOptionDBPtr& (const std::unique_ptr<GncOptionDB>&) for calling from C++.
 
void gnc_register_owner_option (GncOptionDB *db, const char *section, const char *name, const char *key, const char *doc_string, const GncOwner *value, GncOwnerType type)
 Create a new GncOwner option and register it in the options database. More...
 
void gnc_register_owner_option (GncOptionDBPtr &db, const char *section, const char *name, const char *key, const char *doc_string, const GncOwner *value, GncOwnerType type)
 As above but takes a const GncOptionDBPtr& (const std::unique_ptr<GncOptionDB>&) for calling from C++.
 
void gnc_register_color_option (GncOptionDB *db, const char *section, const char *name, const char *key, const char *doc_string, std::string value)
 Create a new color option and register it in the options database. More...
 
void gnc_register_color_option (GncOptionDBPtr &db, const char *section, const char *name, const char *key, const char *doc_string, std::string value)
 As above but takes a const GncOptionDBPtr& (const std::unique_ptr<GncOptionDB>&) for calling from C++.
 
void gnc_register_internal_option (GncOptionDBPtr &db, const char *section, const char *name, const std::string &value)
 
void gnc_register_internal_option (GncOptionDBPtr &db, const char *section, const char *name, bool value)
 
void gnc_register_report_placement_option (GncOptionDBPtr &db, const char *section, const char *name)
 
void gnc_register_currency_option (GncOptionDB *db, const char *section, const char *name, const char *key, const char *doc_string, gnc_commodity *value)
 Create a new currency option and register it in the options database. More...
 
void gnc_register_currency_option (const GncOptionDBPtr &db, const char *section, const char *name, const char *key, const char *doc_string, gnc_commodity *value)
 As above but takes a const GncOptionDBPtr& (const std::unique_ptr<GncOptionDB>&) for calling from C++.
 
void gnc_register_currency_option (GncOptionDB *db, const char *section, const char *name, const char *key, const char *doc_string, const char *value)
 As above but with a const char* value, which must be the ISO4217 three-letter symbol for the currency.
 
void gnc_register_currency_option (const GncOptionDBPtr &db, const char *section, const char *name, const char *key, const char *doc_string, const char *value)
 
void gnc_register_invoice_option (GncOptionDB *db, const char *section, const char *name, const char *key, const char *doc_string, GncInvoice *value)
 Create a new invoice option and register it in the options database. More...
 
void gnc_register_invoice_option (const GncOptionDBPtr &db, const char *section, const char *name, const char *key, const char *doc_string, GncInvoice *value)
 As above but takes a const GncOptionDBPtr& (const std::unique_ptr<GncOptionDB>&) for calling from C++.
 
void gnc_register_taxtable_option (GncOptionDB *db, const char *section, const char *name, const char *key, const char *doc_string, GncTaxTable *value)
 Create a new taxtable option and register it in the options database. More...
 
void gnc_register_taxtable_option (const GncOptionDBPtr &db, const char *section, const char *name, const char *key, const char *doc_string, GncTaxTable *value)
 As above but takes a const GncOptionDBPtr& (const std::unique_ptr<GncOptionDB>&) for calling from C++.
 
void gnc_register_invoice_print_report_option (GncOptionDB *db, const char *section, const char *name, const char *key, const char *doc_string, std::string value)
 Create a new print report option and register it in the options database. More...
 
void gnc_register_invoice_print_report_option (const GncOptionDBPtr &db, const char *section, const char *name, const char *key, const char *doc_string, std::string value)
 As above but takes a const GncOptionDBPtr& (const std::unique_ptr<GncOptionDB>&) for calling from C++.
 
void gnc_register_counter_option (GncOptionDB *db, const char *section, const char *name, const char *key, const char *doc_string, double value)
 Create a new counter option and register it in the options database. More...
 
void gnc_register_counter_option (const GncOptionDBPtr &db, const char *section, const char *name, const char *key, const char *doc_string, double value)
 As above but takes a const GncOptionDBPtr& (const std::unique_ptr<GncOptionDB>&) for calling from C++.
 
void gnc_register_counter_format_option (GncOptionDB *db, const char *section, const char *name, const char *key, const char *doc_string, std::string value)
 Create a new counter format option and register it in the options database. More...
 
void gnc_register_counter_format_option (GncOptionDBPtr &db, const char *section, const char *name, const char *key, const char *doc_string, std::string value)
 As above but takes a const GncOptionDBPtr& (const std::unique_ptr<GncOptionDB>&) for calling from C++.
 
void gnc_register_dateformat_option (GncOptionDB *db, const char *section, const char *name, const char *key, const char *doc_string, std::string value)
 Create a new date format option and register it in the options database. More...
 
void gnc_register_dateformat_option (GncOptionDBPtr &db, const char *section, const char *name, const char *key, const char *doc_string, std::string value)
 As above but takes a const GncOptionDBPtr& (const std::unique_ptr<GncOptionDB>&) for calling from C++.
 
void gnc_register_date_option (GncOptionDB *db, const char *section, const char *name, const char *key, const char *doc_string, RelativeDatePeriod period=RelativeDatePeriod::TODAY, RelativeDateUI ui=RelativeDateUI::BOTH)
 Create a new date option and register it in the options database. More...
 
void gnc_register_date_option (GncOptionDBPtr &db, const char *section, const char *name, const char *key, const char *doc_string, RelativeDatePeriod period=RelativeDatePeriod::TODAY, RelativeDateUI ui=RelativeDateUI::BOTH)
 As above but takes a const GncOptionDBPtr& (const std::unique_ptr<GncOptionDB>&) for calling from C++.
 
void gnc_register_date_option (GncOptionDB *db, const char *section, const char *name, const char *key, const char *doc_string, time64 time, RelativeDateUI ui=RelativeDateUI::BOTH)
 Create a new date option and register it in the options database. More...
 
void gnc_register_date_option (GncOptionDBPtr &db, const char *section, const char *name, const char *key, const char *doc_string, time64 time, RelativeDateUI ui=RelativeDateUI::BOTH)
 As above but takes a const GncOptionDBPtr& (const std::unique_ptr<GncOptionDB>&) for calling from C++.
 
void gnc_register_date_option (GncOptionDB *db, const char *section, const char *name, const char *key, const char *doc_string, RelativeDatePeriodVec &period_set, bool both=true)
 Create a new date option and register it in the options database. More...
 
void gnc_register_date_option (GncOptionDBPtr &db, const char *section, const char *name, const char *key, const char *doc_string, RelativeDatePeriodVec &period_set, bool both=true)
 As above but takes a const GncOptionDBPtr& (const std::unique_ptr<GncOptionDB>&) for calling from C++.
 
void gnc_register_start_date_option (GncOptionDB *db, const char *section, const char *name, const char *key, const char *doc_string, bool both=true)
 Create a new start-date option and register it in the options database. More...
 
void gnc_register_start_date_option (GncOptionDBPtr &db, const char *section, const char *name, const char *key, const char *doc_string, bool both=true)
 As above but takes a const GncOptionDBPtr& (const std::unique_ptr<GncOptionDB>&) for calling from C++.
 
void gnc_register_end_date_option (GncOptionDB *db, const char *section, const char *name, const char *key, const char *doc_string, bool both=true)
 Create a new end-date option and register it in the options database. More...
 
void gnc_register_end_date_option (GncOptionDBPtr &db, const char *section, const char *name, const char *key, const char *doc_string, bool both=true)
 As above but takes a const GncOptionDBPtr& (const std::unique_ptr<GncOptionDB>&) for calling from C++.
 

Variables

constexpr unsigned relative_date_periods
 
size_t constexpr classifier_size_max {50}
 
size_t constexpr sort_tag_size_max {10}
 
auto constexpr uint16_t_max = std::numeric_limits<uint16_t>::max()
 
template<typename T >
constexpr bool is_GncOwnerValue_v = is_GncOwnerValue<T>::value
 
template<typename T >
constexpr bool is_QofInstanceValue_v = is_QofInstanceValue<T>::value
 
template<typename T >
constexpr bool is_QofQueryValue_v = is_QofQueryValue<T>::value
 
template<typename T >
constexpr bool is_OptionClassifier_v = is_OptionClassifier<T>::value
 
template<typename T , typename U >
constexpr bool is_same_decayed_v = is_same_decayed<T, U>::value
 
template<typename T >
constexpr bool is_RangeValue_v = is_RangeValue<T>::value
 

Detailed Description

GnuCash Options System for Book, Report, and Stylesheet Options.

The GnuCash Options System supports two somewhat different purposes:

The options system is centered on an options database or optiondb. A separate optionsdb is created and instantiated for every use, so the book gets one at the beginning of the session with its values loaded from KVP, and every report gets one when the report is run, as do report stylesheets when they are edited. Customized report and stylesheet options are saved as Scheme code fragments in files in the user's GnuCash Config directory.

Note
Persistence via text scheme code is a security vulnerability as it enables an attacker to make GnuCash execute arbitrary code. The Guile interpreter affords full system access with at least the user's privileges.

Typedef Documentation

◆ GncItem

using GncItem = std::pair<QofIdTypeConst, GncGUID>

class GncOptionQofinstanceValue

QofInstances know what type they are but getting them to tell you is a pain so we put them in a pair with a type identifier.

Definition at line 164 of file gnc-option-impl.hpp.

Enumeration Type Documentation

◆ RelativeDatePeriod

enum RelativeDatePeriod : int
strong

Reporting periods relative to the current date.

The original design allowed custom RelativeDatePeriods, but that facility is unused so we'll go with compiled-in enums.

Definition at line 44 of file gnc-option-date.hpp.

44  : int
45 {
46  ABSOLUTE = -1,
47  TODAY,
48  ONE_WEEK_AGO,
49  ONE_WEEK_AHEAD,
50  ONE_MONTH_AGO,
51  ONE_MONTH_AHEAD,
52  THREE_MONTHS_AGO,
53  THREE_MONTHS_AHEAD,
54  SIX_MONTHS_AGO,
55  SIX_MONTHS_AHEAD,
56  ONE_YEAR_AGO,
57  ONE_YEAR_AHEAD,
58  START_THIS_MONTH,
59  END_THIS_MONTH,
60  START_PREV_MONTH,
61  END_PREV_MONTH,
62  START_NEXT_MONTH,
63  END_NEXT_MONTH,
64  START_CURRENT_QUARTER,
65  END_CURRENT_QUARTER,
66  START_PREV_QUARTER,
67  END_PREV_QUARTER,
68  START_NEXT_QUARTER,
69  END_NEXT_QUARTER,
70  START_CAL_YEAR,
71  END_CAL_YEAR,
72  START_PREV_YEAR,
73  END_PREV_YEAR,
74  START_NEXT_YEAR,
75  END_NEXT_YEAR,
76  START_ACCOUNTING_PERIOD,
77  END_ACCOUNTING_PERIOD,
78 };

Function Documentation

◆ gnc_account_list_from_types()

GncOptionAccountList gnc_account_list_from_types ( QofBook *  book,
const GncOptionAccountTypeList &  types 
)

Extract a list of accounts in the book having one of the GNCAccountTypes in types.

Note that in Scheme it's important to use this function and not to create a list of accounts using gnc-get-descendants-sorted because the latter method produces a SWIGTYPE for the accounts that's incompatible with the SWIGTYPE used in this module.

Parameters
bookThe book whose accounts to search
typesA std::vector of GNCAccountType containing the Account types to include in ther result
Returns
A std::vector<const Account*> of all accounts in the book having the Account types in the types parameter.

Definition at line 684 of file gnc-optiondb.cpp.

686 {
687  GncOptionAccountList list;
688  AccountPair funcdata{list, types};
689  Account* base_acct = gnc_book_get_root_account(book);
690  gnc_account_foreach_descendant(base_acct, (AccountCb)find_children,
691  &funcdata);
692  return list;
693 }
void gnc_account_foreach_descendant(const Account *acc, AccountCb thunk, gpointer user_data)
This method will traverse all children of this accounts and their descendants, calling &#39;func&#39; on each...
Definition: Account.cpp:3190

◆ gnc_make_option()

template<typename ValueType >
GncOption* gnc_make_option ( const char *  section,
const char *  name,
const char *  key,
const char *  doc_string,
ValueType  value,
GncOptionUIType  ui_type 
)

Free function wrapping GncOption's constructor.

The type of GncOptionValue to create is determined from the UI type. Some GncOptionValue types require more parameters for their constructors and can't be created with this function.

Definition at line 256 of file gnc-option.hpp.

259 {
260  return new GncOption(section, name, key, doc_string, value, ui_type);
261 }
Represents the public interface for an option.
Definition: gnc-option.hpp:133

◆ gnc_option_db_book_options()

void gnc_option_db_book_options ( GncOptionDB )

Register the standard option set for a QofBook.

Parameters
odbThe GncOptionDB

Definition at line 1102 of file gnc-optiondb.cpp.

1103 {
1104  constexpr const char* business_section{N_("Business")};
1105  constexpr const char* counter_section{N_("Counters")};
1106  static const std::string empty_string{""};
1107 
1108 //Accounts Tab
1109 
1110  gnc_register_number_range_option<double>(odb, OPTION_SECTION_ACCOUNTS,
1111  OPTION_NAME_AUTO_READONLY_DAYS, "a",
1112  N_("Choose the number of days after which transactions will be read-only and cannot be edited anymore. This threshold is marked by a red line in the account register windows. If zero, all transactions can be edited and none are read-only."),
1113  0.0, 0.0, 3650.0, 1.0);
1114 
1115  gnc_register_simple_boolean_option(odb, OPTION_SECTION_ACCOUNTS,
1116  OPTION_NAME_NUM_FIELD_SOURCE, "b",
1117  N_("Check to have split action field used in registers for 'Num' field in place of transaction number; transaction number shown as 'T-Num' on second line of register. Has corresponding effect on business features, reporting and imports/exports."),
1118  false);
1119  gnc_register_simple_boolean_option(odb, OPTION_SECTION_ACCOUNTS,
1120  OPTION_NAME_TRADING_ACCOUNTS, "a",
1121  N_("Check to have trading accounts used for transactions involving more than one currency or commodity."),
1122  false);
1123 
1124 //Budgeting Tab
1125 
1126  gnc_register_budget_option(odb, OPTION_SECTION_BUDGETING,
1127  OPTION_NAME_DEFAULT_BUDGET, "a",
1128  N_("Budget to be used when none has been otherwise specified."),
1129  nullptr);
1130 
1131 //Counters Tab
1132 
1133  gnc_register_counter_option(odb, counter_section,
1134  N_("Customer number"), "gncCustomera",
1135  N_("The previous customer number generated. This number will be incremented to generate the next customer number."),
1136  0.0);
1137  gnc_register_counter_format_option(odb, counter_section,
1138  N_("Customer number format"),
1139  "gncCustomerb",
1140  N_("The format string to use for generating customer numbers. This is a printf-style format string."),
1141  empty_string);
1142  gnc_register_counter_option(odb, counter_section,
1143  N_("Employee number"), "gncEmployeea",
1144  N_("The previous employee number generated. This number will be incremented to generate the next employee number."),
1145  0.0);
1146  gnc_register_counter_format_option(odb, counter_section,
1147  N_("Employee number format"),
1148  "gncEmployeeb",
1149  N_("The format string to use for generating employee numbers. This is a printf-style format string."),
1150  empty_string);
1151  gnc_register_counter_option(odb, counter_section,
1152  N_("Invoice number"), "gncInvoicea",
1153  N_("The previous invoice number generated. This number will be incremented to generate the next invoice number."),
1154  0.0);
1155  gnc_register_counter_format_option(odb, counter_section,
1156  N_("Invoice number format"),
1157  "gncInvoiceb",
1158  N_("The format string to use for generating invoice numbers. This is a printf-style format string."),
1159  empty_string);
1160  gnc_register_counter_option(odb, counter_section,
1161  N_("Bill number"), "gncBilla",
1162  N_("The previous bill number generated. This number will be incremented to generate the next bill number."),
1163  0.0);
1164  gnc_register_counter_format_option(odb, counter_section,
1165  N_("Bill number format"), "gncBillb",
1166  N_("The format string to use for generating bill numbers. This is a printf-style format string."),
1167  empty_string);
1168  gnc_register_counter_option(odb, counter_section,
1169  N_("Expense voucher number"), "gncExpVouchera",
1170  N_("The previous expense voucher number generated. This number will be incremented to generate the next voucher number."),
1171  0.0);
1172  gnc_register_counter_format_option(odb, counter_section,
1173  N_("Expense voucher number format"),
1174  "gncExpVoucherb",
1175  N_("The format string to use for generating expense voucher numbers. This is a printf-style format string."),
1176  empty_string);
1177  gnc_register_counter_option(odb, counter_section,
1178  N_("Job number"), "gncJoba",
1179  N_("The previous job number generated. This number will be incremented to generate the next job number."),
1180  0.0);
1181  gnc_register_counter_format_option(odb, counter_section,
1182  N_("Job number format"), "gncJobb",
1183  N_("The format string to use for generating job numbers. This is a printf-style format string."),
1184  empty_string);
1185  gnc_register_counter_option(odb, counter_section,
1186  N_("Order number"), "gncOrdera",
1187  N_("The previous order number generated. This number will be incremented to generate the next order number."),
1188  0.0);
1189  gnc_register_counter_format_option(odb, counter_section,
1190  N_("Order number format"), "gncOrderb",
1191  N_("The format string to use for generating order numbers. This is a printf-style format string."),
1192  empty_string);
1193  gnc_register_counter_option(odb, counter_section,
1194  N_("Vendor number"), "gncVendora",
1195  N_("The previous vendor number generated. This number will be incremented to generate the next vendor number."),
1196  0.0);
1197  gnc_register_counter_format_option(odb, counter_section,
1198  N_("Vendor number format"), "gncVendorb",
1199  N_("The format string to use for generating vendor numbers. This is a printf-style format string."),
1200  empty_string);
1201 
1202 //Business Tab
1203 
1204  gnc_register_string_option(odb, business_section, N_("Company Name"), "a",
1205  N_("The name of your business."),
1206  empty_string);
1207  gnc_register_text_option(odb, business_section, N_("Company Address"), "b1",
1208  N_("The address of your business."),
1209  empty_string);
1210  gnc_register_string_option(odb, business_section,
1211  N_("Company Contact Person"), "b2",
1212  N_("The contact person to print on invoices."),
1213  empty_string);
1214  gnc_register_string_option(odb, business_section,
1215  N_("Company Phone Number"), "c1",
1216  N_("The contact person to print on invoices."),
1217  empty_string);
1218  gnc_register_string_option(odb, business_section,
1219  N_("Company Fax Number"), "c2",
1220  N_("The fax number of your business."),
1221  empty_string);
1222  gnc_register_string_option(odb, business_section,
1223  N_("Company Email Address"), "c3",
1224  N_ ("The email address of your business."),
1225  empty_string);
1226  gnc_register_string_option(odb, business_section,
1227  N_("Company Website URL"), "c4",
1228  N_("The URL address of your website."),
1229  empty_string);
1230  gnc_register_string_option(odb, business_section, N_("Company ID"), "c5",
1231  N_("The ID for your company (eg 'Tax-ID: 00-000000)."),
1232  empty_string);
1233  gnc_register_invoice_print_report_option(odb, business_section,
1234  OPTION_NAME_DEFAULT_INVOICE_REPORT, "e1",
1235  N_("The invoice report to be used for printing."),
1236  empty_string);
1237  gnc_register_number_range_option<double>(odb, business_section,
1238  OPTION_NAME_DEFAULT_INVOICE_REPORT_TIMEOUT, "e2",
1239  N_("Length of time to change the used invoice report. A value of 0 means disabled."),
1240  0.0, 0.0, 20.0, 1.0);
1241  gnc_register_taxtable_option(odb, business_section,
1242  N_("Default Customer TaxTable"), "f1",
1243  N_("The default tax table to apply to customers."),
1244  nullptr);
1245  gnc_register_taxtable_option(odb, business_section,
1246  N_("Default Vendor TaxTable"), "f2",
1247  N_("The default tax table to apply to vendors."),
1248  nullptr);
1249  gnc_register_dateformat_option(odb, business_section,
1250  N_("Fancy Date Format"), "g",
1251  N_("The default date format used for fancy printed dates."),
1252  empty_string);
1253 
1254 //Tax Tab
1255 
1256  gnc_register_string_option(odb, N_("Tax"), N_("Tax Number"), "a",
1257  N_("The electronic tax number of your business"),
1258  empty_string);
1259 }
void gnc_register_simple_boolean_option(GncOptionDB *db, const char *section, const char *name, const char *key, const char *doc_string, bool value)
Create a new simple boolean option and register it in the options database.
void gnc_register_invoice_print_report_option(GncOptionDB *db, const char *section, const char *name, const char *key, const char *doc_string, std::string value)
Create a new print report option and register it in the options database.
void gnc_register_counter_option(GncOptionDB *db, const char *section, const char *name, const char *key, const char *doc_string, double value)
Create a new counter option and register it in the options database.
void gnc_register_dateformat_option(GncOptionDB *db, const char *section, const char *name, const char *key, const char *doc_string, std::string value)
Create a new date format option and register it in the options database.
void gnc_register_string_option(GncOptionDB *db, const char *section, const char *name, const char *key, const char *doc_string, std::string value)
Create a new string option and register it in the options database.
void gnc_register_taxtable_option(GncOptionDB *db, const char *section, const char *name, const char *key, const char *doc_string, GncTaxTable *value)
Create a new taxtable option and register it in the options database.
void gnc_register_budget_option(GncOptionDB *db, const char *section, const char *name, const char *key, const char *doc_string, GncBudget *value)
Create a new budget option and register it in the options database.
void gnc_register_counter_format_option(GncOptionDB *db, const char *section, const char *name, const char *key, const char *doc_string, std::string value)
Create a new counter format option and register it in the options database.
void gnc_register_text_option(GncOptionDB *db, const char *section, const char *name, const char *key, const char *doc_string, std::string value)
Create a new text option and register it in the options database.

◆ gnc_option_db_clean()

void gnc_option_db_clean ( GncOptionDB odb)

Reset all ui_items to the option value.

Parameters
odbThe GncOptionDB.

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

1079 {
1080  odb->foreach_section(
1081  [](GncOptionSectionPtr& section){
1082  section->foreach_option(
1083  [](GncOption& option) {
1084  option.set_ui_item_from_option();
1085  });
1086  });
1087 }
Represents the public interface for an option.
Definition: gnc-option.hpp:133

◆ gnc_option_db_commit()

GList* gnc_option_db_commit ( GncOptionDB odb)

Write all changed ui_item values to their options.

Parameters
odbThe GncOptionDB.
Returns
A GList* conatining the names of options that raised exceptions when attempting to set their values. The names are const, free only the list.

Definition at line 1052 of file gnc-optiondb.cpp.

1053 {
1054  GList* errors{};
1055  odb->foreach_section(
1056  [&errors](GncOptionSectionPtr& section){
1057  section->foreach_option(
1058  [&errors](GncOption& option) {
1059  try
1060  {
1061  option.set_option_from_ui_item();
1062  }
1063  catch (const std::invalid_argument& err)
1064  {
1065  PWARN("Option %s:%s failed to set its value %s",
1066  option.get_section().c_str(),
1067  option.get_name().c_str(), err.what());
1068  errors = g_list_prepend(errors,
1069  (void*)option.get_name().c_str());
1070  } });
1071  });
1072  if (!errors)
1073  odb->run_callbacks();
1074  return errors;
1075 }
Represents the public interface for an option.
Definition: gnc-option.hpp:133
#define PWARN(format, args...)
Log a warning.
Definition: qoflog.h:250

◆ gnc_option_db_destroy()

void gnc_option_db_destroy ( GncOptionDB odb)

Destruct and release a GncOptionDB.

Parameters
odbThe GncOptionDB.

Definition at line 1046 of file gnc-optiondb.cpp.

1047 {
1048  PWARN("Direct Destroy called on GncOptionDB %" G_GUINT64_FORMAT, (uint64_t)odb);
1049 }
#define PWARN(format, args...)
Log a warning.
Definition: qoflog.h:250

◆ gnc_option_db_load()

void gnc_option_db_load ( GncOptionDB odb,
QofBook *  book 
)

Load a book's options into the GncOptionDB.

Parameters
odbThe GncOptionDB
bookThe book in which the options are saved.

Definition at line 1089 of file gnc-optiondb.cpp.

1090 {
1091  odb->load_from_kvp(book);
1092 }

◆ gnc_option_db_lookup_qofinstance_value()

const QofInstance* gnc_option_db_lookup_qofinstance_value ( GncOptionDB ,
const char *  ,
const char *   
)

Retrieve the QofInstance value of an option in the GncOptionDB.

Parameters
odbthe GncOptionDB
sectionthe section in which the option is stored
namethe option name
Returns
the const QofInstance* of the value or nullptr if the option isn't found or if its value isn't a QofInstance*.

Definition at line 1261 of file gnc-optiondb.cpp.

1263 {
1264  auto option{odb->find_option(section, name)};
1265  if (option)
1266  return option->get_value<const QofInstance*>();
1267  else
1268  return nullptr;
1269 }

◆ gnc_option_db_new()

GncOptionDB* gnc_option_db_new ( void  )

Create an empty option database.

Returns
A newly allocated GncOptionDB. Use delete to destroy it.

Definition at line 1040 of file gnc-optiondb.cpp.

1041 {
1042  return new GncOptionDB;
1043 }
Holds all of the options for a book, report, or stylesheet, organized by GncOptionSections.

◆ gnc_option_db_save()

void gnc_option_db_save ( GncOptionDB odb,
QofBook *  book,
gboolean  clear_options 
)

Save the GncOptionDB contents into a book's options store.

Parameters
odbThe GncOptionDB
bookThe book in which the options are saved.
clear_optionsTRUE if the books existing options should be removed first.

Definition at line 1095 of file gnc-optiondb.cpp.

1097 {
1098  odb->save_to_kvp(book, static_cast<bool>(clear_options));
1099 }

◆ gnc_register_account_list_limited_option()

void gnc_register_account_list_limited_option ( GncOptionDB db,
const char *  section,
const char *  name,
const char *  key,
const char *  doc_string,
const GncOptionAccountList &  value,
GncOptionAccountTypeList &&  allowed 
)

Create a new limited account list option and register it in the options database.

Parameters
dbA GncOptionDB* for calling from C. Caller retains ownership.
sectionThe database section for the option.
nameThe option name.
keyA short tag used to sort the controls in the dialog.
doc_stringA description of the option. This will be used in tooltips and should be marked for translation.
valueThe initial and default values for the option.
allowedThe accounts which are available for selection.

Definition at line 650 of file gnc-optiondb.cpp.

656 {
657  try
658  {
659  GncOption option{GncOptionAccountListValue{section, name, key, doc_string,
660  GncOptionUIType::ACCOUNT_LIST, value, std::move(allowed)}};
661  db->register_option(section, std::move(option));
662  }
663  catch (const std::invalid_argument& err)
664  {
665  PWARN("Account List Limited Option, value failed validation, option not registered.");
666  }
667 }
Represents the public interface for an option.
Definition: gnc-option.hpp:133
Set one or more accounts on which to report, optionally restricted to certain account types...
#define PWARN(format, args...)
Log a warning.
Definition: qoflog.h:250

◆ gnc_register_account_list_option()

void gnc_register_account_list_option ( GncOptionDB db,
const char *  section,
const char *  name,
const char *  key,
const char *  doc_string,
const GncOptionAccountList &  value 
)

Create a new account list option and register it in the options database.

Parameters
dbA GncOptionDB* for calling from C. Caller retains ownership.
sectionThe database section for the option.
nameThe option name.
keyA short tag used to sort the controls in the dialog.
doc_stringA description of the option. This will be used in tooltips and should be marked for translation.
valueThe initial and default values for the option.

Definition at line 639 of file gnc-optiondb.cpp.

643 {
644  GncOption option{GncOptionAccountListValue{section, name, key, doc_string,
645  GncOptionUIType::ACCOUNT_LIST, value}};
646  db->register_option(section, std::move(option));
647 }
Represents the public interface for an option.
Definition: gnc-option.hpp:133
Set one or more accounts on which to report, optionally restricted to certain account types...

◆ gnc_register_account_sel_limited_option()

void gnc_register_account_sel_limited_option ( GncOptionDB db,
const char *  section,
const char *  name,
const char *  key,
const char *  doc_string,
const Account value,
GncOptionAccountTypeList &&  allowed 
)

Create a limited account selection option and register it in the options database.

Parameters
dbA GncOptionDB* for calling from C. Caller retains ownership.
sectionThe database section for the option.
nameThe option name.
keyA short tag used to sort the controls in the dialog.
doc_stringA description of the option. This will be used in tooltips and should be marked for translation.
valueThe initial and default value for the option.
allowedThe accounts which are available for selection.

Definition at line 697 of file gnc-optiondb.cpp.

702 {
703  try
704  {
705  GncOption option{GncOptionAccountSelValue{section, name, key, doc_string,
706  GncOptionUIType::ACCOUNT_SEL, value, std::move(allowed)}};
707  db->register_option(section, std::move(option));
708  }
709  catch (const std::invalid_argument& err)
710  {
711  PWARN("Account Sel Limited Option, value failed validation, option not registerd.");
712  }
713 }
Represents the public interface for an option.
Definition: gnc-option.hpp:133
#define PWARN(format, args...)
Log a warning.
Definition: qoflog.h:250

◆ gnc_register_budget_option()

void gnc_register_budget_option ( GncOptionDB db,
const char *  section,
const char *  name,
const char *  key,
const char *  doc_string,
GncBudget *  value 
)

Create a new budget option and register it in the options database.

Parameters
dbA GncOptionDB* for calling from C. Caller retains ownership.
sectionThe database section for the option.
nameThe option name.
keyA short tag used to sort the controls in the dialog.
doc_stringA description of the option. This will be used in tooltips and should be marked for translation.
valueThe initial and default value for the option.

Definition at line 562 of file gnc-optiondb.cpp.

565 {
566  GncOption option{GncOptionQofInstanceValue{section, name, key, doc_string,
567  (const QofInstance*)value,
568  GncOptionUIType::BUDGET}};
569  db->register_option(section, std::move(option));
570 }
Represents the public interface for an option.
Definition: gnc-option.hpp:133

◆ gnc_register_color_option()

void gnc_register_color_option ( GncOptionDB db,
const char *  section,
const char *  name,
const char *  key,
const char *  doc_string,
std::string  value 
)

Create a new color option and register it in the options database.

Parameters
dbA GncOptionDB* for calling from C. Caller retains ownership.
sectionThe database section for the option.
nameThe option name.
keyA short tag used to sort the controls in the dialog.
doc_stringA description of the option. This will be used in tooltips and should be marked for translation.
valueThe initial and default value for the option.

Definition at line 573 of file gnc-optiondb.cpp.

576 {
577  GncOption option{section, name, key, doc_string, value,
578  GncOptionUIType::COLOR};
579  db->register_option(section, std::move(option));
580 }
Represents the public interface for an option.
Definition: gnc-option.hpp:133

◆ gnc_register_commodity_option() [1/2]

void gnc_register_commodity_option ( GncOptionDB db,
const char *  section,
const char *  name,
const char *  key,
const char *  doc_string,
gnc_commodity *  value 
)

Create a new commodity option and register it in the options database.

Parameters
dbA GncOptionDB* for calling from C. Caller retains ownership.
sectionThe database section for the option.
nameThe option name.
keyA short tag used to sort the controls in the dialog.
doc_stringA description of the option. This will be used in tooltips and should be marked for translation.
valueThe initial and default value for the option.

Definition at line 583 of file gnc-optiondb.cpp.

586 {
587  GncOption option{GncOptionCommodityValue{section, name, key, doc_string,
588  value,
589  GncOptionUIType::COMMODITY}};
590  db->register_option(section, std::move(option));
591 }
Represents the public interface for an option.
Definition: gnc-option.hpp:133
class GncOptionCommodityValue Commodities are stored with their namespace and mnemonic instead of the...

◆ gnc_register_commodity_option() [2/2]

void gnc_register_commodity_option ( GncOptionDB db,
const char *  section,
const char *  name,
const char *  key,
const char *  doc_string,
const char *  value 
)

As above but with a const char* value, which should be the symbol for the commodity.

All security editor namespaces will be searched to retrieve it.

Definition at line 594 of file gnc-optiondb.cpp.

597 {
598  gnc_commodity* commodity{};
599  const auto book{qof_session_get_book(gnc_get_current_session())};
600  const auto commodity_table{gnc_commodity_table_get_table(book)};
601  const auto namespaces{gnc_commodity_table_get_namespaces(commodity_table)};
602  for (auto node = namespaces; node && commodity == nullptr;
603  node = g_list_next(node))
604  {
605  commodity = gnc_commodity_table_lookup(commodity_table,
606  (const char*)(node->data),
607  value);
608  if (commodity)
609  break;
610  }
611  GncOption option{GncOptionCommodityValue{section, name, key, doc_string,
612  commodity,
613  GncOptionUIType::COMMODITY}};
614  db->register_option(section, std::move(option));
615 }
gnc_commodity_table * gnc_commodity_table_get_table(QofBook *book)
Returns the commodity table associated with a book.
Represents the public interface for an option.
Definition: gnc-option.hpp:133
QofBook * qof_session_get_book(const QofSession *session)
Returns the QofBook of this session.
Definition: qofsession.cpp:574
GList * gnc_commodity_table_get_namespaces(const gnc_commodity_table *table)
Return a list of all namespaces in the commodity table.
class GncOptionCommodityValue Commodities are stored with their namespace and mnemonic instead of the...

◆ gnc_register_counter_format_option()

void gnc_register_counter_format_option ( GncOptionDB db,
const char *  section,
const char *  name,
const char *  key,
const char *  doc_string,
std::string  value 
)

Create a new counter format option and register it in the options database.

Parameters
dbA GncOptionDB* for calling from C. Caller retains ownership.
sectionThe database section for the option.
nameThe option name.
keyA short tag used to sort the controls in the dialog.
doc_stringA description of the option. This will be used in tooltips and should be marked for translation.
valueThe initial and default value for the option.

Definition at line 861 of file gnc-optiondb.cpp.

865 {
866  GncOption option{section, name, key, doc_string, value,
867  GncOptionUIType::STRING};
868  db->register_option(section, std::move(option));
869 }
Represents the public interface for an option.
Definition: gnc-option.hpp:133

◆ gnc_register_counter_option()

void gnc_register_counter_option ( GncOptionDB db,
const char *  section,
const char *  name,
const char *  key,
const char *  doc_string,
double  value 
)

Create a new counter option and register it in the options database.

Parameters
dbA GncOptionDB* for calling from C. Caller retains ownership.
sectionThe database section for the option.
nameThe option name.
keyA short tag used to sort the controls in the dialog.
doc_stringA description of the option. This will be used in tooltips and should be marked for translation.
valueThe initial and default value for the option.

Definition at line 851 of file gnc-optiondb.cpp.

854 {
855  GncOption option{GncOptionRangeValue<double>{section, name, key, doc_string,
856  value, 0.0, 999999999.0, 1.0}};
857  db->register_option(section, std::move(option));
858 }
Represents the public interface for an option.
Definition: gnc-option.hpp:133
Used for numeric ranges and plot sizes.

◆ gnc_register_currency_option()

void gnc_register_currency_option ( GncOptionDB db,
const char *  section,
const char *  name,
const char *  key,
const char *  doc_string,
gnc_commodity *  value 
)

Create a new currency option and register it in the options database.

Parameters
dbA GncOptionDB* for calling from C. Caller retains ownership.
sectionThe database section for the option.
nameThe option name.
keyA short tag used to sort the controls in the dialog.
doc_stringA description of the option. This will be used in tooltips and should be marked for translation.
valueThe initial and default value for the option. It is checked with gnc_commodity_is_currency.

Definition at line 882 of file gnc-optiondb.cpp.

885 {
887  section, name, key, doc_string, value, GncOptionUIType::CURRENCY
888  }};
889  db->register_option(section, std::move(option));
890 }
Represents the public interface for an option.
Definition: gnc-option.hpp:133
class GncOptionCommodityValue Commodities are stored with their namespace and mnemonic instead of the...

◆ gnc_register_date_option() [1/3]

void gnc_register_date_option ( GncOptionDB db,
const char *  section,
const char *  name,
const char *  key,
const char *  doc_string,
RelativeDatePeriod  period = RelativeDatePeriod::TODAY,
RelativeDateUI  ui = RelativeDateUI::BOTH 
)

Create a new date option and register it in the options database.

Parameters
dbA GncOptionDB* for calling from C. Caller retains ownership.
sectionThe database section for the option.
nameThe option name.
keyA short tag used to sort the controls in the dialog.
doc_stringA description of the option. This will be used in tooltips and should be marked for translation.
periodThe default/starting relative date value for the option.
uiWhat UI to display, relative, absolute, or both.

Definition at line 923 of file gnc-optiondb.cpp.

927 {
928  auto ui_type = ui == RelativeDateUI::BOTH ? GncOptionUIType::DATE_BOTH :
929  ui == RelativeDateUI::RELATIVE ? GncOptionUIType::DATE_RELATIVE :
930  GncOptionUIType::DATE_ABSOLUTE;
931  GncOption option{GncOptionDateValue(section, name, key, doc_string,
932  ui_type, period)};
933  db->register_option(section, std::move(option));
934 }
A legal date value is a pair of either a RelativeDatePeriod, the absolute flag and a time64...
Represents the public interface for an option.
Definition: gnc-option.hpp:133

◆ gnc_register_date_option() [2/3]

void gnc_register_date_option ( GncOptionDB db,
const char *  section,
const char *  name,
const char *  key,
const char *  doc_string,
time64  time,
RelativeDateUI  ui = RelativeDateUI::BOTH 
)

Create a new date option and register it in the options database.

Parameters
dbA GncOptionDB* for calling from C. Caller retains ownership.
sectionThe database section for the option.
nameThe option name.
keyA short tag used to sort the controls in the dialog.
doc_stringA description of the option. This will be used in tooltips and should be marked for translation.
timeThe initial time to set in the option.
uiWhat UI to display, relative, absolute, or both.

Definition at line 909 of file gnc-optiondb.cpp.

913 {
914  auto ui_type = ui == RelativeDateUI::BOTH ? GncOptionUIType::DATE_BOTH :
915  ui == RelativeDateUI::RELATIVE ? GncOptionUIType::DATE_RELATIVE :
916  GncOptionUIType::DATE_ABSOLUTE;
917  GncOption option{GncOptionDateValue(section, name, key, doc_string,
918  ui_type, time)};
919  db->register_option(section, std::move(option));
920 }
A legal date value is a pair of either a RelativeDatePeriod, the absolute flag and a time64...
Represents the public interface for an option.
Definition: gnc-option.hpp:133

◆ gnc_register_date_option() [3/3]

void gnc_register_date_option ( GncOptionDB db,
const char *  section,
const char *  name,
const char *  key,
const char *  doc_string,
RelativeDatePeriodVec &  period_set,
bool  both = true 
)

Create a new date option and register it in the options database.

Parameters
dbA GncOptionDB* for calling from C. Caller retains ownership.
sectionThe database section for the option.
nameThe option name.
keyA short tag used to sort the controls in the dialog.
doc_stringA description of the option. This will be used in tooltips and should be marked for translation.
period_setA vector of relative date periods to display in the relative control.
bothWhether to display both a relative and absolute control or a onla a relative control.

Definition at line 937 of file gnc-optiondb.cpp.

942 {
943  auto is_absolute = period_set.size() == 1 &&
944  period_set.front() == RelativeDatePeriod::ABSOLUTE;
945  auto ui_type = both ? GncOptionUIType::DATE_BOTH :
946  is_absolute ? GncOptionUIType::DATE_ABSOLUTE : GncOptionUIType::DATE_RELATIVE;
947  GncOption option{GncOptionDateValue(section, name, key, doc_string,
948  ui_type, period_set)};
949  if (is_absolute)
950  option.set_default_value(gnc_time(nullptr));
951  db->register_option(section, std::move(option));
952 }
A legal date value is a pair of either a RelativeDatePeriod, the absolute flag and a time64...
Represents the public interface for an option.
Definition: gnc-option.hpp:133
time64 gnc_time(time64 *tbuf)
get the current local time
Definition: gnc-date.cpp:270

◆ gnc_register_dateformat_option()

void gnc_register_dateformat_option ( GncOptionDB db,
const char *  section,
const char *  name,
const char *  key,
const char *  doc_string,
std::string  value 
)

Create a new date format option and register it in the options database.

Parameters
dbA GncOptionDB* for calling from C. Caller retains ownership.
sectionThe database section for the option.
nameThe option name.
keyA short tag used to sort the controls in the dialog.
doc_stringA description of the option. This will be used in tooltips and should be marked for translation.
valueThe initial and default value for the option.

Definition at line 872 of file gnc-optiondb.cpp.

875 {
876  GncOption option{section, name, key, doc_string, value,
877  GncOptionUIType::DATE_FORMAT};
878  db->register_option(section, std::move(option));
879 }
Represents the public interface for an option.
Definition: gnc-option.hpp:133

◆ gnc_register_end_date_option()

void gnc_register_end_date_option ( GncOptionDB db,
const char *  section,
const char *  name,
const char *  key,
const char *  doc_string,
bool  both = true 
)

Create a new end-date option and register it in the options database.

Parameters
dbA GncOptionDB* for calling from C. Caller retains ownership.
sectionThe database section for the option.
nameThe option name.
keyA short tag used to sort the controls in the dialog.
doc_stringA description of the option. This will be used in tooltips and should be marked for translation.
bothWhether to display both a relative and absolute control or a onla a relative control.

Definition at line 992 of file gnc-optiondb.cpp.

995 {
996  auto ui_type = both ? GncOptionUIType::DATE_BOTH :
997  GncOptionUIType::DATE_RELATIVE;
998  GncOption option{GncOptionDateValue(section, name, key, doc_string,
999  ui_type, end_dates)};
1000  db->register_option(section, std::move(option));
1001 }
A legal date value is a pair of either a RelativeDatePeriod, the absolute flag and a time64...
Represents the public interface for an option.
Definition: gnc-option.hpp:133

◆ gnc_register_font_option()

void gnc_register_font_option ( GncOptionDB db,
const char *  section,
const char *  name,
const char *  key,
const char *  doc_string,
std::string  value 
)

Create a new font option and register it in the options database.

Parameters
dbA GncOptionDB* for calling from C. Caller retains ownership.
sectionThe database section for the option.
nameThe option name.
keyA short tag used to sort the controls in the dialog.
doc_stringA description of the option. This will be used in tooltips and should be marked for translation.
valueThe initial and default value for the option.

Definition at line 552 of file gnc-optiondb.cpp.

555 {
556  GncOption option{section, name, key, doc_string, value,
557  GncOptionUIType::FONT};
558  db->register_option(section, std::move(option));
559 }
Represents the public interface for an option.
Definition: gnc-option.hpp:133

◆ gnc_register_invoice_option()

void gnc_register_invoice_option ( GncOptionDB db,
const char *  section,
const char *  name,
const char *  key,
const char *  doc_string,
GncInvoice *  value 
)

Create a new invoice option and register it in the options database.

Parameters
dbA GncOptionDB* for calling from C. Caller retains ownership.
sectionThe database section for the option.
nameThe option name.
keyA short tag used to sort the controls in the dialog.
doc_stringA description of the option. This will be used in tooltips and should be marked for translation.
valueThe initial and default value for the option.

Definition at line 819 of file gnc-optiondb.cpp.

822 {
823  GncOption option{GncOptionQofInstanceValue{section, name, key, doc_string,
824  (const QofInstance*)value,
825  GncOptionUIType::INVOICE}};
826  db->register_option(section, std::move(option));
827 }
Represents the public interface for an option.
Definition: gnc-option.hpp:133

◆ gnc_register_invoice_print_report_option()

void gnc_register_invoice_print_report_option ( GncOptionDB db,
const char *  section,
const char *  name,
const char *  key,
const char *  doc_string,
std::string  value 
)

Create a new print report option and register it in the options database.

Parameters
dbA GncOptionDB* for calling from C. Caller retains ownership.
sectionThe database section for the option.
nameThe option name.
doc_stringA description of the option. This will be used in tooltips and should be marked for translation.
valueThe initial and default value for the option.

Definition at line 841 of file gnc-optiondb.cpp.

844 {
845  GncOption option{section, name, key, doc_string,
846  value, GncOptionUIType::INV_REPORT};
847  db->register_option(section, std::move(option));
848 }
Represents the public interface for an option.
Definition: gnc-option.hpp:133

◆ gnc_register_list_option()

void gnc_register_list_option ( GncOptionDB db,
const char *  section,
const char *  name,
const char *  key,
const char *  doc_string,
const char *  value,
GncMultichoiceOptionChoices &&  list 
)

Create a new list option and register it in the options database.

Parameters
dbA GncOptionDB* for calling from C. Caller retains ownership.
sectionThe database section for the option.
nameThe option name.
keyA short tag used to sort the controls in the dialog.
doc_stringA description of the option. This will be used in tooltips and should be marked for translation.
valueThe initial and default value for the option.
listThe values available for selection. Note that this parameter will be moved from so using it after this call will result in undefined behavior.

Definition at line 735 of file gnc-optiondb.cpp.

739 {
740  GncOption option{GncOptionMultichoiceValue{section, name, key, doc_string,
741  value, std::move(list), GncOptionUIType::LIST}};
742  db->register_option(section, std::move(option));
743 }
Represents the public interface for an option.
Definition: gnc-option.hpp:133
Multichoice options have a vector of valid options (GncMultichoiceOptionChoices) and validate the sel...

◆ gnc_register_multichoice_option()

void gnc_register_multichoice_option ( GncOptionDB db,
const char *  section,
const char *  name,
const char *  key,
const char *  doc_string,
const char *  default_val,
GncMultichoiceOptionChoices &&  value 
)

Create a new multichoice option and register it in the options database.

Parameters
dbA GncOptionDB* for calling from C. Caller retains ownership.
sectionThe database section for the option.
nameThe option name.
keyA short tag used to sort the controls in the dialog.
doc_stringA description of the option. This will be used in tooltips and should be marked for translation.
valueThe set of possible values for the option. Only one can be selected. Note that the value will be moved from the parameter and using the parameter after this call will result in undefined behavior.

Definition at line 716 of file gnc-optiondb.cpp.

720 {
721  std::string defval{default_val};
722  auto found{std::find_if(choices.begin(), choices.end(),
723  [&defval](auto& choice)->bool {
724  return defval == std::get<0>(choice);
725  })};
726  if (found == choices.end())
727  defval = (choices.empty() ? std::string{"None"} :
728  std::get<0>(choices.at(0)));
729  GncOption option{GncOptionMultichoiceValue{section, name, key, doc_string,
730  defval.c_str(), std::move(choices)}};
731  db->register_option(section, std::move(option));
732 }
Represents the public interface for an option.
Definition: gnc-option.hpp:133
Multichoice options have a vector of valid options (GncMultichoiceOptionChoices) and validate the sel...

◆ gnc_register_number_plot_size_option()

void gnc_register_number_plot_size_option ( GncOptionDB db,
const char *  section,
const char *  name,
const char *  key,
const char *  doc_string,
int  value 
)

Create a new plot-size option and register it in the options database.

Parameters
dbA GncOptionDB* for calling from C. Caller retains ownership.
sectionThe database section for the option.
nameThe option name.
keyA short tag used to sort the controls in the dialog.
doc_stringA description of the option. This will be used in tooltips and should be marked for translation.
valueThe initial and default value for the option.

Definition at line 769 of file gnc-optiondb.cpp.

773 {
774 //65K is 10x reasonable, but it's a convenient constant.
775  GncOption option{GncOptionRangeValue<int>{section, name, key, doc_string,
776  value, 10, UINT16_MAX, 1, GncOptionUIType::PLOT_SIZE}};
777  db->register_option(section, std::move(option));
778 }
Represents the public interface for an option.
Definition: gnc-option.hpp:133
Used for numeric ranges and plot sizes.

◆ gnc_register_number_range_option()

template<typename ValueType >
void gnc_register_number_range_option ( GncOptionDB db,
const char *  section,
const char *  name,
const char *  key,
const char *  doc_string,
ValueType  value,
ValueType  min,
ValueType  max,
ValueType  step 
)

Create a new number range option and register it in the options database.

These are normally associated with spin controls and ValueType is normally double, but it's templated to permit other numeric types if needed.

Parameters
dbA GncOptionDB* for calling from C. Caller retains ownership.
sectionThe database section for the option.
nameThe option name.
keyA short tag used to sort the controls in the dialog.
doc_stringA description of the option. This will be used in tooltips and should be marked for translation.
valueThe initial and default value for the option.
minThe minimum value for the spin control.
maxThe maximum value for the spin control.
stepThe step size (increment) of the spin control.

Definition at line 749 of file gnc-optiondb.cpp.

753 {
754  try
755  {
756  GncOption option{GncOptionRangeValue<ValueType>{section, name, key,
757  doc_string, value, min,
758  max, step}};
759  db->register_option(section, std::move(option));
760  }
761  catch(const std::invalid_argument& err)
762  {
763  PWARN("Number Range Option %s, option not registerd.",
764  err.what());
765  }
766 }
Represents the public interface for an option.
Definition: gnc-option.hpp:133
#define PWARN(format, args...)
Log a warning.
Definition: qoflog.h:250
Used for numeric ranges and plot sizes.

◆ gnc_register_owner_option()

void gnc_register_owner_option ( GncOptionDB db,
const char *  section,
const char *  name,
const char *  key,
const char *  doc_string,
const GncOwner value,
GncOwnerType  type 
)

Create a new GncOwner option and register it in the options database.

Parameters
dbA GncOptionDB* for calling from C. Caller retains ownership.
sectionThe database section for the option.
nameThe option name.
keyA short tag used to sort the controls in the dialog.
doc_stringA description of the option. This will be used in tooltips and should be marked for translation.
valueThe initial and default value for the option.
typeThe type of owner, determines the UI type.

Definition at line 790 of file gnc-optiondb.cpp.

794 {
795  GncOptionUIType uitype;
796  switch (type)
797  {
798  case GNC_OWNER_CUSTOMER:
799  uitype = GncOptionUIType::CUSTOMER;
800  break;
801  case GNC_OWNER_EMPLOYEE:
802  uitype = GncOptionUIType::EMPLOYEE;
803  break;
804  case GNC_OWNER_JOB:
805  uitype = GncOptionUIType::JOB;
806  break;
807  case GNC_OWNER_VENDOR:
808  uitype = GncOptionUIType::VENDOR;
809  break;
810  default:
811  uitype = GncOptionUIType::INTERNAL;
812  };
813  GncOption option{GncOptionGncOwnerValue{section, name, key, doc_string,
814  value, uitype}};
815  db->register_option(section, std::move(option));
816 }
Represents the public interface for an option.
Definition: gnc-option.hpp:133
GncOptionUIType
Used by GncOptionClassifier to indicate to dialog-options what control should be displayed for the op...

◆ gnc_register_pixmap_option()

void gnc_register_pixmap_option ( GncOptionDB db,
const char *  section,
const char *  name,
const char *  key,
const char *  doc_string,
std::string  value 
)

Create a new pixmap option and register it in the options database.

Parameters
dbA GncOptionDB* for calling from C. Caller retains ownership.
sectionThe database section for the option.
nameThe option name.
keyA short tag used to sort the controls in the dialog.
doc_stringA description of the option. This will be used in tooltips and should be marked for translation.
valueThe initial and default value for the option.

Definition at line 629 of file gnc-optiondb.cpp.

632 {
633  GncOption option{section, name, key, doc_string, value,
634  GncOptionUIType::PIXMAP};
635  db->register_option(section, std::move(option));
636 }
Represents the public interface for an option.
Definition: gnc-option.hpp:133

◆ gnc_register_query_option()

void gnc_register_query_option ( GncOptionDB db,
const char *  section,
const char *  name,
const QofQuery value 
)

Create a new QofQuery option and register it in the options database.

Query options have no UI component so they don't get a key or a docstring.

Parameters
dbA GncOptionDB* for calling from C. Caller retains ownership.
sectionThe database section for the option.
nameThe option name.
valueThe initial and default value for the option.

Definition at line 781 of file gnc-optiondb.cpp.

783 {
784  GncOption option{section, name, "", "", value,
785  GncOptionUIType::INTERNAL};
786  db->register_option(section, std::move(option));
787 }
Represents the public interface for an option.
Definition: gnc-option.hpp:133

◆ gnc_register_simple_boolean_option()

void gnc_register_simple_boolean_option ( GncOptionDB db,
const char *  section,
const char *  name,
const char *  key,
const char *  doc_string,
bool  value 
)

Create a new simple boolean option and register it in the options database.

Parameters
dbA GncOptionDB* for calling from C. Caller retains ownership.
sectionThe database section for the option.
nameThe option name.
keyA short tag used to sort the controls in the dialog.
doc_stringA description of the option. This will be used in tooltips and should be marked for translation.
valueThe initial and default value for the option.

Definition at line 618 of file gnc-optiondb.cpp.

622 {
623  GncOption option{section, name, key, doc_string, value,
624  GncOptionUIType::BOOLEAN};
625  db->register_option(section, std::move(option));
626 }
Represents the public interface for an option.
Definition: gnc-option.hpp:133

◆ gnc_register_start_date_option()

void gnc_register_start_date_option ( GncOptionDB db,
const char *  section,
const char *  name,
const char *  key,
const char *  doc_string,
bool  both = true 
)

Create a new start-date option and register it in the options database.

Parameters
dbA GncOptionDB* for calling from C. Caller retains ownership.
sectionThe database section for the option.
nameThe option name.
keyA short tag used to sort the controls in the dialog.
doc_stringA description of the option. This will be used in tooltips and should be marked for translation.
bothWhether to display both a relative and absolute control or a onla a relative control.

Definition at line 968 of file gnc-optiondb.cpp.

971 {
972  auto ui_type = both ? GncOptionUIType::DATE_BOTH :
973  GncOptionUIType::DATE_RELATIVE;
974  GncOption option{GncOptionDateValue(section, name, key, doc_string,
975  ui_type, begin_dates)};
976  db->register_option(section, std::move(option));
977 }
A legal date value is a pair of either a RelativeDatePeriod, the absolute flag and a time64...
Represents the public interface for an option.
Definition: gnc-option.hpp:133

◆ gnc_register_string_option()

void gnc_register_string_option ( GncOptionDB db,
const char *  section,
const char *  name,
const char *  key,
const char *  doc_string,
std::string  value 
)

Create a new string option and register it in the options database.

Parameters
dbA GncOptionDB* for calling from C. Caller retains ownership.
sectionThe database section for the option.
nameThe option name.
keyA short tag used to sort the controls in the dialog.
doc_stringA description of the option. This will be used in tooltips and should be marked for translation.
valueThe initial and default value for the option.

Definition at line 531 of file gnc-optiondb.cpp.

534 {
535  GncOption option{section, name, key, doc_string, value,
536  GncOptionUIType::STRING};
537  db->register_option(section, std::move(option));
538 }
Represents the public interface for an option.
Definition: gnc-option.hpp:133

◆ gnc_register_taxtable_option()

void gnc_register_taxtable_option ( GncOptionDB db,
const char *  section,
const char *  name,
const char *  key,
const char *  doc_string,
GncTaxTable value 
)

Create a new taxtable option and register it in the options database.

Parameters
dbA GncOptionDB* for calling from C. Caller retains ownership.
sectionThe database section for the option.
nameThe option name.
keyA short tag used to sort the controls in the dialog.
doc_stringA description of the option. This will be used in tooltips and should be marked for translation.
valueThe initial and default value for the option.

Definition at line 830 of file gnc-optiondb.cpp.

833 {
834  GncOption option{GncOptionQofInstanceValue{section, name, key, doc_string,
835  (const QofInstance*)value,
836  GncOptionUIType::TAX_TABLE}};
837  db->register_option(section, std::move(option));
838 }
Represents the public interface for an option.
Definition: gnc-option.hpp:133

◆ gnc_register_text_option()

void gnc_register_text_option ( GncOptionDB db,
const char *  section,
const char *  name,
const char *  key,
const char *  doc_string,
std::string  value 
)

Create a new text option and register it in the options database.

Parameters
dbA GncOptionDB* for calling from C. Caller retains ownership.
sectionThe database section for the option.
nameThe option name.
keyA short tag used to sort the controls in the dialog.
doc_stringA description of the option. This will be used in tooltips and should be marked for translation.
valueThe initial and default value for the option.

Definition at line 541 of file gnc-optiondb.cpp.

544 {
545  GncOption option{section, name, key, doc_string, value,
546  GncOptionUIType::TEXT};
547  db->register_option(section, std::move(option));
548 
549 }
Represents the public interface for an option.
Definition: gnc-option.hpp:133

◆ gnc_relative_date_description()

const char* gnc_relative_date_description ( RelativeDatePeriod  )

Provide the description of a relative date.

This string is localizable.

Parameters
periodThe relative date period.
Returns
A constant string or nullptr if the period is ABSOLUTE. The string's lifetime will be that of the Relative Date Period. It must not be freed and should be copied if the period might be destroyed before the using code is finished.

Definition at line 373 of file gnc-option-date.cpp.

374 {
375  if (per == RelativeDatePeriod::ABSOLUTE)
376  return nullptr;
377  return checked_reldate(per).m_description;
378 }

◆ gnc_relative_date_display_string()

const char* gnc_relative_date_display_string ( RelativeDatePeriod  )

Provide the string representation of a relative date for displaying value to a user.

This string is localizable.

Parameters
periodThe relative date period.
Returns
A constant string or nullptr if the period is ABSOLUTE. The string's lifetime will be that of the Relative Date Period. It must not be freed and should be copied if the period might be destroyed before the using code is finished.

Definition at line 366 of file gnc-option-date.cpp.

367 {
368  if (per == RelativeDatePeriod::ABSOLUTE)
369  return nullptr;
370  return checked_reldate(per).m_display;
371 }

◆ gnc_relative_date_from_storage_string()

RelativeDatePeriod gnc_relative_date_from_storage_string ( const char *  )

Convert a relative date storage string back to a RelativeDatePeriod value.

Parameters
Astring representation obtained from gnc_relative_date_storage_string.
Returns
A RelativeDatePeriod value.

Definition at line 381 of file gnc-option-date.cpp.

382 {
383  auto per = std::find_if(reldates.begin(), reldates.end(),
384  [str](auto rel) -> bool
385  {
386  return strcmp(str, rel.m_storage) == 0;
387  });
388  return per != reldates.end() ? per->m_period : RelativeDatePeriod::ABSOLUTE;
389 }

◆ gnc_relative_date_is_ending()

bool gnc_relative_date_is_ending ( RelativeDatePeriod  )

Report whether the relative date represents the end of a date range.

For example END_LAST_MONTH is the end of a range.

Parameters
periodThe Relative Date Period to check.
Returns
true if the date is the end of a date range.

Definition at line 350 of file gnc-option-date.cpp.

351 {
352  if (per == RelativeDatePeriod::ABSOLUTE)
353  return false;
354  return checked_reldate(per).m_type == RelativeDateType::END;
355 }

◆ gnc_relative_date_is_single()

bool gnc_relative_date_is_single ( RelativeDatePeriod  )

Report whether the relative date represents a period offset to today's date rather than the beginning or end of a date range.

For example ONE_MONTH_AGO will be made concrete as the same day as today in the previous month.

Parameters
periodThe Relative Date Period to check.
Returns
true if the date is stand-alone.

Definition at line 332 of file gnc-option-date.cpp.

333 {
334  if (per == RelativeDatePeriod::ABSOLUTE)
335  return false;
336  auto reldate = checked_reldate(per);
337  return reldate.m_type == RelativeDateType::LAST ||
338  reldate.m_type == RelativeDateType::NEXT;
339 }

◆ gnc_relative_date_is_starting()

bool gnc_relative_date_is_starting ( RelativeDatePeriod  )

Report whether the relative date represents the beginning of a date range.

For example START_LAST_MONTH is the beginning of a range.

Parameters
periodThe Relative Date Period to check.
Returns
true if the date is the beginning of a date range

Definition at line 342 of file gnc-option-date.cpp.

343 {
344  if (per == RelativeDatePeriod::ABSOLUTE)
345  return false;
346  return checked_reldate(per).m_type == RelativeDateType::START;
347 }

◆ gnc_relative_date_storage_string()

const char* gnc_relative_date_storage_string ( RelativeDatePeriod  )

Provide the string representation of a relative date for persisting the value.

This string is not localizable.

Parameters
periodThe relative date period.
Returns
A constant string or nullptr if the period is ABSOLUTE. The string's lifetime will be that of the Relative Date Period. It must not be freed and should be copied if the period might be destroyed before the using code is finished.

Definition at line 358 of file gnc-option-date.cpp.

359 {
360  if (per == RelativeDatePeriod::ABSOLUTE)
361  return nullptr;
362  return checked_reldate(per).m_storage;
363 }

◆ gnc_relative_date_to_time64()

time64 gnc_relative_date_to_time64 ( RelativeDatePeriod  )

Convert a RelativeDatePeriod value to a concrete time64 by applying the value to the current time.

For example if it is now 3:15:42 PM local time 3 June, calling this with a period RelativeDatePeriod::ONE_WEEK_AHEAD will return a time64 representing 3:15:42 PM local time 10 June of this year. Times for START periods are changed to midnight local time and for END periods to 23:59:59 local time so for example if the period is instead RelativeDatePeriod::START_THIS_MONTH the time64 will represent 00:00:00 1 June and if it is RelativeDatePeriod::END_THIS_MONTH the time64 will be for 23:59:59 30 June, both in the current time zone.

Parameters
periodThe relative date period to use to calculate the concrete date.
Returns
a time64.

Definition at line 492 of file gnc-option-date.cpp.

493 {
494  if (period == RelativeDatePeriod::TODAY)
495  return static_cast<time64>(GncDateTime());
496  if (period == RelativeDatePeriod::START_ACCOUNTING_PERIOD)
497  return gnc_accounting_period_fiscal_start();
498  if (period == RelativeDatePeriod::END_ACCOUNTING_PERIOD)
499  return gnc_accounting_period_fiscal_end();
500 
501  GncDateTime now_t;
502  if (period == RelativeDatePeriod::TODAY)
503  return static_cast<time64>(now_t);
504  auto now{static_cast<tm>(now_t)};
505  auto acct_per{static_cast<tm>(GncDateTime(gnc_accounting_period_fiscal_start()))};
506 
507  if (acct_per.tm_mon == now.tm_mon && acct_per.tm_mday == now.tm_mday)
508  {
509  //No set accounting period, use the calendar year
510  acct_per.tm_mon = 0;
511  acct_per.tm_mday = 0;
512  }
513 
514  switch(reldate_offset(period))
515  {
516  case RelativeDateOffset::NONE:
517 // Report on today so nothing to do
518  break;
519  case RelativeDateOffset::YEAR:
520  if (reldate_is_prev(period))
521  --now.tm_year;
522  else if (reldate_is_next(period))
523  ++now.tm_year;
524  if (gnc_relative_date_is_starting(period))
525  now.tm_mon = 0;
526  else if (gnc_relative_date_is_ending(period))
527  now.tm_mon = 11;
528  break;
529  case RelativeDateOffset::SIX:
530  if (reldate_is_prev(period))
531  now.tm_mon -= 6;
532  else if (reldate_is_next(period))
533  now.tm_mon += 6;
534  break;
535  case RelativeDateOffset::QUARTER:
536  {
537  auto delta = (now.tm_mon > acct_per.tm_mon ?
538  now.tm_mon - acct_per.tm_mon :
539  acct_per.tm_mon - now.tm_mon) % 3;
540  now.tm_mon = now.tm_mon - delta;
541  }
542  [[fallthrough]];
543  case RelativeDateOffset::THREE:
544  if (reldate_is_prev(period))
545  now.tm_mon -= 3;
546  else if (reldate_is_next(period))
547  now.tm_mon += 3;
548  if (gnc_relative_date_is_ending(period))
549  now.tm_mon += 2;
550  break;
551  case RelativeDateOffset::MONTH:
552  if (reldate_is_prev(period))
553  --now.tm_mon;
554  else if (reldate_is_next(period))
555  ++now.tm_mon;
556  break;
557  case RelativeDateOffset::WEEK:
558  if (reldate_is_prev(period))
559  now.tm_mday -= 7;
560  else if (reldate_is_next(period))
561  now.tm_mday += 7;
562  }
563  reldate_set_day_and_time(now, checked_reldate(period).m_type);
564  normalize_reldate_tm(now);
565  return static_cast<time64>(GncDateTime(now));
566 }
GnuCash DateTime class.
bool gnc_relative_date_is_ending(RelativeDatePeriod per)
Report whether the relative date represents the end of a date range.
bool gnc_relative_date_is_starting(RelativeDatePeriod per)
Report whether the relative date represents the beginning of a date range.
gint64 time64
Many systems, including Microsoft Windows and BSD-derived Unixes like Darwin, are retaining the int-3...
Definition: gnc-date.h:87

◆ operator<<()

std::ostream& operator<< ( std::ostream &  ,
const RelativeDatePeriod   
)

Add the display string to the provided std::ostream.

Parameters
streamthe std::ostream to which to write the period value
periodthe period value to write
Returns
A reference to stream so that the operator can be chained.

Definition at line 569 of file gnc-option-date.cpp.

570 {
571  ostr << "'reldate . " << gnc_relative_date_display_string(per);
572  return ostr;
573 }
const char * gnc_relative_date_display_string(RelativeDatePeriod per)
Provide the string representation of a relative date for displaying value to a user.

Variable Documentation

◆ relative_date_periods

constexpr unsigned relative_date_periods
Initial value:
=
static_cast<unsigned>(RelativeDatePeriod::END_ACCOUNTING_PERIOD) + 2

Definition at line 80 of file gnc-option-date.hpp.