Skip to content

Commit

Permalink
[gncTaxTable.cpp] convert to c++
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherlam committed Jul 23, 2024
1 parent 272c1be commit ecdcba5
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 22 deletions.
2 changes: 1 addition & 1 deletion libgnucash/engine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ set (engine_SOURCES
gncJob.c
gncOrder.c
gncOwner.cpp
gncTaxTable.c
gncTaxTable.cpp
gncVendor.cpp
kvp-frame.cpp
kvp-value.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ maybe_resort_list (GncTaxTable *table)
struct _book_info *bi;

if (table->parent || table->invisible) return;
bi = qof_book_get_data (qof_instance_get_book(table), _GNC_MOD_NAME);
bi = static_cast<_book_info*>(qof_book_get_data (qof_instance_get_book(table), _GNC_MOD_NAME));
bi->tables = g_list_sort (bi->tables, (GCompareFunc)gncTaxTableCompare);
}

Expand All @@ -167,15 +167,15 @@ mod_table (GncTaxTable *table)
static inline void addObj (GncTaxTable *table)
{
struct _book_info *bi;
bi = qof_book_get_data (qof_instance_get_book(table), _GNC_MOD_NAME);
bi = static_cast<_book_info*>(qof_book_get_data (qof_instance_get_book(table), _GNC_MOD_NAME));
bi->tables = g_list_insert_sorted (bi->tables, table,
(GCompareFunc)gncTaxTableCompare);
}

static inline void remObj (GncTaxTable *table)
{
struct _book_info *bi;
bi = qof_book_get_data (qof_instance_get_book(table), _GNC_MOD_NAME);
bi = static_cast<_book_info*>(qof_book_get_data (qof_instance_get_book(table), _GNC_MOD_NAME));
bi->tables = g_list_remove (bi->tables, table);
}

Expand Down Expand Up @@ -322,7 +322,7 @@ impl_refers_to_object(const QofInstance* inst, const QofInstance* ref)

for (node = tt->entries; node != NULL; node = node->next)
{
GncTaxTableEntry* tte = node->data;
GncTaxTableEntry* tte = static_cast<GncTaxTableEntry*>(node->data);

if (tte->account == GNC_ACCOUNT(ref))
{
Expand Down Expand Up @@ -408,7 +408,7 @@ gncTaxTableCreate (QofBook *book)
GncTaxTable *table;
if (!book) return NULL;

table = g_object_new (GNC_TYPE_TAXTABLE, NULL);
table = GNC_TAXTABLE(g_object_new (GNC_TYPE_TAXTABLE, NULL));
qof_instance_init_data (&table->inst, _GNC_MOD_NAME, book);
table->name = CACHE_INSERT ("");
addObj (table);
Expand Down Expand Up @@ -438,9 +438,7 @@ gncTaxTableFree (GncTaxTable *table)
remObj (table);

/* destroy the list of entries */
for (list = table->entries; list; list = list->next)
gncTaxTableEntryDestroy (list->data);
g_list_free (table->entries);
g_list_free_full (table->entries, (GDestroyNotify)gncTaxTableEntryDestroy);

if (!qof_instance_get_destroying(table))
PERR("free a taxtable without do_free set!");
Expand All @@ -452,7 +450,7 @@ gncTaxTableFree (GncTaxTable *table)
/* disconnect from the children */
for (list = table->children; list; list = list->next)
{
child = list->data;
child = GNC_TAXTABLE(list->data);
gncTaxTableSetParent(child, NULL);
}
g_list_free(table->children);
Expand Down Expand Up @@ -550,7 +548,7 @@ void gncTaxTableMakeInvisible (GncTaxTable *table)
if (!table) return;
gncTaxTableBeginEdit (table);
table->invisible = TRUE;
bi = qof_book_get_data (qof_instance_get_book(table), _GNC_MOD_NAME);
bi = static_cast<_book_info*>(qof_book_get_data (qof_instance_get_book(table), _GNC_MOD_NAME));
bi->tables = g_list_remove (bi->tables, table);
gncTaxTableCommitEdit (table);
}
Expand Down Expand Up @@ -670,9 +668,9 @@ GncTaxTable *gncTaxTableLookupByName (QofBook *book, const char *name)

for ( ; list; list = list->next)
{
GncTaxTable *table = list->data;
GncTaxTable *table = GNC_TAXTABLE(list->data);
if (!g_strcmp0 (table->name, name))
return list->data;
return table;
}
return NULL;
}
Expand Down Expand Up @@ -703,7 +701,7 @@ GncTaxTableList * gncTaxTableGetTables (QofBook *book)
struct _book_info *bi;
if (!book) return NULL;

