GnuCash c935c2f+
Loading...
Searching...
No Matches
gnc-optiondb.hpp
Go to the documentation of this file.
1/********************************************************************\
2 * gnc-optiondb.hpp -- Collection of GncOption objects *
3 * Copyright (C) 2019 John Ralls <jralls@ceridwen.us> *
4 * *
5 * This program is free software; you can redistribute it and/or *
6 * modify it under the terms of the GNU General Public License as *
7 * published by the Free Software Foundation; either version 2 of *
8 * the License, or (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License*
16 * along with this program; if not, contact: *
17 * *
18 * Free Software Foundation Voice: +1-617-542-5942 *
19 * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
20 * Boston, MA 02110-1301, USA gnu@gnu.org *
21 * *
22\********************************************************************/
33#ifndef GNC_OPTIONDB_HPP_
34#define GNC_OPTIONDB_HPP_
35
36#include <string>
37#include <functional>
38#include <exception>
39#include <optional>
40#include <iostream>
41#include <cstdint>
42
43#include <config.h>
44#include "Account.h"
45#include "gnc-budget.h"
46#include "gnc-commodity.h"
47#include "gncInvoice.h"
48#include "gncTaxTable.h"
49#include "gnc-option.hpp"
50#include "gnc-datetime.hpp"
51
52
53class GncOptionDB;
54using GncOptionDBPtr = std::unique_ptr<GncOptionDB>;
55using GncOptionAccountList = std::vector<GncGUID>;
56
57using GncOptionAccountTypeList = std::vector<GNCAccountType>;
58using GncMultichoiceOptionEntry = std::tuple<const std::string,
59 const std::string,
60 GncOptionMultichoiceKeyType>;
61using GncMultichoiceOptionChoices = std::vector<GncMultichoiceOptionEntry>;
62
78GncOptionAccountList
80 const GncOptionAccountTypeList& types);
81
92void gnc_register_string_option(GncOptionDB* db, const char* section,
93 const char* name, const char* key,
94 const char* doc_string, std::string value);
95
99inline void gnc_register_string_option(const GncOptionDBPtr& db,
100 const char* section, const char* name,
101 const char* key, const char* doc_string,
102 std::string value)
103{
104 gnc_register_string_option(db.get(), section, name, key,
105 doc_string, value);
106}
107
118void gnc_register_text_option(GncOptionDB* db, const char* section,
119 const char* name, const char* key,
120 const char* doc_string, std::string value);
121
125inline void gnc_register_text_option(const GncOptionDBPtr& db,
126 const char* section,
127 const char* name, const char* key,
128 const char* doc_string, std::string value)
129{
130 gnc_register_text_option(db.get(), section, name, key, doc_string, value);
131}
132
143void gnc_register_font_option(GncOptionDB* db, const char* section,
144 const char* name, const char* key,
145 const char* doc_string, std::string value);
146
150inline void gnc_register_font_option(const GncOptionDBPtr& db,
151 const char* section, const char* name,
152 const char* key, const char* doc_string,
153 std::string value)
154{
155 gnc_register_font_option(db.get(), section, name, key, doc_string, value);
156}
157
168void gnc_register_budget_option(GncOptionDB* db, const char* section,
169 const char* name, const char* key,
170 const char* doc_string, GncBudget* value);
171
175inline void gnc_register_budget_option(const GncOptionDBPtr& db,
176 const char* section, const char* name,
177 const char* key, const char* doc_string,
178 GncBudget* value)
179{
180 gnc_register_budget_option(db.get(), section, name, key, doc_string, value);
181}
182
194 const char* section, const char* name,
195 const char* key, const char* doc_string,
196 gnc_commodity* value);
197
201inline void gnc_register_commodity_option(const GncOptionDBPtr& db,
202 const char* section,
203 const char* name, const char* key,
204 const char* doc_string,
205 gnc_commodity* value)
206{
207 gnc_register_commodity_option(db.get(), section, name, key,
208 doc_string, value);
209}
216 const char* section, const char* name,
217 const char* key, const char* doc_string,
218 const char* value);
219
223inline void gnc_register_commodity_option(const GncOptionDBPtr& db,
224 const char* section,
225 const char* name, const char* key,
226 const char* doc_string,
227 const char* value)
228{
229 gnc_register_commodity_option(db.get(), section, name, key,
230 doc_string, value);
231}
232
244 const char* section, const char* name,
245 const char* key, const char* doc_string,
246 bool value);
247
251inline void gnc_register_simple_boolean_option(const GncOptionDBPtr& db,
252 const char* section,
253 const char* name,
254 const char* key,
255 const char* doc_string,
256 bool value)
257{
258 gnc_register_simple_boolean_option(db.get(), section, name, key,
259 doc_string, value);
260}
261
272void gnc_register_pixmap_option(GncOptionDB* db, const char* section,
273 const char* name, const char* key,
274 const char* doc_string, std::string value);
275
279inline void gnc_register_pixmap_option(GncOptionDBPtr& db, const char* section,
280 const char* name, const char* key,
281 const char* doc_string,
282 std::string value)
283{
284 gnc_register_pixmap_option(db.get(), section, name, key, doc_string, value);
285}
286
299 const char* section,
300 const char* name, const char* key,
301 const char* doc_string,
302 const GncOptionAccountList& value,
303 GncOptionAccountTypeList&& allowed);
304
308inline void gnc_register_account_list_limited_option(GncOptionDBPtr& db,
309 const char* section,
310 const char* name, const char* key,
311 const char* doc_string,
312 const GncOptionAccountList& value,
313 GncOptionAccountTypeList&& allowed)
314{
315 gnc_register_account_list_limited_option(db.get(), section, name, key,
316 doc_string, value,
317 std::move(allowed));
318}
319
331 const char* section,
332 const char* name, const char* key,
333 const char* doc_string,
334 const GncOptionAccountList& value);
335
339inline void gnc_register_account_list_option(GncOptionDBPtr& db,
340 const char* section,
341 const char* name, const char* key,
342 const char* doc_string,
343 const GncOptionAccountList& value)
344{
345 gnc_register_account_list_option(db.get(), section, name, key,
346 doc_string, value);
347}
348
361 const char* section,
362 const char* name, const char* key,
363 const char* doc_string,
364 const Account* value,
365 GncOptionAccountTypeList&& allowed);
366
370inline void gnc_register_account_sel_limited_option(GncOptionDBPtr& db,
371 const char* section,
372 const char* name, const char* key,
373 const char* doc_string,
374 const Account* value,
375 GncOptionAccountTypeList&& allowed)
376{
377 gnc_register_account_sel_limited_option(db.get(), section, name, key,
378 doc_string, value,
379 std::move(allowed));
380}
381
393 const char* section, const char* name,
394 const char* key, const char* doc_string,
395 const char* default_val,
396 GncMultichoiceOptionChoices&& value);
397
401inline void gnc_register_multichoice_option(GncOptionDBPtr& db,
402 const char* section, const char* name,
403 const char* key, const char* doc_string,
404 const char* default_val,
405 GncMultichoiceOptionChoices&& value)
406{
407 gnc_register_multichoice_option(db.get(), section, name,
408 key, doc_string, default_val,
409 std::move(value));
410}
411
423void gnc_register_list_option(GncOptionDB* db, const char* section,
424 const char* name, const char* key,
425 const char* doc_string, const char* value,
426 GncMultichoiceOptionChoices&& list);
427
431inline void gnc_register_list_option(GncOptionDBPtr& db, const char* section,
432 const char* name, const char* key,
433 const char* doc_string, const char* value,
434 GncMultichoiceOptionChoices&& list)
435{
436 gnc_register_list_option(db.get(), section, name, key, doc_string,
437 value, std::move(list));
438}
439
455template <typename ValueType>
457 const char* section, const char* name,
458 const char* key, const char* doc_string,
459 ValueType value, ValueType min,
460 ValueType max, ValueType step);
461
465template <typename ValueType>
466void gnc_register_number_range_option(GncOptionDBPtr& db,
467 const char* section, const char* name,
468 const char* key, const char* doc_string,
469 ValueType value, ValueType min,
470 ValueType max, ValueType step)
471{
472 gnc_register_number_range_option<ValueType>(db.get(), section, name,
473 key, doc_string, value,
474 min, max, step);
475}
476
488 const char* section, const char* name,
489 const char* key,
490 const char* doc_string,
491 int value);
492
494 const char* section, const char* name,
495 const char* key,
496 const char* doc_string,
497 float value)
498{
499 gnc_register_number_plot_size_option(db, section, name, key,
500 doc_string, static_cast<int>(value));
501}
502
503
507inline void gnc_register_number_plot_size_option(const GncOptionDBPtr& db,
508 const char* section,
509 const char* name,
510 const char* key,
511 const char* doc_string,
512 int value)
513{
514 gnc_register_number_plot_size_option(db.get(), section, name, key,
515 doc_string, value);
516}
517
518inline void gnc_register_number_plot_size_option(const GncOptionDBPtr& db,
519 const char* section,
520 const char* name,
521 const char* key,
522 const char* doc_string,
523 float value)
524{
525 gnc_register_number_plot_size_option(db.get(), section, name, key,
526 doc_string, static_cast<int>(value));
527}
528
539void gnc_register_query_option(GncOptionDB* db, const char* section,
540 const char* name, const QofQuery* value);
541
545inline void gnc_register_query_option(GncOptionDBPtr& db, const char* section,
546 const char* name,
547 const QofQuery* value)
548{
549 gnc_register_query_option(db.get(), section, name, value);
550}
551
563void gnc_register_owner_option(GncOptionDB* db, const char* section,
564 const char* name, const char* key,
565 const char* doc_string, const GncOwner* value,
566 GncOwnerType type);
567
571inline void gnc_register_owner_option(GncOptionDBPtr& db, const char* section,
572 const char* name, const char* key,
573 const char* doc_string,
574 const GncOwner* value,
575 GncOwnerType type)
576{
577 gnc_register_owner_option(db.get(), section, name, key, doc_string, value, type);
578}
579
590void gnc_register_color_option(GncOptionDB* db, const char* section,
591 const char* name, const char* key,
592 const char* doc_string, std::string value);
593
597inline void gnc_register_color_option(GncOptionDBPtr& db, const char* section,
598 const char* name, const char* key,
599 const char* doc_string,
600 std::string value)
601{
602 gnc_register_color_option(db.get(), section, name, key, doc_string, value);
603}
604
605void gnc_register_internal_option(GncOptionDBPtr& db,
606 const char* section, const char* name,
607 const std::string& value);
608
609void gnc_register_internal_option(GncOptionDBPtr& db,
610 const char* section, const char* name,
611 bool value);
612
613void gnc_register_report_placement_option(GncOptionDBPtr& db,
614 const char* section, const char* name);
615
626void gnc_register_currency_option(GncOptionDB* db, const char* section,
627 const char* name, const char* key,
628 const char* doc_string, gnc_commodity* value);
629
633inline void gnc_register_currency_option(const GncOptionDBPtr& db,
634 const char* section,
635 const char* name, const char* key,
636 const char* doc_string,
637 gnc_commodity* value)
638{
639 gnc_register_currency_option(db.get(), section, name, key,
640 doc_string, value);
641}
642
648 const char* section,
649 const char* name, const char* key,
650 const char* doc_string,
651 const char* value);
652
653inline void gnc_register_currency_option(const GncOptionDBPtr& db,
654 const char* section,
655 const char* name, const char* key,
656 const char* doc_string,
657 const char* value)
658{
659 gnc_register_currency_option(db.get(), section, name, key,
660 doc_string, value);
661}
662
673void gnc_register_invoice_option(GncOptionDB* db, const char* section,
674 const char* name, const char* key,
675 const char* doc_string, GncInvoice* value);
676
680inline void gnc_register_invoice_option(const GncOptionDBPtr& db,
681 const char* section,
682 const char* name, const char* key,
683 const char* doc_string,
684 GncInvoice* value)
685{
686 gnc_register_invoice_option(db.get(), section, name, key,
687 doc_string, value);
688}
689
700void gnc_register_taxtable_option(GncOptionDB* db, const char* section,
701 const char* name, const char* key,
702 const char* doc_string, GncTaxTable* value);
703
707inline void gnc_register_taxtable_option(const GncOptionDBPtr& db,
708 const char* section, const char* name,
709 const char* key,
710 const char* doc_string,
711 GncTaxTable* value)
712{
713 gnc_register_taxtable_option(db.get(), section, name, key,
714 doc_string, value);
715}
716
726void gnc_register_invoice_print_report_option(GncOptionDB* db, const char* section,
727 const char* name, const char* key,
728 const char* doc_string, std::string value);
729
733inline void gnc_register_invoice_print_report_option(const GncOptionDBPtr& db,
734 const char* section, const char* name,
735 const char* key, const char* doc_string,
736 std::string value)
737{
738 gnc_register_invoice_print_report_option(db.get(), section, name, key,
739 doc_string, value);
740}
741
752void gnc_register_counter_option(GncOptionDB* db, const char* section,
753 const char* name, const char* key,
754 const char* doc_string, int value);
755
759inline void gnc_register_counter_option(const GncOptionDBPtr& db,
760 const char* section, const char* name,
761 const char* key, const char* doc_string,
762 double value)
763{
764 gnc_register_counter_option(db.get(), section, name, key,
765 doc_string, value);
766}
767
779 const char* section, const char* name,
780 const char* key, const char* doc_string,
781 std::string value);
782
786inline void gnc_register_counter_format_option(GncOptionDBPtr& db,
787 const char* section,
788 const char* name,
789 const char* key,
790 const char* doc_string,
791 std::string value)
792{
793 gnc_register_counter_format_option(db.get(), section, name, key,
794 doc_string, value);
795}
796
808 const char* section, const char* name,
809 const char* key, const char* doc_string,
810 GncOptionDateFormat&& value);
811
815inline void gnc_register_dateformat_option(GncOptionDBPtr& db,
816 const char* section,
817 const char* name, const char* key,
818 const char* doc_string,
819 GncOptionDateFormat&& value)
820{
821 gnc_register_dateformat_option(db.get(), section, name, key,
822 doc_string, std::move(value));
823}
824
825enum RelativeDateUI : uint8_t
826{
827 ABSOLUTE,
828 RELATIVE,
829 BOTH
830};
831
843void gnc_register_date_option(GncOptionDB* db, const char* section,
844 const char* name, const char* key,
845 const char* doc_string,
846 RelativeDatePeriod period =
847 RelativeDatePeriod::TODAY,
848 RelativeDateUI ui = RelativeDateUI::BOTH);
849
853inline void gnc_register_date_option(GncOptionDBPtr& db, const char* section,
854 const char* name, const char* key,
855 const char* doc_string,
856 RelativeDatePeriod period =
857 RelativeDatePeriod::TODAY,
858 RelativeDateUI ui = RelativeDateUI::BOTH)
859{
860 gnc_register_date_option(db.get(), section, name, key, doc_string,
861 period, ui);
862}
863
875void gnc_register_date_option(GncOptionDB* db, const char* section,
876 const char* name, const char* key,
877 const char* doc_string, time64 time,
878 RelativeDateUI ui = RelativeDateUI::BOTH);
879
883inline void gnc_register_date_option(GncOptionDBPtr& db, const char* section,
884 const char* name, const char* key,
885 const char* doc_string, time64 time,
886 RelativeDateUI ui = RelativeDateUI::BOTH)
887{
888 gnc_register_date_option(db.get(), section, name, key, doc_string,
889 time, ui);
890}
891
903void gnc_register_date_option(GncOptionDB* db, const char* section,
904 const char* name, const char* key,
905 const char* doc_string,
906 RelativeDatePeriodVec& period_set,
907 bool both = true);
908
912inline void gnc_register_date_option(GncOptionDBPtr& db, const char* section,
913 const char* name, const char* key,
914 const char* doc_string,
915 RelativeDatePeriodVec& period_set,
916 bool both = true)
917{
918 gnc_register_date_option(db.get(), section, name, key, doc_string,
919 period_set, both);
920}
921
933 const char* section,
934 const char* name, const char* key,
935 const char* doc_string, bool both = true);
936
940inline void gnc_register_start_date_option(GncOptionDBPtr& db,
941 const char* section,
942 const char* name, const char* key,
943 const char* doc_string, bool both = true)
944{
945 gnc_register_start_date_option(db.get(), section, name, key, doc_string,
946 both);
947}
948
959void gnc_register_end_date_option(GncOptionDB* db, const char* section,
960 const char* name, const char* key,
961 const char* doc_string, bool both = true);
962
966inline void gnc_register_end_date_option(GncOptionDBPtr& db, const char* section,
967 const char* name, const char* key,
968 const char* doc_string, bool both = true)
969{
970 gnc_register_end_date_option(db.get(), section, name, key, doc_string,
971 both);
972}
973
974
975
976#endif //GNC_OPTIONDB_HPP_
Account handling public routines.
Holds all of the options for a book, report, or stylesheet, organized by GncOptionSections.
GnuCash Budgets.
Commodity handling public routines.
C++ Public interface for individual options.
Business Invoice Interface.
Tax Table programming interface.
gint64 time64
Most systems that are currently maintained, including Microsoft Windows, BSD-derived Unixes and Linux...
Definition gnc-date.h:87
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.
void gnc_register_dateformat_option(GncOptionDB *db, const char *section, const char *name, const char *key, const char *doc_string, GncOptionDateFormat &&value)
Create a new date 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.
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.
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.
RelativeDatePeriod
Reporting periods relative to the current date.
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_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.
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.
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_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.
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.
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.
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_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.
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.
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.
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_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.
void gnc_register_counter_option(GncOptionDB *db, const char *section, const char *name, const char *key, const char *doc_string, int value)
Create a new counter option and register it in the options database.
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.
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_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.
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.
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.
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.
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.
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.
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.
STRUCTS.
modtime is the internal date of the last modtime See libgnucash/engine/TaxTableBillTermImmutability....
QofBook reference.
Definition qofbook-p.hpp:47
A Query.
Definition qofquery.cpp:75