mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
[gnc-pricedb.cpp] convert to cpp
This commit is contained in:
@@ -170,7 +170,7 @@ set (engine_SOURCES
|
|||||||
gnc-option.cpp
|
gnc-option.cpp
|
||||||
gnc-option-impl.cpp
|
gnc-option-impl.cpp
|
||||||
gnc-optiondb.cpp
|
gnc-optiondb.cpp
|
||||||
gnc-pricedb.c
|
gnc-pricedb.cpp
|
||||||
gnc-rational.cpp
|
gnc-rational.cpp
|
||||||
gnc-session.c
|
gnc-session.c
|
||||||
gnc-timezone.cpp
|
gnc-timezone.cpp
|
||||||
|
|||||||
@@ -204,17 +204,17 @@ gnc_price_set_property(GObject* object, guint prop_id, const GValue* value, GPar
|
|||||||
gnc_price_set_typestr(price, g_value_get_string(value));
|
gnc_price_set_typestr(price, g_value_get_string(value));
|
||||||
break;
|
break;
|
||||||
case PROP_VALUE:
|
case PROP_VALUE:
|
||||||
number = g_value_get_boxed(value);
|
number = static_cast<gnc_numeric*>(g_value_get_boxed(value));
|
||||||
gnc_price_set_value(price, *number);
|
gnc_price_set_value(price, *number);
|
||||||
break;
|
break;
|
||||||
case PROP_COMMODITY:
|
case PROP_COMMODITY:
|
||||||
gnc_price_set_commodity(price, g_value_get_object(value));
|
gnc_price_set_commodity(price, static_cast<gnc_commodity*>(g_value_get_object(value)));
|
||||||
break;
|
break;
|
||||||
case PROP_CURRENCY:
|
case PROP_CURRENCY:
|
||||||
gnc_price_set_currency(price, g_value_get_object(value));
|
gnc_price_set_currency(price, static_cast<gnc_commodity*>(g_value_get_object(value)));
|
||||||
break;
|
break;
|
||||||
case PROP_DATE:
|
case PROP_DATE:
|
||||||
time = g_value_get_boxed(value);
|
time = static_cast<Time64*>(g_value_get_boxed(value));
|
||||||
gnc_price_set_time64(price, time->t);
|
gnc_price_set_time64(price, time->t);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -311,7 +311,7 @@ gnc_price_create (QofBook *book)
|
|||||||
g_return_val_if_fail (book, NULL);
|
g_return_val_if_fail (book, NULL);
|
||||||
|
|
||||||
ENTER(" ");
|
ENTER(" ");
|
||||||
p = g_object_new(GNC_TYPE_PRICE, NULL);
|
p = static_cast<GNCPrice*>(g_object_new(GNC_TYPE_PRICE, NULL));
|
||||||
|
|
||||||
qof_instance_init_data (&p->inst, GNC_ID_PRICE, book);
|
qof_instance_init_data (&p->inst, GNC_ID_PRICE, book);
|
||||||
qof_event_gen (&p->inst, QOF_EVENT_CREATE, NULL);
|
qof_event_gen (&p->inst, QOF_EVENT_CREATE, NULL);
|
||||||
@@ -543,7 +543,7 @@ gnc_price_set_source_string(GNCPrice *p, const char* str)
|
|||||||
{
|
{
|
||||||
if (!p) return;
|
if (!p) return;
|
||||||
for (PriceSource s = PRICE_SOURCE_EDIT_DLG;
|
for (PriceSource s = PRICE_SOURCE_EDIT_DLG;
|
||||||
s < PRICE_SOURCE_INVALID; ++s)
|
s < PRICE_SOURCE_INVALID; s = PriceSource(s + 1))
|
||||||
if (strcmp(source_names[s], str) == 0)
|
if (strcmp(source_names[s], str) == 0)
|
||||||
{
|
{
|
||||||
gnc_price_set_source(p, s);
|
gnc_price_set_source(p, s);
|
||||||
@@ -813,7 +813,7 @@ gnc_price_list_equal(PriceList *prices1, PriceList *prices2)
|
|||||||
PINFO ("prices1 has extra prices");
|
PINFO ("prices1 has extra prices");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (!gnc_price_equal (n1->data, n2->data))
|
if (!gnc_price_equal (static_cast<GNCPrice*>(n1->data), static_cast<GNCPrice*>(n2->data)))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
n1 = n1->next;
|
n1 = n1->next;
|
||||||
@@ -865,14 +865,14 @@ gnc_pricedb_create(QofBook * book)
|
|||||||
* then use that. Warn user, they shouldn't be creating two ...
|
* then use that. Warn user, they shouldn't be creating two ...
|
||||||
*/
|
*/
|
||||||
col = qof_book_get_collection (book, GNC_ID_PRICEDB);
|
col = qof_book_get_collection (book, GNC_ID_PRICEDB);
|
||||||
result = qof_collection_get_data (col);
|
result = static_cast<GNCPriceDB*>(qof_collection_get_data (col));
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
PWARN ("A price database already exists for this book!");
|
PWARN ("A price database already exists for this book!");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = g_object_new(GNC_TYPE_PRICEDB, NULL);
|
result = static_cast<GNCPriceDB*>(g_object_new(GNC_TYPE_PRICEDB, NULL));
|
||||||
qof_instance_init_data (&result->inst, GNC_ID_PRICEDB, book);
|
qof_instance_init_data (&result->inst, GNC_ID_PRICEDB, book);
|
||||||
qof_collection_mark_clean(col);
|
qof_collection_mark_clean(col);
|
||||||
|
|
||||||
@@ -897,7 +897,7 @@ destroy_pricedb_currency_hash_data(gpointer key,
|
|||||||
|
|
||||||
for (node = price_list; node; node = node->next)
|
for (node = price_list; node; node = node->next)
|
||||||
{
|
{
|
||||||
p = node->data;
|
p = static_cast<GNCPrice*>(node->data);
|
||||||
|
|
||||||
p->db = NULL;
|
p->db = NULL;
|
||||||
}
|
}
|
||||||
@@ -959,7 +959,7 @@ GNCPriceDB *
|
|||||||
gnc_collection_get_pricedb(QofCollection *col)
|
gnc_collection_get_pricedb(QofCollection *col)
|
||||||
{
|
{
|
||||||
if (!col) return NULL;
|
if (!col) return NULL;
|
||||||
return qof_collection_get_data (col);
|
return static_cast<GNCPriceDB*>(qof_collection_get_data (col));
|
||||||
}
|
}
|
||||||
|
|
||||||
GNCPriceDB *
|
GNCPriceDB *
|
||||||
@@ -977,7 +977,7 @@ gnc_pricedb_get_db(QofBook *book)
|
|||||||
static gboolean
|
static gboolean
|
||||||
num_prices_helper (GNCPrice *p, gpointer user_data)
|
num_prices_helper (GNCPrice *p, gpointer user_data)
|
||||||
{
|
{
|
||||||
guint *count = user_data;
|
auto count = static_cast<guint*>(user_data);
|
||||||
|
|
||||||
*count += 1;
|
*count += 1;
|
||||||
|
|
||||||
@@ -1010,14 +1010,12 @@ typedef struct
|
|||||||
static void
|
static void
|
||||||
pricedb_equal_foreach_pricelist(gpointer key, gpointer val, gpointer user_data)
|
pricedb_equal_foreach_pricelist(gpointer key, gpointer val, gpointer user_data)
|
||||||
{
|
{
|
||||||
GNCPriceDBEqualData *equal_data = user_data;
|
auto equal_data = static_cast<GNCPriceDBEqualData*>(user_data);
|
||||||
gnc_commodity *currency = key;
|
auto currency = static_cast<gnc_commodity*>(key);
|
||||||
GList *price_list1 = val;
|
auto price_list1 = static_cast<GList*>(val);
|
||||||
GList *price_list2;
|
auto price_list2 = gnc_pricedb_get_prices (equal_data->db2,
|
||||||
|
equal_data->commodity,
|
||||||
price_list2 = gnc_pricedb_get_prices (equal_data->db2,
|
currency);
|
||||||
equal_data->commodity,
|
|
||||||
currency);
|
|
||||||
|
|
||||||
if (!gnc_price_list_equal (price_list1, price_list2))
|
if (!gnc_price_list_equal (price_list1, price_list2))
|
||||||
equal_data->equal = FALSE;
|
equal_data->equal = FALSE;
|
||||||
@@ -1029,10 +1027,10 @@ static void
|
|||||||
pricedb_equal_foreach_currencies_hash (gpointer key, gpointer val,
|
pricedb_equal_foreach_currencies_hash (gpointer key, gpointer val,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
GHashTable *currencies_hash = val;
|
auto currencies_hash = static_cast<GHashTable*>(val);
|
||||||
GNCPriceDBEqualData *equal_data = user_data;
|
auto equal_data = static_cast<GNCPriceDBEqualData *>(user_data);
|
||||||
|
|
||||||
equal_data->commodity = key;
|
equal_data->commodity = static_cast<gnc_commodity*>(key);
|
||||||
|
|
||||||
g_hash_table_foreach (currencies_hash,
|
g_hash_table_foreach (currencies_hash,
|
||||||
pricedb_equal_foreach_pricelist,
|
pricedb_equal_foreach_pricelist,
|
||||||
@@ -1127,14 +1125,14 @@ add_price(GNCPriceDB *db, GNCPrice *p)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
currency_hash = g_hash_table_lookup(db->commodity_hash, commodity);
|
currency_hash = static_cast<GHashTable*>(g_hash_table_lookup(db->commodity_hash, commodity));
|
||||||
if (!currency_hash)
|
if (!currency_hash)
|
||||||
{
|
{
|
||||||
currency_hash = g_hash_table_new(NULL, NULL);
|
currency_hash = g_hash_table_new(NULL, NULL);
|
||||||
g_hash_table_insert(db->commodity_hash, commodity, currency_hash);
|
g_hash_table_insert(db->commodity_hash, commodity, currency_hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
price_list = g_hash_table_lookup(currency_hash, currency);
|
price_list = static_cast<GList*>(g_hash_table_lookup(currency_hash, currency));
|
||||||
if (!gnc_price_list_insert(&price_list, p, !db->bulk_update))
|
if (!gnc_price_list_insert(&price_list, p, !db->bulk_update))
|
||||||
{
|
{
|
||||||
LEAVE ("gnc_price_list_insert failed");
|
LEAVE ("gnc_price_list_insert failed");
|
||||||
@@ -1226,7 +1224,7 @@ remove_price(GNCPriceDB *db, GNCPrice *p, gboolean cleanup)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
currency_hash = g_hash_table_lookup(db->commodity_hash, commodity);
|
currency_hash = static_cast<GHashTable*>(g_hash_table_lookup(db->commodity_hash, commodity));
|
||||||
if (!currency_hash)
|
if (!currency_hash)
|
||||||
{
|
{
|
||||||
LEAVE (" no currency hash");
|
LEAVE (" no currency hash");
|
||||||
@@ -1234,7 +1232,7 @@ remove_price(GNCPriceDB *db, GNCPrice *p, gboolean cleanup)
|
|||||||
}
|
}
|
||||||
|
|
||||||
qof_event_gen (&p->inst, QOF_EVENT_REMOVE, NULL);
|
qof_event_gen (&p->inst, QOF_EVENT_REMOVE, NULL);
|
||||||
price_list = g_hash_table_lookup(currency_hash, currency);
|
price_list = static_cast<GList*>(g_hash_table_lookup(currency_hash, currency));
|
||||||
gnc_price_ref(p);
|
gnc_price_ref(p);
|
||||||
if (!gnc_price_list_remove(&price_list, p))
|
if (!gnc_price_list_remove(&price_list, p))
|
||||||
{
|
{
|
||||||
@@ -1317,7 +1315,7 @@ typedef struct
|
|||||||
static gboolean
|
static gboolean
|
||||||
check_one_price_date (GNCPrice *price, gpointer user_data)
|
check_one_price_date (GNCPrice *price, gpointer user_data)
|
||||||
{
|
{
|
||||||
remove_info *data = user_data;
|
auto data = static_cast<remove_info*>(user_data);
|
||||||
PriceSource source;
|
PriceSource source;
|
||||||
time64 time;
|
time64 time;
|
||||||
|
|
||||||
@@ -1507,7 +1505,7 @@ gnc_pricedb_process_removal_list (GNCPriceDB *db, GDate *fiscal_end_date,
|
|||||||
|
|
||||||
// get the fiscal start month
|
// get the fiscal start month
|
||||||
g_date_subtract_months (tmp_date, 12);
|
g_date_subtract_months (tmp_date, 12);
|
||||||
fiscal_month_start = g_date_get_month (tmp_date) + 1;
|
fiscal_month_start = static_cast<GDateMonth>(g_date_get_month (tmp_date) + 1);
|
||||||
g_date_free (tmp_date);
|
g_date_free (tmp_date);
|
||||||
|
|
||||||
// sort the list by commodity / currency / date
|
// sort the list by commodity / currency / date
|
||||||
@@ -1518,25 +1516,26 @@ gnc_pricedb_process_removal_list (GNCPriceDB *db, GDate *fiscal_end_date,
|
|||||||
{
|
{
|
||||||
GDate saved_price_date;
|
GDate saved_price_date;
|
||||||
GDate next_price_date;
|
GDate next_price_date;
|
||||||
|
auto price = static_cast<GNCPrice*>(item->data);
|
||||||
|
|
||||||
// Keep None
|
// Keep None
|
||||||
if (keep == PRICE_REMOVE_KEEP_NONE)
|
if (keep == PRICE_REMOVE_KEEP_NONE)
|
||||||
{
|
{
|
||||||
gnc_pricedb_remove_old_prices_pinfo (item->data, FALSE);
|
gnc_pricedb_remove_old_prices_pinfo (price, FALSE);
|
||||||
gnc_pricedb_remove_price (db, item->data);
|
gnc_pricedb_remove_price (db, price);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
save_first_price = !price_commodity_and_currency_equal (item->data, cloned_price); // Not Equal
|
save_first_price = !price_commodity_and_currency_equal (price, cloned_price); // Not Equal
|
||||||
if (save_first_price == TRUE)
|
if (save_first_price == TRUE)
|
||||||
{
|
{
|
||||||
clone_price (&cloned_price, item->data);
|
clone_price (&cloned_price, price);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the price dates
|
// get the price dates
|
||||||
saved_price_date = time64_to_gdate (gnc_price_get_time64 (cloned_price));
|
saved_price_date = time64_to_gdate (gnc_price_get_time64 (cloned_price));
|
||||||
next_price_date = time64_to_gdate (gnc_price_get_time64 (item->data));
|
next_price_date = time64_to_gdate (gnc_price_get_time64 (price));
|
||||||
|
|
||||||
// Keep last price in fiscal year
|
// Keep last price in fiscal year
|
||||||
if (keep == PRICE_REMOVE_KEEP_LAST_PERIOD && save_first_price == FALSE)
|
if (keep == PRICE_REMOVE_KEEP_LAST_PERIOD && save_first_price == FALSE)
|
||||||
@@ -1591,11 +1590,11 @@ gnc_pricedb_process_removal_list (GNCPriceDB *db, GDate *fiscal_end_date,
|
|||||||
// Now compare the values
|
// Now compare the values
|
||||||
if (saved_test_value == next_test_value)
|
if (saved_test_value == next_test_value)
|
||||||
{
|
{
|
||||||
gnc_pricedb_remove_old_prices_pinfo (item->data, FALSE);
|
gnc_pricedb_remove_old_prices_pinfo (price, FALSE);
|
||||||
gnc_pricedb_remove_price (db, item->data);
|
gnc_pricedb_remove_price (db, price);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
clone_price (&cloned_price, item->data);
|
clone_price (&cloned_price, price);
|
||||||
}
|
}
|
||||||
if (cloned_price)
|
if (cloned_price)
|
||||||
gnc_price_unref (cloned_price);
|
gnc_price_unref (cloned_price);
|
||||||
@@ -1634,7 +1633,7 @@ gnc_pricedb_remove_old_prices (GNCPriceDB *db, GList *comm_list,
|
|||||||
// Walk the list of commodities
|
// Walk the list of commodities
|
||||||
for (node = g_list_first (comm_list); node; node = g_list_next (node))
|
for (node = g_list_first (comm_list); node; node = g_list_next (node))
|
||||||
{
|
{
|
||||||
GHashTable *currencies_hash = g_hash_table_lookup (db->commodity_hash, node->data);
|
auto currencies_hash = static_cast<GHashTable*>(g_hash_table_lookup (db->commodity_hash, node->data));
|
||||||
g_hash_table_foreach (currencies_hash, pricedb_remove_foreach_pricelist, &data);
|
g_hash_table_foreach (currencies_hash, pricedb_remove_foreach_pricelist, &data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1652,13 +1651,13 @@ gnc_pricedb_remove_old_prices (GNCPriceDB *db, GList *comm_list,
|
|||||||
{
|
{
|
||||||
GDateYear year_now = g_date_get_year (gnc_g_date_new_today ());
|
GDateYear year_now = g_date_get_year (gnc_g_date_new_today ());
|
||||||
fiscal_end_date = g_date_new ();
|
fiscal_end_date = g_date_new ();
|
||||||
g_date_set_dmy (fiscal_end_date, 31, 12, year_now);
|
g_date_set_dmy (fiscal_end_date, 31, GDateMonth(12), year_now);
|
||||||
}
|
}
|
||||||
else if (g_date_valid (fiscal_end_date) == FALSE)
|
else if (g_date_valid (fiscal_end_date) == FALSE)
|
||||||
{
|
{
|
||||||
GDateYear year_now = g_date_get_year (gnc_g_date_new_today ());
|
GDateYear year_now = g_date_get_year (gnc_g_date_new_today ());
|
||||||
g_date_clear (fiscal_end_date, 1);
|
g_date_clear (fiscal_end_date, 1);
|
||||||
g_date_set_dmy (fiscal_end_date, 31, 12, year_now);
|
g_date_set_dmy (fiscal_end_date, 31, GDateMonth(12), year_now);
|
||||||
}
|
}
|
||||||
gnc_pricedb_process_removal_list (db, fiscal_end_date, data, keep);
|
gnc_pricedb_process_removal_list (db, fiscal_end_date, data, keep);
|
||||||
|
|
||||||
@@ -1675,16 +1674,16 @@ static PriceList *pricedb_price_list_merge (PriceList *a, PriceList *b);
|
|||||||
static void
|
static void
|
||||||
hash_values_helper(gpointer key, gpointer value, gpointer data)
|
hash_values_helper(gpointer key, gpointer value, gpointer data)
|
||||||
{
|
{
|
||||||
GList ** l = data;
|
auto l = static_cast<GList**>(data);
|
||||||
if (*l)
|
if (*l)
|
||||||
{
|
{
|
||||||
GList *new_l;
|
GList *new_l;
|
||||||
new_l = pricedb_price_list_merge(*l, value);
|
new_l = pricedb_price_list_merge(*l, static_cast<PriceList*>(value));
|
||||||
g_list_free (*l);
|
g_list_free (*l);
|
||||||
*l = new_l;
|
*l = new_l;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
*l = g_list_copy (value);
|
*l = g_list_copy (static_cast<GList*>(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
static PriceList *
|
static PriceList *
|
||||||
@@ -1693,7 +1692,7 @@ price_list_from_hashtable (GHashTable *hash, const gnc_commodity *currency)
|
|||||||
GList *price_list = NULL, *result = NULL ;
|
GList *price_list = NULL, *result = NULL ;
|
||||||
if (currency)
|
if (currency)
|
||||||
{
|
{
|
||||||
price_list = g_hash_table_lookup(hash, currency);
|
price_list = static_cast<GList*>(g_hash_table_lookup(hash, currency));
|
||||||
if (!price_list)
|
if (!price_list)
|
||||||
{
|
{
|
||||||
LEAVE (" no price list");
|
LEAVE (" no price list");
|
||||||
@@ -1750,9 +1749,9 @@ pricedb_get_prices_internal(GNCPriceDB *db, const gnc_commodity *commodity,
|
|||||||
PriceList *forward_list = NULL, *reverse_list = NULL;
|
PriceList *forward_list = NULL, *reverse_list = NULL;
|
||||||
g_return_val_if_fail (db != NULL, NULL);
|
g_return_val_if_fail (db != NULL, NULL);
|
||||||
g_return_val_if_fail (commodity != NULL, NULL);
|
g_return_val_if_fail (commodity != NULL, NULL);
|
||||||
forward_hash = g_hash_table_lookup(db->commodity_hash, commodity);
|
forward_hash = static_cast<GHashTable*>(g_hash_table_lookup(db->commodity_hash, commodity));
|
||||||
if (currency && bidi)
|
if (currency && bidi)
|
||||||
reverse_hash = g_hash_table_lookup(db->commodity_hash, currency);
|
reverse_hash = static_cast<GHashTable*>(g_hash_table_lookup(db->commodity_hash, currency));
|
||||||
if (!forward_hash && !reverse_hash)
|
if (!forward_hash && !reverse_hash)
|
||||||
{
|
{
|
||||||
LEAVE (" no currency hash");
|
LEAVE (" no currency hash");
|
||||||
@@ -1803,7 +1802,7 @@ GNCPrice *gnc_pricedb_lookup_latest(GNCPriceDB *db,
|
|||||||
/* This works magically because prices are inserted in date-sorted
|
/* This works magically because prices are inserted in date-sorted
|
||||||
* order, and the latest date always comes first. So return the
|
* order, and the latest date always comes first. So return the
|
||||||
* first in the list. */
|
* first in the list. */
|
||||||
result = price_list->data;
|
result = static_cast<GNCPrice*>(price_list->data);
|
||||||
gnc_price_ref(result);
|
gnc_price_ref(result);
|
||||||
g_list_free (price_list);
|
g_list_free (price_list);
|
||||||
LEAVE("price is %p", result);
|
LEAVE("price is %p", result);
|
||||||
@@ -1838,8 +1837,9 @@ price_list_scan_any_currency(GList *price_list, gpointer data)
|
|||||||
if (!price_list)
|
if (!price_list)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
com = gnc_price_get_commodity(node->data);
|
auto price = static_cast<GNCPrice*>(node->data);
|
||||||
cur = gnc_price_get_currency(node->data);
|
com = gnc_price_get_commodity(price);
|
||||||
|
cur = gnc_price_get_currency(price);
|
||||||
|
|
||||||
/* if this price list isn't for the commodity we are interested in,
|
/* if this price list isn't for the commodity we are interested in,
|
||||||
ignore it. */
|
ignore it. */
|
||||||
@@ -1851,14 +1851,14 @@ price_list_scan_any_currency(GList *price_list, gpointer data)
|
|||||||
previous price to the result list. */
|
previous price to the result list. */
|
||||||
while (node != NULL)
|
while (node != NULL)
|
||||||
{
|
{
|
||||||
GNCPrice *price = node->data;
|
price = static_cast<GNCPrice*>(node->data);
|
||||||
time64 price_t = gnc_price_get_time64(price);
|
time64 price_t = gnc_price_get_time64(price);
|
||||||
if (price_t < helper->t)
|
if (price_t < helper->t)
|
||||||
{
|
{
|
||||||
/* If there is a previous price add it to the results. */
|
/* If there is a previous price add it to the results. */
|
||||||
if (node->prev)
|
if (node->prev)
|
||||||
{
|
{
|
||||||
GNCPrice *prev_price = node->prev->data;
|
auto prev_price = static_cast<GNCPrice*>(node->prev->data);
|
||||||
gnc_price_ref(prev_price);
|
gnc_price_ref(prev_price);
|
||||||
*helper->list = g_list_prepend(*helper->list, prev_price);
|
*helper->list = g_list_prepend(*helper->list, prev_price);
|
||||||
}
|
}
|
||||||
@@ -1914,7 +1914,7 @@ find_comtime(GPtrArray* array, gnc_commodity *com)
|
|||||||
GNCPrice** retval = NULL;
|
GNCPrice** retval = NULL;
|
||||||
for (index = 0; index < array->len; ++index)
|
for (index = 0; index < array->len; ++index)
|
||||||
{
|
{
|
||||||
GNCPrice **price_p = g_ptr_array_index(array, index);
|
auto price_p = static_cast<GNCPrice**>(g_ptr_array_index(array, index));
|
||||||
if (gnc_price_get_commodity(*price_p) == com ||
|
if (gnc_price_get_commodity(*price_p) == com ||
|
||||||
gnc_price_get_currency(*price_p) == com)
|
gnc_price_get_currency(*price_p) == com)
|
||||||
retval = price_p;
|
retval = price_p;
|
||||||
@@ -1998,7 +1998,7 @@ nearest_to (PriceList *prices, const gnc_commodity* target, time64 t)
|
|||||||
*/
|
*/
|
||||||
for (index = 0; index < price_array->len; ++index)
|
for (index = 0; index < price_array->len; ++index)
|
||||||
{
|
{
|
||||||
GNCPrice **com_price = g_ptr_array_index(price_array, index);
|
auto com_price = static_cast<GNCPrice**>(g_ptr_array_index(price_array, index));
|
||||||
time64 price_t = gnc_price_get_time64(*com_price);
|
time64 price_t = gnc_price_get_time64(*com_price);
|
||||||
if (price_t >= t)
|
if (price_t >= t)
|
||||||
{
|
{
|
||||||
@@ -2076,7 +2076,7 @@ gnc_pricedb_has_prices(GNCPriceDB *db,
|
|||||||
|
|
||||||
if (!db || !commodity) return FALSE;
|
if (!db || !commodity) return FALSE;
|
||||||
ENTER ("db=%p commodity=%p currency=%p", db, commodity, currency);
|
ENTER ("db=%p commodity=%p currency=%p", db, commodity, currency);
|
||||||
currency_hash = g_hash_table_lookup(db->commodity_hash, commodity);
|
currency_hash = static_cast<GHashTable*>(g_hash_table_lookup(db->commodity_hash, commodity));
|
||||||
if (!currency_hash)
|
if (!currency_hash)
|
||||||
{
|
{
|
||||||
LEAVE("no, no currency_hash table");
|
LEAVE("no, no currency_hash table");
|
||||||
@@ -2085,7 +2085,7 @@ gnc_pricedb_has_prices(GNCPriceDB *db,
|
|||||||
|
|
||||||
if (currency)
|
if (currency)
|
||||||
{
|
{
|
||||||
price_list = g_hash_table_lookup(currency_hash, currency);
|
price_list = static_cast<GList*>(g_hash_table_lookup(currency_hash, currency));
|
||||||
if (price_list)
|
if (price_list)
|
||||||
{
|
{
|
||||||
LEAVE("yes");
|
LEAVE("yes");
|
||||||
@@ -2118,7 +2118,7 @@ gnc_pricedb_get_prices(GNCPriceDB *db,
|
|||||||
result = pricedb_get_prices_internal (db, commodity, currency, FALSE);
|
result = pricedb_get_prices_internal (db, commodity, currency, FALSE);
|
||||||
if (!result) return NULL;
|
if (!result) return NULL;
|
||||||
for (node = result; node; node = node->next)
|
for (node = result; node; node = node->next)
|
||||||
gnc_price_ref (node->data);
|
gnc_price_ref (static_cast<GNCPrice*>(node->data));
|
||||||
|
|
||||||
LEAVE (" ");
|
LEAVE (" ");
|
||||||
return result;
|
return result;
|
||||||
@@ -2129,8 +2129,8 @@ gnc_pricedb_get_prices(GNCPriceDB *db,
|
|||||||
static void
|
static void
|
||||||
price_count_helper(gpointer key, gpointer value, gpointer data)
|
price_count_helper(gpointer key, gpointer value, gpointer data)
|
||||||
{
|
{
|
||||||
int *result = data;
|
auto result = static_cast<int*>(data);
|
||||||
GList *price_list = value;
|
auto price_list = static_cast<GList*>(value);
|
||||||
|
|
||||||
*result += g_list_length(price_list);
|
*result += g_list_length(price_list);
|
||||||
}
|
}
|
||||||
@@ -2145,7 +2145,7 @@ gnc_pricedb_num_prices(GNCPriceDB *db,
|
|||||||
if (!db || !c) return 0;
|
if (!db || !c) return 0;
|
||||||
ENTER ("db=%p commodity=%p", db, c);
|
ENTER ("db=%p commodity=%p", db, c);
|
||||||
|
|
||||||
currency_hash = g_hash_table_lookup(db->commodity_hash, c);
|
currency_hash = static_cast<GHashTable*>(g_hash_table_lookup(db->commodity_hash, c));
|
||||||
if (currency_hash)
|
if (currency_hash)
|
||||||
{
|
{
|
||||||
g_hash_table_foreach(currency_hash, price_count_helper, (gpointer)&result);
|
g_hash_table_foreach(currency_hash, price_count_helper, (gpointer)&result);
|
||||||
@@ -2160,11 +2160,12 @@ static void
|
|||||||
list_combine (gpointer element, gpointer data)
|
list_combine (gpointer element, gpointer data)
|
||||||
{
|
{
|
||||||
GList *list = *(GList**)data;
|
GList *list = *(GList**)data;
|
||||||
|
auto lst = static_cast<GList*>(element);
|
||||||
if (list == NULL)
|
if (list == NULL)
|
||||||
*(GList**)data = g_list_copy (element);
|
*(GList**)data = g_list_copy (lst);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GList *new_list = g_list_concat ((GList *)list, g_list_copy (element));
|
GList *new_list = g_list_concat (list, g_list_copy (lst));
|
||||||
*(GList**)data = new_list;
|
*(GList**)data = new_list;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2198,7 +2199,7 @@ gnc_pricedb_nth_price (GNCPriceDB *db,
|
|||||||
|
|
||||||
if (last_c && prices && last_c == c && db->reset_nth_price_cache == FALSE)
|
if (last_c && prices && last_c == c && db->reset_nth_price_cache == FALSE)
|
||||||
{
|
{
|
||||||
result = g_list_nth_data (prices, n);
|
result = static_cast<GNCPrice*>(g_list_nth_data (prices, n));
|
||||||
LEAVE ("price=%p", result);
|
LEAVE ("price=%p", result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -2213,12 +2214,12 @@ gnc_pricedb_nth_price (GNCPriceDB *db,
|
|||||||
|
|
||||||
db->reset_nth_price_cache = FALSE;
|
db->reset_nth_price_cache = FALSE;
|
||||||
|
|
||||||
currency_hash = g_hash_table_lookup (db->commodity_hash, c);
|
currency_hash = static_cast<GHashTable*>(g_hash_table_lookup (db->commodity_hash, c));
|
||||||
if (currency_hash)
|
if (currency_hash)
|
||||||
{
|
{
|
||||||
GList *currencies = g_hash_table_get_values (currency_hash);
|
GList *currencies = g_hash_table_get_values (currency_hash);
|
||||||
g_list_foreach (currencies, list_combine, &prices);
|
g_list_foreach (currencies, list_combine, &prices);
|
||||||
result = g_list_nth_data (prices, n);
|
result = static_cast<GNCPrice*>(g_list_nth_data (prices, n));
|
||||||
g_list_free (currencies);
|
g_list_free (currencies);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2257,7 +2258,7 @@ gnc_pricedb_lookup_at_time64(GNCPriceDB *db,
|
|||||||
item = price_list;
|
item = price_list;
|
||||||
while (item)
|
while (item)
|
||||||
{
|
{
|
||||||
GNCPrice *p = item->data;
|
auto p = static_cast<GNCPrice*>(item->data);
|
||||||
time64 price_time = gnc_price_get_time64(p);
|
time64 price_time = gnc_price_get_time64(p);
|
||||||
if (price_time == t)
|
if (price_time == t)
|
||||||
{
|
{
|
||||||
@@ -2294,20 +2295,20 @@ lookup_nearest_in_time(GNCPriceDB *db,
|
|||||||
item = price_list;
|
item = price_list;
|
||||||
|
|
||||||
/* default answer */
|
/* default answer */
|
||||||
current_price = item->data;
|
current_price = static_cast<GNCPrice*>(item->data);
|
||||||
|
|
||||||
/* find the first candidate past the one we want. Remember that
|
/* find the first candidate past the one we want. Remember that
|
||||||
prices are in most-recent-first order. */
|
prices are in most-recent-first order. */
|
||||||
while (!next_price && item)
|
while (!next_price && item)
|
||||||
{
|
{
|
||||||
GNCPrice *p = item->data;
|
auto p = static_cast<GNCPrice*>(item->data);
|
||||||
time64 price_time = gnc_price_get_time64(p);
|
time64 price_time = gnc_price_get_time64(p);
|
||||||
if (price_time <= t)
|
if (price_time <= t)
|
||||||
{
|
{
|
||||||
next_price = item->data;
|
next_price = static_cast<GNCPrice*>(item->data);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
current_price = item->data;
|
current_price = static_cast<GNCPrice*>(item->data);
|
||||||
item = item->next;
|
item = item->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2416,9 +2417,9 @@ gnc_pricedb_lookup_nearest_before_t64 (GNCPriceDB *db,
|
|||||||
item = price_list;
|
item = price_list;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
price_time = gnc_price_get_time64 (item->data);
|
price_time = gnc_price_get_time64 (static_cast<GNCPrice*>(item->data));
|
||||||
if (price_time <= t)
|
if (price_time <= t)
|
||||||
current_price = item->data;
|
current_price = static_cast<GNCPrice*>(item->data);
|
||||||
item = item->next;
|
item = item->next;
|
||||||
}
|
}
|
||||||
while (price_time > t && item);
|
while (price_time > t && item);
|
||||||
@@ -2901,7 +2902,7 @@ typedef struct
|
|||||||
static gboolean
|
static gboolean
|
||||||
add_price_to_list (GNCPrice *p, gpointer data)
|
add_price_to_list (GNCPrice *p, gpointer data)
|
||||||
{
|
{
|
||||||
GList **list = data;
|
auto list = static_cast<GList**>(data);
|
||||||
|
|
||||||
*list = g_list_prepend (*list, p);
|
*list = g_list_prepend (*list, p);
|
||||||
|
|
||||||
@@ -2911,8 +2912,8 @@ add_price_to_list (GNCPrice *p, gpointer data)
|
|||||||
static void
|
static void
|
||||||
gnc_price_fixup_legacy_commods(gpointer data, gpointer user_data)
|
gnc_price_fixup_legacy_commods(gpointer data, gpointer user_data)
|
||||||
{
|
{
|
||||||
GNCPrice *p = data;
|
auto p = static_cast<GNCPrice*>(data);
|
||||||
GNCPriceFixupData *fixup_data = user_data;
|
auto fixup_data = static_cast<GNCPriceFixupData*>(user_data);
|
||||||
gnc_commodity *price_c;
|
gnc_commodity *price_c;
|
||||||
|
|
||||||
if (!p) return;
|
if (!p) return;
|
||||||
@@ -3040,13 +3041,12 @@ pricedb_book_begin (QofBook *book)
|
|||||||
static void
|
static void
|
||||||
pricedb_book_end (QofBook *book)
|
pricedb_book_end (QofBook *book)
|
||||||
{
|
{
|
||||||
GNCPriceDB *db;
|
|
||||||
QofCollection *col;
|
QofCollection *col;
|
||||||
|
|
||||||
if (!book)
|
if (!book)
|
||||||
return;
|
return;
|
||||||
col = qof_book_get_collection(book, GNC_ID_PRICEDB);
|
col = qof_book_get_collection(book, GNC_ID_PRICEDB);
|
||||||
db = qof_collection_get_data(col);
|
auto db = static_cast<GNCPriceDB*>(qof_collection_get_data(col));
|
||||||
qof_collection_set_data(col, NULL);
|
qof_collection_set_data(col, NULL);
|
||||||
gnc_pricedb_destroy(db);
|
gnc_pricedb_destroy(db);
|
||||||
}
|
}
|
||||||
@@ -3110,7 +3110,7 @@ price_foreach(const QofCollection *col, QofInstanceForeachCB cb, gpointer data)
|
|||||||
{
|
{
|
||||||
GNCPriceDB *db;
|
GNCPriceDB *db;
|
||||||
|
|
||||||
db = qof_collection_get_data(col);
|
db = static_cast<GNCPriceDB*>(qof_collection_get_data(col));
|
||||||
void_unstable_price_traversal(db,
|
void_unstable_price_traversal(db,
|
||||||
(void (*)(GNCPrice *, gpointer)) cb,
|
(void (*)(GNCPrice *, gpointer)) cb,
|
||||||
data);
|
data);
|
||||||
@@ -3126,7 +3126,7 @@ static void price_list_dump(GList *price_list, const char *tag);
|
|||||||
static const char *
|
static const char *
|
||||||
price_printable(gpointer obj)
|
price_printable(gpointer obj)
|
||||||
{
|
{
|
||||||
GNCPrice *pr = obj;
|
auto pr = static_cast<GNCPrice*>(obj);
|
||||||
gnc_commodity *commodity;
|
gnc_commodity *commodity;
|
||||||
gnc_commodity *currency;
|
gnc_commodity *currency;
|
||||||
static char buff[2048]; /* nasty static OK for printing */
|
static char buff[2048]; /* nasty static OK for printing */
|
||||||
@@ -655,7 +655,7 @@ libgnucash/engine/gnc-optiondb.cpp
|
|||||||
libgnucash/engine/gnc-option-impl.cpp
|
libgnucash/engine/gnc-option-impl.cpp
|
||||||
libgnucash/engine/gncOrder.c
|
libgnucash/engine/gncOrder.c
|
||||||
libgnucash/engine/gncOwner.c
|
libgnucash/engine/gncOwner.c
|
||||||
libgnucash/engine/gnc-pricedb.c
|
libgnucash/engine/gnc-pricedb.cpp
|
||||||
libgnucash/engine/gnc-rational.cpp
|
libgnucash/engine/gnc-rational.cpp
|
||||||
libgnucash/engine/gnc-session.c
|
libgnucash/engine/gnc-session.c
|
||||||
libgnucash/engine/gncTaxTable.c
|
libgnucash/engine/gncTaxTable.c
|
||||||
|
|||||||
Reference in New Issue
Block a user