bi = qof_book_get_data (book, _GNC_MOD_NAME);
bi = static_cast<_book_info*>(qof_book_get_data (book, _GNC_MOD_NAME));
return bi ? bi->tables : NULL;
}

Expand Down Expand Up @@ -737,7 +735,7 @@ static GncTaxTable *gncTaxTableCopy (const GncTaxTable *table)
for (list = table->entries; list; list = list->next)
{
GncTaxTableEntry *entry, *e;
entry = list->data;
entry = static_cast<GncTaxTableEntry*>(list->data);
e = gncTaxTableEntryCopy (entry);
/* Clang static analyzer thinks we're leaking e, but we're not.
* We're transferring it to table. */
Expand Down Expand Up @@ -800,7 +798,7 @@ Account * gncTaxTableEntryGetAccount (const GncTaxTableEntry *entry)

GncAmountType gncTaxTableEntryGetType (const GncTaxTableEntry *entry)
{
if (!entry) return 0;
if (!entry) return GncAmountType(0);
return entry->type;
}

Expand Down Expand Up @@ -950,7 +948,7 @@ GList *gncAccountValueAdd (GList *list, Account *acc, gnc_numeric value)
/* Try to find the account in the list */
for (li = list; li; li = li->next)
{
res = li->data;
res = static_cast<GncAccountValue*>(li->data);
if (res->account == acc)
{
res->value = gnc_numeric_add (res->value, value, GNC_DENOM_AUTO,
Expand All @@ -973,7 +971,7 @@ GList *gncAccountValueAddList (GList *l1, GList *l2)

for (li = l2; li; li = li->next )
{
GncAccountValue *val = li->data;
GncAccountValue *val = static_cast<GncAccountValue*>(li->data);
l1 = gncAccountValueAdd (l1, val->account, val->value);
}

Expand All @@ -987,7 +985,7 @@ gnc_numeric gncAccountValueTotal (GList *list)

for ( ; list ; list = list->next)
{
GncAccountValue *val = list->data;
GncAccountValue *val = static_cast<GncAccountValue*>(list->data);
total = gnc_numeric_add (total, val->value, GNC_DENOM_AUTO, GNC_HOW_DENOM_REDUCE | GNC_HOW_RND_ROUND_HALF_UP);
}
return total;
Expand Down Expand Up @@ -1031,7 +1029,7 @@ static void _gncTaxTableDestroy (QofBook *book)

if (!book) return;

bi = qof_book_get_data (book, _GNC_MOD_NAME);
bi = static_cast<_book_info*>(qof_book_get_data (book, _GNC_MOD_NAME));

col = qof_book_get_collection (book, GNC_ID_TAXTABLE);
qof_collection_foreach (col, destroy_taxtable_on_book_close, NULL);
Expand All @@ -1045,7 +1043,7 @@ static QofObject gncTaxTableDesc =
DI(.interface_version = ) QOF_OBJECT_VERSION,
DI(.e_type = ) _GNC_MOD_NAME,
DI(.type_label = ) "Tax Table",
DI(.create = ) (gpointer)gncTaxTableCreate,
DI(.create = ) (void* (*)(QofBook*))gncTaxTableCreate,
DI(.book_begin = ) _gncTaxTableCreate,
DI(.book_end = ) _gncTaxTableDestroy,
DI(.is_dirty = ) qof_collection_is_dirty,
Expand Down
2 changes: 1 addition & 1 deletion po/POTFILES.in
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ libgnucash/engine/gncOwner.cpp
libgnucash/engine/gnc-pricedb.cpp
libgnucash/engine/gnc-rational.cpp
libgnucash/engine/gnc-session.c
libgnucash/engine/gncTaxTable.c
libgnucash/engine/gncTaxTable.cpp
libgnucash/engine/gnc-timezone.cpp
libgnucash/engine/gnc-uri-utils.c
libgnucash/engine/gncVendor.cpp
Expand Down

0 comments on commit ecdcba5

Please sign in to comment.