35 #include <gnc-xml-helper.h> 41 #include <TransactionP.hpp> 44 #include <gnc-pricedb-p.h> 48 #include "sixtp-dom-parsers.h" 49 #include "sixtp-stack.h" 50 #include "sixtp-parsers.h" 51 #include "sixtp-utils.h" 53 #include <kvp-frame.hpp> 56 static sixtp* gnc_transaction_parser_new (
void);
59 static sixtp* gnc_account_parser_new (
void);
62 static sixtp* ledger_data_parser_new (
void);
65 static sixtp* commodity_restore_parser_new (
void);
68 static sixtp* generic_gnc_commodity_lookup_parser_new (
void);
74 static sixtp* kvp_frame_parser_new (
void);
77 static sixtp* gnc_pricedb_parser_new (
void);
83 GNC_PARSE_ERR_BAD_VERSION,
89 gboolean seen_version;
135 static QofLogModule log_module = GNC_MOD_IO;
149 gnc_parser_configure_for_input_version (
GNCParseStatus* status, gint64 version)
152 status->version = version;
153 status->seen_version = TRUE;
158 status->error = GNC_PARSE_ERR_BAD_VERSION;
166 sixtp* ledger_data_pr = ledger_data_parser_new ();
167 g_return_val_if_fail (ledger_data_pr, FALSE);
168 sixtp_add_sub_parser (status->gnc_parser,
"ledger-data", ledger_data_pr);
175 gnc_version_end_handler (gpointer data_for_children,
176 GSList* data_from_children, GSList* sibling_data,
177 gpointer parent_data, gpointer global_data,
178 gpointer* result,
const gchar* tag)
185 g_return_val_if_fail (pstatus, FALSE);
186 if (pstatus->seen_version)
return (FALSE);
188 txt = concatenate_child_result_chars (data_from_children);
189 g_return_val_if_fail (txt, FALSE);
191 ok = string_to_gint64 (txt, &version);
193 g_return_val_if_fail (ok, FALSE);
195 if (!gnc_parser_configure_for_input_version (pstatus, version))
return (FALSE);
201 gnc_version_parser_new (
void)
203 return (simple_chars_only_parser_new (gnc_version_end_handler));
233 gnc_parser_before_child_handler (gpointer data_for_children,
234 GSList* data_from_children,
235 GSList* sibling_data,
236 gpointer parent_data,
237 gpointer global_data,
241 const gchar* child_tag)
245 g_return_val_if_fail (pstatus, FALSE);
247 if (strcmp (child_tag,
"ledger-data") == 0)
249 if (pstatus->root_account)
259 gnc_parser_after_child_handler (gpointer data_for_children,
260 GSList* data_from_children,
261 GSList* sibling_data,
262 gpointer parent_data,
263 gpointer global_data,
266 const gchar* child_tag,
267 sixtp_child_result* child_result)
270 g_return_val_if_fail (pstatus, FALSE);
272 if (strcmp (child_tag,
"ledger-data") == 0)
274 g_return_val_if_fail (child_result, FALSE);
275 g_return_val_if_fail (child_result->data, FALSE);
276 pstatus->root_account = (
Account*) child_result->data;
277 child_result->should_cleanup = FALSE;
284 gnc_parser_new (
void)
286 return sixtp_set_any (
288 SIXTP_CHARACTERS_HANDLER_ID, allow_and_ignore_only_whitespace,
289 SIXTP_BEFORE_CHILD_HANDLER_ID, gnc_parser_before_child_handler,
290 SIXTP_AFTER_CHILD_HANDLER_ID, gnc_parser_after_child_handler,
291 SIXTP_NO_MORE_HANDLERS);
302 sixtp* gnc_version_pr;
307 top_level_pr = sixtp_new ();
308 g_return_val_if_fail (top_level_pr, FALSE);
309 sixtp_set_chars (top_level_pr, allow_and_ignore_only_whitespace);
312 gnc_pr = gnc_parser_new ();
315 sixtp_destroy (top_level_pr);
318 sixtp_add_sub_parser (top_level_pr,
"gnc", gnc_pr);
321 gnc_version_pr = gnc_version_parser_new ();
324 sixtp_destroy (top_level_pr);
327 sixtp_add_sub_parser (gnc_pr,
"version", gnc_version_pr);
329 global_parse_status->seen_version = FALSE;
330 global_parse_status->gnc_parser = gnc_pr;
331 global_parse_status->root_account = NULL;
332 global_parse_status->pricedb = NULL;
334 global_parse_status->error = GNC_PARSE_ERR_NONE;
345 gpointer parse_result = NULL;
350 global_parse_status.book = book;
351 g_return_val_if_fail (book, FALSE);
352 g_return_val_if_fail (filename, FALSE);
354 xaccDisableDataScrubbing ();
355 top_level_pr = gncxml_setup_for_read (&global_parse_status);
356 g_return_val_if_fail (top_level_pr, FALSE);
358 parse_ok = sixtp_parse_file (top_level_pr,
361 &global_parse_status,
364 sixtp_destroy (top_level_pr);
365 xaccEnableDataScrubbing ();
369 if (!global_parse_status.root_account)
return FALSE;
371 root = global_parse_status.root_account;
372 gnc_book_set_root_account (book, root);
378 xaccAccountTreeScrubSplits (root);
393 if ((gnc_is_our_xml_file (filename, NULL)) == GNC_BOOK_XML1_FILE)
438 kvp_value_result_cleanup (sixtp_child_result* cr)
440 KvpValue* v =
static_cast<KvpValue*
> (cr->data);
445 simple_kvp_value_parser_new (sixtp_end_handler end_handler)
447 return sixtp_set_any (sixtp_new (), FALSE,
448 SIXTP_CHARACTERS_HANDLER_ID,
449 generic_accumulate_chars,
450 SIXTP_END_HANDLER_ID, end_handler,
451 SIXTP_CLEANUP_RESULT_ID, kvp_value_result_cleanup,
452 SIXTP_CLEANUP_CHARS_ID, sixtp_child_free_data,
453 SIXTP_RESULT_FAIL_ID, kvp_value_result_cleanup,
454 SIXTP_CHARS_FAIL_ID, sixtp_child_free_data,
455 SIXTP_NO_MORE_HANDLERS);
476 string_to_gnc_numeric(
const gchar* str, gnc_numeric *n)
484 #define KVP_CVT_VALUE(TYPE) \ 491 txt = concatenate_child_result_chars(data_from_children); \ 492 g_return_val_if_fail(txt, FALSE); \ 494 ok = (gboolean) string_to_##TYPE(txt, &val); \ 496 g_return_val_if_fail(ok, FALSE); \ 498 kvpv = new KvpValue{val}; \ 499 g_return_val_if_fail(kvpv, FALSE); \ 507 gint64_kvp_value_end_handler (gpointer data_for_children,
508 GSList* data_from_children,
509 GSList* sibling_data,
510 gpointer parent_data,
511 gpointer global_data,
515 KVP_CVT_VALUE (gint64);
520 gint64_kvp_value_parser_new (
void)
522 return (simple_kvp_value_parser_new (gint64_kvp_value_end_handler));
526 double_kvp_value_end_handler (gpointer data_for_children,
527 GSList* data_from_children,
528 GSList* sibling_data,
529 gpointer parent_data,
530 gpointer global_data,
534 KVP_CVT_VALUE (
double);
538 double_kvp_value_parser_new (
void)
540 return (simple_kvp_value_parser_new (double_kvp_value_end_handler));
544 gnc_numeric_kvp_value_end_handler (gpointer data_for_children,
545 GSList* data_from_children,
546 GSList* sibling_data,
547 gpointer parent_data,
548 gpointer global_data,
552 KVP_CVT_VALUE (gnc_numeric);
556 gnc_numeric_kvp_value_parser_new (
void)
558 return (simple_kvp_value_parser_new (gnc_numeric_kvp_value_end_handler));
562 string_kvp_value_end_handler (gpointer data_for_children,
563 GSList* data_from_children,
564 GSList* sibling_data,
565 gpointer parent_data,
566 gpointer global_data,
573 txt = concatenate_child_result_chars (data_from_children);
574 g_return_val_if_fail (txt, FALSE);
576 kvpv =
new KvpValue {g_strdup (txt)};
578 g_return_val_if_fail (kvpv, FALSE);
585 string_kvp_value_parser_new (
void)
587 return (simple_kvp_value_parser_new (string_kvp_value_end_handler));
593 guid_kvp_value_end_handler (gpointer data_for_children,
594 GSList* data_from_children,
595 GSList* sibling_data,
596 gpointer parent_data,
597 gpointer global_data,
606 txt = concatenate_child_result_chars (data_from_children);
607 g_return_val_if_fail (txt, FALSE);
612 g_return_val_if_fail (ok, FALSE);
615 g_return_val_if_fail (kvpv, FALSE);
622 guid_kvp_value_parser_new (
void)
624 return (simple_kvp_value_parser_new (guid_kvp_value_end_handler));
649 glist_kvp_value_end_handler (gpointer data_for_children,
650 GSList* data_from_children, GSList* sibling_data,
651 gpointer parent_data, gpointer global_data,
652 gpointer* result,
const gchar* tag)
656 KvpValue* kvp_result;
659 for (lp = data_from_children; lp; lp = lp->next)
661 sixtp_child_result* cr = (sixtp_child_result*) lp->data;
662 KvpValue* kvp = (KvpValue*) cr->data;
665 result_glist = g_list_prepend (result_glist, kvp);
666 cr->should_cleanup = FALSE;
669 kvp_result =
new KvpValue {result_glist};
671 g_list_free_full (result_glist,
672 [] (
void * data) {
delete static_cast<KvpValue*
> (data);});
673 *result = kvp_result;
678 #define KVP_TOKEN(NAME,TOK) \ 679 child_pr = NAME##_kvp_value_parser_new(); \ 680 g_return_val_if_fail(child_pr, FALSE); \ 681 sixtp_add_sub_parser(p, TOK, child_pr); 686 add_all_kvp_value_parsers_as_sub_nodes (
sixtp* p,
687 sixtp* kvp_frame_parser,
692 g_return_val_if_fail (p, FALSE);
693 g_return_val_if_fail (kvp_frame_parser, FALSE);
695 KVP_TOKEN (gint64,
"gint64");
696 KVP_TOKEN (
double,
"double");
697 KVP_TOKEN (gnc_numeric,
"numeric");
698 KVP_TOKEN (
string,
"string");
699 KVP_TOKEN (guid,
"guid");
701 sixtp_add_sub_parser (p,
"glist", glist_parser);
702 sixtp_add_sub_parser (p,
"frame", kvp_frame_parser);
708 glist_kvp_value_parser_new (
sixtp* kvp_frame_parser)
710 sixtp* top_level = sixtp_set_any (
712 SIXTP_CHARACTERS_HANDLER_ID, allow_and_ignore_only_whitespace,
713 SIXTP_END_HANDLER_ID, glist_kvp_value_end_handler,
714 SIXTP_CLEANUP_RESULT_ID, kvp_value_result_cleanup,
715 SIXTP_RESULT_FAIL_ID, kvp_value_result_cleanup,
716 SIXTP_NO_MORE_HANDLERS);
722 if (!add_all_kvp_value_parsers_as_sub_nodes (top_level,
726 sixtp_destroy (top_level);
765 kvp_frame_slot_end_handler (gpointer data_for_children,
766 GSList* data_from_children, GSList* sibling_data,
767 gpointer parent_data, gpointer global_data,
768 gpointer* result,
const gchar* tag)
770 KvpFrame* f = (KvpFrame*) parent_data;
772 KvpValue* value = NULL;
773 gboolean delete_value = FALSE;
774 sixtp_child_result *cr1 = NULL, *cr2 = NULL, *cr = NULL;
775 g_return_val_if_fail (f, FALSE);
777 if (g_slist_length (data_from_children) != 2)
return (FALSE);
778 cr1 = (sixtp_child_result*)data_from_children->data;
779 cr2 = (sixtp_child_result*)data_from_children->next->data;
781 if (is_child_result_from_node_named(cr1,
"k"))
783 key = (
char*)cr1->data;
786 else if (is_child_result_from_node_named(cr2,
"k"))
788 key = (
char*)cr2->data;
794 if (is_child_result_from_node_named (cr,
"frame"))
796 KvpFrame* frame =
static_cast<KvpFrame*
> (cr->data);
797 value =
new KvpValue {frame};
802 value =
static_cast<KvpValue*
> (cr->data);
803 delete_value = FALSE;
806 f->set ({key}, value);
813 kvp_frame_slot_parser_new (
sixtp* kvp_frame_parser)
819 g_return_val_if_fail (kvp_frame_parser, NULL);
821 if (! (top_level = sixtp_set_any (
823 SIXTP_CHARACTERS_HANDLER_ID, allow_and_ignore_only_whitespace,
824 SIXTP_END_HANDLER_ID, kvp_frame_slot_end_handler,
825 SIXTP_NO_MORE_HANDLERS)))
830 child_pr = simple_chars_only_parser_new (NULL);
833 sixtp_destroy (top_level);
836 sixtp_add_sub_parser (top_level,
"k", child_pr);
838 glist_pr = glist_kvp_value_parser_new (kvp_frame_parser);
841 sixtp_destroy (top_level);
845 if (!add_all_kvp_value_parsers_as_sub_nodes (top_level,
849 sixtp_destroy (top_level);
875 kvp_frame_start_handler (GSList* sibling_data, gpointer parent_data,
876 gpointer global_data, gpointer* data_for_children,
877 gpointer* result,
const gchar* tag, gchar** attrs)
879 auto f =
new KvpFrame;
880 *data_for_children = f;
885 kvp_frame_end_handler (gpointer data_for_children,
886 GSList* data_from_children, GSList* sibling_data,
887 gpointer parent_data, gpointer global_data,
888 gpointer* result,
const gchar* tag)
890 g_return_val_if_fail (data_for_children != NULL, FALSE);
891 *result = data_for_children;
896 kvp_frame_fail_handler (gpointer data_for_children,
897 GSList* data_from_children,
898 GSList* sibling_data,
899 gpointer parent_data,
900 gpointer global_data,
904 auto f =
static_cast<KvpFrame*
> (data_for_children);
909 kvp_frame_result_cleanup (sixtp_child_result* cr)
911 auto f =
static_cast<KvpFrame*
> (cr->data);
916 kvp_frame_parser_new (
void)
920 if (! (top_level = sixtp_set_any (
922 SIXTP_START_HANDLER_ID, kvp_frame_start_handler,
923 SIXTP_CHARACTERS_HANDLER_ID, allow_and_ignore_only_whitespace,
924 SIXTP_END_HANDLER_ID, kvp_frame_end_handler,
925 SIXTP_CLEANUP_RESULT_ID, kvp_frame_result_cleanup,
926 SIXTP_RESULT_FAIL_ID, kvp_frame_result_cleanup,
927 SIXTP_FAIL_HANDLER_ID, kvp_frame_fail_handler,
928 SIXTP_NO_MORE_HANDLERS)))
933 if (! (sixtp_add_some_sub_parsers (
935 "s", kvp_frame_slot_parser_new (top_level),
968 ledger_data_start_handler (GSList* sibling_data, gpointer parent_data,
969 gpointer global_data, gpointer* data_for_children,
970 gpointer* result,
const gchar* tag, gchar** attrs)
979 g_return_val_if_fail (ra, FALSE);
981 *data_for_children = ra;
986 ledger_data_after_child_handler (gpointer data_for_children,
987 GSList* data_from_children,
988 GSList* sibling_data,
989 gpointer parent_data,
990 gpointer global_data,
993 const gchar* child_tag,
994 sixtp_child_result* child_result)
996 if (!child_result)
return (TRUE);
999 if (child_result->type != SIXTP_CHILD_RESULT_NODE)
return (TRUE);
1000 if (strcmp (child_result->tag,
"pricedb") == 0)
1002 GNCPriceDB* pdb = (GNCPriceDB*) child_result->data;
1005 g_return_val_if_fail (pdb, FALSE);
1006 g_return_val_if_fail (status, FALSE);
1008 if (status->pricedb)
1010 PERR (
"hit pricedb twice in data file.");
1013 status->pricedb = pdb;
1014 child_result->should_cleanup = FALSE;
1020 ledger_data_end_handler (gpointer data_for_children,
1021 GSList* data_from_children, GSList* sibling_data,
1022 gpointer parent_data, gpointer global_data,
1023 gpointer* result,
const gchar* tag)
1029 g_return_val_if_fail (ra, FALSE);
1036 g_list_free (descendants);
1045 ledger_data_fail_handler (gpointer data_for_children,
1046 GSList* data_from_children,
1047 GSList* sibling_data,
1048 gpointer parent_data,
1049 gpointer global_data,
1062 ledger_data_result_cleanup (sixtp_child_result* cr)
1074 ledger_data_parser_new (
void)
1079 if (! (top_level = sixtp_set_any (
1080 sixtp_new (), FALSE,
1081 SIXTP_START_HANDLER_ID, ledger_data_start_handler,
1082 SIXTP_CHARACTERS_HANDLER_ID, allow_and_ignore_only_whitespace,
1083 SIXTP_AFTER_CHILD_HANDLER_ID, ledger_data_after_child_handler,
1084 SIXTP_END_HANDLER_ID, ledger_data_end_handler,
1085 SIXTP_CLEANUP_RESULT_ID, ledger_data_result_cleanup,
1086 SIXTP_FAIL_HANDLER_ID, ledger_data_fail_handler,
1087 SIXTP_RESULT_FAIL_ID, ledger_data_result_cleanup,
1088 SIXTP_NO_MORE_HANDLERS)))
1093 if (!sixtp_add_some_sub_parsers (
1095 "commodity", commodity_restore_parser_new (),
1096 "pricedb", gnc_pricedb_parser_new (),
1097 "account", gnc_account_parser_new (),
1098 "transaction", gnc_transaction_parser_new (),
1140 account_start_handler (GSList* sibling_data,
1141 gpointer parent_data,
1142 gpointer global_data,
1143 gpointer* data_for_children,
1149 *data_for_children = parent_data;
1175 account_restore_start_handler (GSList* sibling_data,
1176 gpointer parent_data,
1177 gpointer global_data,
1178 gpointer* data_for_children,
1186 g_return_val_if_fail (acc, FALSE);
1189 *data_for_children = acc;
1196 account_restore_end_handler (gpointer data_for_children,
1197 GSList* data_from_children, GSList* sibling_data,
1198 gpointer parent_data, gpointer global_data,
1199 gpointer* result,
const gchar* tag)
1204 g_return_val_if_fail ((parent && acc), FALSE);
1225 account_restore_after_child_handler (gpointer data_for_children,
1226 GSList* data_from_children,
1227 GSList* sibling_data,
1228 gpointer parent_data,
1229 gpointer global_data,
1232 const gchar* child_tag,
1233 sixtp_child_result* child_result)
1238 g_return_val_if_fail (a, FALSE);
1240 if (!child_result)
return (TRUE);
1241 if (child_result->type != SIXTP_CHILD_RESULT_NODE)
return (TRUE);
1242 if (strcmp (child_result->tag,
"slots") == 0)
1244 auto f =
static_cast<KvpFrame*
> (child_result->data);
1245 g_return_val_if_fail (f, FALSE);
1246 if (a->inst.kvp_data)
delete a->inst.kvp_data;
1247 a->inst.kvp_data = f;
1248 child_result->should_cleanup = FALSE;
1250 else if (strcmp (child_result->tag,
"currency") == 0)
1252 gnc_commodity* com = (gnc_commodity*) child_result->data;
1253 g_return_val_if_fail (com, FALSE);
1258 else if (strcmp (child_result->tag,
"security") == 0)
1260 gnc_commodity* com = (gnc_commodity*) child_result->data;
1261 g_return_val_if_fail (com, FALSE);
1271 account_restore_fail_handler (gpointer data_for_children,
1272 GSList* data_from_children,
1273 GSList* sibling_data,
1274 gpointer parent_data,
1275 gpointer global_data,
1306 acc_restore_name_end_handler (gpointer data_for_children,
1307 GSList* data_from_children, GSList* sibling_data,
1308 gpointer parent_data, gpointer global_data,
1309 gpointer* result,
const gchar* tag)
1314 g_return_val_if_fail (acc, FALSE);
1316 name = concatenate_child_result_chars (data_from_children);
1317 g_return_val_if_fail (name, FALSE);
1344 acc_restore_guid_end_handler (gpointer data_for_children,
1345 GSList* data_from_children, GSList* sibling_data,
1346 gpointer parent_data, gpointer global_data,
1347 gpointer* result,
const gchar* tag)
1355 g_return_val_if_fail (acc, FALSE);
1357 txt = concatenate_child_result_chars (data_from_children);
1358 g_return_val_if_fail (txt, FALSE);
1363 g_return_val_if_fail (ok, FALSE);
1370 xaccAccountSetGUID (acc, &gid);
1394 acc_restore_type_end_handler (gpointer data_for_children,
1395 GSList* data_from_children, GSList* sibling_data,
1396 gpointer parent_data, gpointer global_data,
1397 gpointer* result,
const gchar* tag)
1404 g_return_val_if_fail (acc, FALSE);
1406 txt = concatenate_child_result_chars (data_from_children);
1407 g_return_val_if_fail (txt, FALSE);
1412 g_return_val_if_fail (ok, FALSE);
1438 acc_restore_code_end_handler (gpointer data_for_children,
1439 GSList* data_from_children, GSList* sibling_data,
1440 gpointer parent_data, gpointer global_data,
1441 gpointer* result,
const gchar* tag)
1446 g_return_val_if_fail (acc, FALSE);
1448 txt = concatenate_child_result_chars (data_from_children);
1449 g_return_val_if_fail (txt, FALSE);
1477 acc_restore_description_end_handler (gpointer data_for_children,
1478 GSList* data_from_children, GSList* sibling_data,
1479 gpointer parent_data, gpointer global_data,
1480 gpointer* result,
const gchar* tag)
1485 g_return_val_if_fail (acc, FALSE);
1487 txt = concatenate_child_result_chars (data_from_children);
1488 g_return_val_if_fail (txt, FALSE);
1515 acc_restore_notes_end_handler (gpointer data_for_children,
1516 GSList* data_from_children, GSList* sibling_data,
1517 gpointer parent_data, gpointer global_data,
1518 gpointer* result,
const gchar* tag)
1523 g_return_val_if_fail (acc, FALSE);
1525 txt = concatenate_child_result_chars (data_from_children);
1526 g_return_val_if_fail (txt, FALSE);
1556 acc_restore_parent_end_handler (gpointer data_for_children,
1557 GSList* data_from_children, GSList* sibling_data,
1558 gpointer parent_data, gpointer global_data,
1559 gpointer* result,
const gchar* tag)
1564 sixtp_child_result* child_result;
1567 g_return_val_if_fail (acc, FALSE);
1569 if (g_slist_length (data_from_children) != 1)
1572 child_result = (sixtp_child_result*) data_from_children->data;
1574 if (!is_child_result_from_node_named (child_result,
"guid"))
1578 gid = * ((
GncGUID*) child_result->data);
1582 g_return_val_if_fail (parent, FALSE);
1590 parent_lookup_parser_new (
void)
1592 return sixtp_set_any (sixtp_new (), TRUE,
1593 SIXTP_CHARACTERS_HANDLER_ID,
1594 allow_and_ignore_only_whitespace,
1595 SIXTP_END_HANDLER_ID,
1596 acc_restore_parent_end_handler,
1597 SIXTP_NO_MORE_HANDLERS);
1601 gnc_account_parser_new (
void)
1607 if (! (ret = sixtp_set_any (
1608 sixtp_new (), FALSE,
1609 SIXTP_START_HANDLER_ID, account_start_handler,
1610 SIXTP_CHARACTERS_HANDLER_ID, allow_and_ignore_only_whitespace,
1611 SIXTP_NO_MORE_HANDLERS)))
1618 sixtp_set_any (sixtp_new (), FALSE,
1619 SIXTP_START_HANDLER_ID, account_restore_start_handler,
1620 SIXTP_END_HANDLER_ID, account_restore_end_handler,
1621 SIXTP_FAIL_HANDLER_ID, account_restore_fail_handler,
1622 SIXTP_AFTER_CHILD_HANDLER_ID,
1623 account_restore_after_child_handler,
1624 SIXTP_NO_MORE_HANDLERS)))
1626 sixtp_destroy (ret);
1631 if (!sixtp_add_some_sub_parsers (
1633 "name", restore_char_generator (acc_restore_name_end_handler),
1634 "guid", restore_char_generator (acc_restore_guid_end_handler),
1635 "type", restore_char_generator (acc_restore_type_end_handler),
1636 "code", restore_char_generator (acc_restore_code_end_handler),
1638 restore_char_generator (acc_restore_description_end_handler),
1639 "notes", restore_char_generator (acc_restore_notes_end_handler),
1641 "currency", generic_gnc_commodity_lookup_parser_new (),
1643 "security", generic_gnc_commodity_lookup_parser_new (),
1645 "parent", sixtp_add_some_sub_parsers (
1646 parent_lookup_parser_new (), TRUE,
1647 "guid", generic_guid_parser_new (),
1649 "slots", kvp_frame_parser_new (),
1652 sixtp_destroy (ret);
1656 sixtp_add_sub_parser (ret,
"restore", restore_pr);
1714 gboolean seen_fraction;
1719 commodity_restore_start_handler (GSList* sibling_data, gpointer parent_data,
1720 gpointer global_data,
1721 gpointer* data_for_children, gpointer* result,
1722 const gchar* tag, gchar** attrs)
1727 g_return_val_if_fail (cpi, FALSE);
1729 *data_for_children = cpi;
1734 #define COMMOD_TOKEN(NAME) \ 1735 if(strcmp(child_result->tag, #NAME) == 0) { \ 1736 if(cpi->NAME) return(FALSE); \ 1737 cpi->NAME = (gchar *) child_result->data; \ 1738 child_result->should_cleanup = FALSE; \ 1744 commodity_restore_after_child_handler (gpointer data_for_children,
1745 GSList* data_from_children,
1746 GSList* sibling_data,
1747 gpointer parent_data,
1748 gpointer global_data,
1751 const gchar* child_tag,
1752 sixtp_child_result* child_result)
1756 g_return_val_if_fail (cpi, FALSE);
1757 g_return_val_if_fail (child_result, FALSE);
1759 COMMOD_TOKEN (space)
1762 COMMOD_TOKEN (xcode)
1763 if (strcmp (child_result->tag,
"fraction") == 0)
1767 if (cpi->seen_fraction)
return (FALSE);
1768 string_to_gint64 ((gchar*) child_result->data, &frac);
1769 cpi->fraction = frac;
1770 cpi->seen_fraction = TRUE;
1771 child_result->should_cleanup = TRUE;
1783 commodity_restore_end_handler (gpointer data_for_children,
1784 GSList* data_from_children, GSList* sibling_data,
1785 gpointer parent_data, gpointer global_data,
1786 gpointer* result,
const gchar* tag)
1790 gboolean ok = FALSE;
1791 gnc_commodity* comm = NULL;
1793 g_return_val_if_fail (cpi, FALSE);
1795 if (cpi->seen_fraction)
1797 gnc_commodity* comm;
1799 if (!cpi->space) cpi->space = g_strdup (
"");
1800 if (!cpi->id) cpi->id = g_strdup (
"");
1801 if (!cpi->name) cpi->name = g_strdup (
"");
1802 if (!cpi->xcode) cpi->xcode = g_strdup (
"");
1812 gnc_commodity_table* ctab;
1824 g_free (cpi->space);
1827 g_free (cpi->xcode);
1837 commodity_restore_parser_new (
void)
1842 top_level = sixtp_new ();
1843 g_return_val_if_fail (top_level, NULL);
1845 if (! (restore_pr = sixtp_set_any (
1846 sixtp_new (), FALSE,
1847 SIXTP_START_HANDLER_ID, commodity_restore_start_handler,
1848 SIXTP_END_HANDLER_ID, commodity_restore_end_handler,
1849 SIXTP_FAIL_HANDLER_ID, generic_free_data_for_children,
1850 SIXTP_AFTER_CHILD_HANDLER_ID, commodity_restore_after_child_handler,
1851 SIXTP_NO_MORE_HANDLERS)))
1853 sixtp_destroy (top_level);
1856 sixtp_add_sub_parser (top_level,
"restore", restore_pr);
1858 if (!sixtp_add_some_sub_parsers (
1860 "space", simple_chars_only_parser_new (NULL),
1861 "id", simple_chars_only_parser_new (NULL),
1862 "name", simple_chars_only_parser_new (NULL),
1863 "xcode", simple_chars_only_parser_new (NULL),
1864 "fraction", simple_chars_only_parser_new (NULL),
1917 generic_gnc_commodity_lookup_start_handler (
1918 GSList* sibling_data, gpointer parent_data, gpointer global_data,
1919 gpointer* data_for_children, gpointer* result,
const gchar* tag,
1923 g_return_val_if_fail (cpi, FALSE);
1924 *data_for_children = cpi;
1929 generic_gnc_commodity_lookup_after_child_handler (gpointer data_for_children,
1930 GSList* data_from_children,
1931 GSList* sibling_data,
1932 gpointer parent_data,
1933 gpointer global_data,
1936 const gchar* child_tag,
1937 sixtp_child_result* child_result)
1942 g_return_val_if_fail (cpi, FALSE);
1943 g_return_val_if_fail (child_result, FALSE);
1944 if (child_result->type != SIXTP_CHILD_RESULT_NODE)
return (FALSE);
1946 if (strcmp (child_result->tag,
"space") == 0)
1948 if (cpi->name_space)
return (FALSE);
1949 cpi->name_space = (gchar*) child_result->data;
1950 child_result->should_cleanup = FALSE;
1952 else if (strcmp (child_result->tag,
"id") == 0)
1954 if (cpi->id)
return (FALSE);
1955 cpi->id = (gchar*) child_result->data;
1956 child_result->should_cleanup = FALSE;
1968 generic_gnc_commodity_lookup_end_handler (gpointer data_for_children,
1969 GSList* data_from_children, GSList* sibling_data,
1970 gpointer parent_data, gpointer global_data,
1971 gpointer* result,
const gchar* tag)
1976 gboolean ok = FALSE;
1978 g_return_val_if_fail (cpi, FALSE);
1980 if (cpi->name_space && cpi->id)
1982 gnc_commodity_table*
table;
1987 com = gnc_commodity_table_lookup (
table, cpi->name_space, cpi->id);
1996 g_free (cpi->name_space);
2005 generic_gnc_commodity_lookup_parser_new (
void)
2009 if (! (top_level = sixtp_set_any (
2010 sixtp_new (), FALSE,
2011 SIXTP_START_HANDLER_ID, generic_gnc_commodity_lookup_start_handler,
2012 SIXTP_CHARACTERS_HANDLER_ID, allow_and_ignore_only_whitespace,
2013 SIXTP_END_HANDLER_ID, generic_gnc_commodity_lookup_end_handler,
2014 SIXTP_FAIL_HANDLER_ID, generic_free_data_for_children,
2015 SIXTP_AFTER_CHILD_HANDLER_ID,
2016 generic_gnc_commodity_lookup_after_child_handler,
2017 SIXTP_NO_MORE_HANDLERS)))
2022 if (!sixtp_add_some_sub_parsers (
2024 "space", simple_chars_only_parser_new (NULL),
2025 "id", simple_chars_only_parser_new (NULL),
2066 transaction_start_handler (GSList* sibling_data, gpointer parent_data,
2067 gpointer global_data, gpointer* data_for_children,
2068 gpointer* result,
const gchar* tag, gchar** attrs)
2071 *data_for_children = parent_data;
2110 txn_restore_start_handler (GSList* sibling_data, gpointer parent_data,
2111 gpointer global_data, gpointer* data_for_children,
2112 gpointer* result,
const gchar* tag, gchar** attrs)
2117 g_return_val_if_fail (trans, FALSE);
2120 *data_for_children = trans;
2126 txn_restore_end_handler (gpointer data_for_children,
2127 GSList* data_from_children, GSList* sibling_data,
2128 gpointer parent_data, gpointer global_data,
2129 gpointer* result,
const gchar* tag)
2132 Transaction* trans = (Transaction*) data_for_children;
2134 g_return_val_if_fail (trans, FALSE);
2157 txn_restore_after_child_handler (gpointer data_for_children,
2158 GSList* data_from_children,
2159 GSList* sibling_data,
2160 gpointer parent_data,
2161 gpointer global_data,
2164 const gchar* child_tag,
2165 sixtp_child_result* child_result)
2167 Transaction* trans = (Transaction*) data_for_children;
2168 g_return_val_if_fail (trans, FALSE);
2169 if (!child_result)
return (TRUE);
2170 if (child_result->type != SIXTP_CHILD_RESULT_NODE)
return (TRUE);
2171 if (strcmp (child_result->tag,
"slots") == 0)
2173 KvpFrame* f = (KvpFrame*) child_result->data;
2174 g_return_val_if_fail (f, FALSE);
2175 qof_instance_set_slots (QOF_INSTANCE (trans), f);
2176 child_result->should_cleanup = FALSE;
2182 txn_restore_fail_handler (gpointer data_for_children,
2183 GSList* data_from_children,
2184 GSList* sibling_data,
2185 gpointer parent_data,
2186 gpointer global_data,
2190 Transaction* trans = (Transaction*) data_for_children;
2220 txn_restore_guid_end_handler (gpointer data_for_children,
2221 GSList* data_from_children, GSList* sibling_data,
2222 gpointer parent_data, gpointer global_data,
2223 gpointer* result,
const gchar* tag)
2226 Transaction* t = (Transaction*) parent_data;
2231 g_return_val_if_fail (t, FALSE);
2233 txt = concatenate_child_result_chars (data_from_children);
2234 g_return_val_if_fail (txt, FALSE);
2239 g_return_val_if_fail (ok, FALSE);
2246 xaccTransSetGUID (t, &gid);
2272 txn_restore_num_end_handler (gpointer data_for_children,
2273 GSList* data_from_children, GSList* sibling_data,
2274 gpointer parent_data, gpointer global_data,
2275 gpointer* result,
const gchar* tag)
2277 Transaction* t = (Transaction*) parent_data;
2280 g_return_val_if_fail (t, FALSE);
2282 txt = concatenate_child_result_chars (data_from_children);
2283 g_return_val_if_fail (txt, FALSE);
2312 txn_restore_description_end_handler (gpointer data_for_children,
2313 GSList* data_from_children, GSList* sibling_data,
2314 gpointer parent_data, gpointer global_data,
2315 gpointer* result,
const gchar* tag)
2317 Transaction* t = (Transaction*) parent_data;
2320 g_return_val_if_fail (t, FALSE);
2322 txt = concatenate_child_result_chars (data_from_children);
2323 g_return_val_if_fail (txt, FALSE);
2342 txn_rest_date_posted_end_handler (gpointer data_for_children,
2343 GSList* data_from_children, GSList* sibling_data,
2344 gpointer parent_data, gpointer global_data,
2345 gpointer* result,
const gchar* tag)
2347 Transaction* t = (Transaction*) parent_data;
2350 g_return_val_if_fail (info, FALSE);
2351 if (!t || !timespec_parse_ok (info))
2374 txn_rest_date_entered_end_handler (gpointer data_for_children,
2375 GSList* data_from_children, GSList* sibling_data,
2376 gpointer parent_data, gpointer global_data,
2377 gpointer* result,
const gchar* tag)
2379 Transaction* t = (Transaction*) parent_data;
2382 g_return_val_if_fail (info, FALSE);
2383 if (!t || !timespec_parse_ok (info))
2421 txn_restore_split_start_handler (GSList* sibling_data, gpointer parent_data,
2422 gpointer global_data,
2423 gpointer* data_for_children, gpointer* result,
2424 const gchar* tag, gchar** attrs)
2428 g_return_val_if_fail (s, FALSE);
2429 *data_for_children = s;
2434 txn_restore_split_end_handler (gpointer data_for_children,
2435 GSList* data_from_children, GSList* sibling_data,
2436 gpointer parent_data, gpointer global_data,
2437 gpointer* result,
const gchar* tag)
2439 Transaction* t = (Transaction*) parent_data;
2440 Split* s = (Split*) data_for_children;
2442 g_return_val_if_fail (s, FALSE);
2461 txn_restore_split_after_child_handler (gpointer data_for_children,
2462 GSList* data_from_children,
2463 GSList* sibling_data,
2464 gpointer parent_data,
2465 gpointer global_data,
2468 const gchar* child_tag,
2469 sixtp_child_result* child_result)
2471 Split* s = (Split*) data_for_children;
2472 g_return_val_if_fail (s, FALSE);
2473 if (!child_result)
return (TRUE);
2474 if (child_result->type != SIXTP_CHILD_RESULT_NODE)
return (TRUE);
2476 if (strcmp (child_result->tag,
"slots") == 0)
2478 KvpFrame* f =
static_cast<KvpFrame*
> (child_result->data);
2479 g_return_val_if_fail (f, FALSE);
2480 if (s->inst.kvp_data)
delete s->inst.kvp_data;
2481 s->inst.kvp_data = f;
2482 child_result->should_cleanup = FALSE;
2484 else if (strcmp (child_result->tag,
"quantity") == 0)
2486 gnc_numeric* n = (gnc_numeric*) child_result->data;
2487 g_return_val_if_fail (n, FALSE);
2491 else if (strcmp (child_result->tag,
"value") == 0)
2493 gnc_numeric* n = (gnc_numeric*) child_result->data;
2494 g_return_val_if_fail (n, FALSE);
2503 txn_restore_split_fail_handler (gpointer data_for_children,
2504 GSList* data_from_children,
2505 GSList* sibling_data,
2506 gpointer parent_data,
2507 gpointer global_data,
2511 Split* s = (Split*) data_for_children;
2537 txn_restore_split_guid_end_handler (gpointer data_for_children,
2538 GSList* data_from_children, GSList* sibling_data,
2539 gpointer parent_data, gpointer global_data,
2540 gpointer* result,
const gchar* tag)
2543 Split* s = (Split*) parent_data;
2548 g_return_val_if_fail (s, FALSE);
2550 txt = concatenate_child_result_chars (data_from_children);
2551 g_return_val_if_fail (txt, FALSE);
2556 g_return_val_if_fail (ok, FALSE);
2563 xaccSplitSetGUID (s, &gid);
2589 txn_restore_split_memo_end_handler (gpointer data_for_children,
2590 GSList* data_from_children, GSList* sibling_data,
2591 gpointer parent_data, gpointer global_data,
2592 gpointer* result,
const gchar* tag)
2594 Split* s = (Split*) parent_data;
2597 g_return_val_if_fail (s, FALSE);
2599 txt = concatenate_child_result_chars (data_from_children);
2600 g_return_val_if_fail (txt, FALSE);
2629 txn_restore_split_action_end_handler (gpointer data_for_children,
2630 GSList* data_from_children, GSList* sibling_data,
2631 gpointer parent_data, gpointer global_data,
2632 gpointer* result,
const gchar* tag)
2634 Split* s = (Split*) parent_data;
2637 g_return_val_if_fail (s, FALSE);
2639 txt = concatenate_child_result_chars (data_from_children);
2640 g_return_val_if_fail (txt, FALSE);
2669 txn_restore_split_reconcile_state_end_handler (gpointer data_for_children,
2670 GSList* data_from_children, GSList* sibling_data,
2671 gpointer parent_data, gpointer global_data,
2672 gpointer* result,
const gchar* tag)
2674 Split* s = (Split*) parent_data;
2677 g_return_val_if_fail (s, FALSE);
2679 txt = concatenate_child_result_chars (data_from_children);
2680 g_return_val_if_fail (txt, FALSE);
2682 if (strlen (txt) != 1)
2705 txn_restore_split_reconcile_date_end_handler (gpointer data_for_children,
2706 GSList* data_from_children, GSList* sibling_data,
2707 gpointer parent_data, gpointer global_data,
2708 gpointer* result,
const gchar* tag)
2710 Split* s = (Split*) parent_data;
2713 g_return_val_if_fail (info, FALSE);
2714 if (!s || !timespec_parse_ok (info))
2747 txn_restore_split_account_end_handler (gpointer data_for_children,
2748 GSList* data_from_children, GSList* sibling_data,
2749 gpointer parent_data, gpointer global_data,
2750 gpointer* result,
const gchar* tag)
2753 Split* s = (Split*) parent_data;
2759 g_return_val_if_fail (s, FALSE);
2761 txt = concatenate_child_result_chars (data_from_children);
2762 g_return_val_if_fail (txt, FALSE);
2767 g_return_val_if_fail (ok, FALSE);
2770 g_return_val_if_fail (acct, FALSE);
2783 gnc_txn_restore_split_parser_new (
void)
2788 sixtp_set_any (sixtp_new (), FALSE,
2789 SIXTP_START_HANDLER_ID, txn_restore_split_start_handler,
2790 SIXTP_CHARACTERS_HANDLER_ID,
2791 allow_and_ignore_only_whitespace,
2792 SIXTP_END_HANDLER_ID, txn_restore_split_end_handler,
2793 SIXTP_FAIL_HANDLER_ID, txn_restore_split_fail_handler,
2794 SIXTP_AFTER_CHILD_HANDLER_ID,
2795 txn_restore_split_after_child_handler,
2796 SIXTP_NO_MORE_HANDLERS)))
2801 if (!sixtp_add_some_sub_parsers (
2803 "guid", restore_char_generator (txn_restore_split_guid_end_handler),
2804 "memo", restore_char_generator (txn_restore_split_memo_end_handler),
2806 restore_char_generator (txn_restore_split_action_end_handler),
2808 restore_char_generator (txn_restore_split_account_end_handler),
2810 restore_char_generator (txn_restore_split_reconcile_state_end_handler),
2812 generic_timespec_parser_new (
2813 txn_restore_split_reconcile_date_end_handler),
2814 "quantity", generic_gnc_numeric_parser_new (),
2815 "value", generic_gnc_numeric_parser_new (),
2816 "slots", kvp_frame_parser_new (),
2828 gnc_transaction_parser_new (
void)
2834 sixtp_set_any (sixtp_new (), FALSE,
2835 SIXTP_START_HANDLER_ID, transaction_start_handler,
2836 SIXTP_CHARACTERS_HANDLER_ID,
2837 allow_and_ignore_only_whitespace,
2838 SIXTP_AFTER_CHILD_HANDLER_ID,
2839 txn_restore_after_child_handler,
2840 SIXTP_NO_MORE_HANDLERS)))
2847 sixtp_set_any (sixtp_new (), FALSE,
2848 SIXTP_START_HANDLER_ID, txn_restore_start_handler,
2849 SIXTP_END_HANDLER_ID, txn_restore_end_handler,
2850 SIXTP_FAIL_HANDLER_ID, txn_restore_fail_handler,
2851 SIXTP_AFTER_CHILD_HANDLER_ID,
2852 txn_restore_after_child_handler,
2853 SIXTP_NO_MORE_HANDLERS)))
2855 sixtp_destroy (top_level);
2858 sixtp_add_sub_parser (top_level,
"restore", restore_pr);
2860 if (! (sixtp_add_some_sub_parsers (
2862 "guid", restore_char_generator (txn_restore_guid_end_handler),
2863 "num", restore_char_generator (txn_restore_num_end_handler),
2865 restore_char_generator (txn_restore_description_end_handler),
2867 generic_timespec_parser_new (txn_rest_date_posted_end_handler),
2869 generic_timespec_parser_new (txn_rest_date_entered_end_handler),
2870 "slots", kvp_frame_parser_new (),
2871 "split", gnc_txn_restore_split_parser_new (),
2874 sixtp_destroy (top_level);
2930 price_parse_xml_sub_node (GNCPrice* p, xmlNodePtr sub_node, QofBook* book)
2932 if (!p || !sub_node)
return FALSE;
2934 gnc_price_begin_edit (p);
2936 if (g_strcmp0 (
"price:id", (
char*)sub_node->name) == 0)
2938 GncGUID* c = dom_tree_to_guid (sub_node);
2939 if (!c)
return FALSE;
2940 gnc_price_set_guid (p, c);
2943 else if (g_strcmp0 (
"price:commodity", (
char*)sub_node->name) == 0)
2945 gnc_commodity* c = dom_tree_to_commodity_ref (sub_node, book);
2946 if (!c)
return FALSE;
2947 gnc_price_set_commodity (p, c);
2949 else if (g_strcmp0 (
"price:currency", (
char*)sub_node->name) == 0)
2951 gnc_commodity* c = dom_tree_to_commodity_ref (sub_node, book);
2952 if (!c)
return FALSE;
2953 gnc_price_set_currency (p, c);
2955 else if (g_strcmp0 (
"price:time", (
char*)sub_node->name) == 0)
2957 time64 time = dom_tree_to_time64 (sub_node);
2958 if (!dom_tree_valid_time64 (time, sub_node->name)) time = 0;
2959 gnc_price_set_time64 (p, time);
2961 else if (g_strcmp0 (
"price:source", (
char*)sub_node->name) == 0)
2963 char* text = dom_tree_to_text (sub_node);
2964 if (!text)
return FALSE;
2965 gnc_price_set_source_string (p, text);
2968 else if (g_strcmp0 (
"price:type", (
char*)sub_node->name) == 0)
2970 char* text = dom_tree_to_text (sub_node);
2971 if (!text)
return FALSE;
2972 gnc_price_set_typestr (p, text);
2975 else if (g_strcmp0 (
"price:value", (
char*)sub_node->name) == 0)
2977 gnc_price_set_value (p, dom_tree_to_gnc_numeric (sub_node));
2979 gnc_price_commit_edit (p);
2984 price_parse_xml_end_handler (gpointer data_for_children,
2985 GSList* data_from_children,
2986 GSList* sibling_data,
2987 gpointer parent_data,
2988 gpointer global_data,
2993 xmlNodePtr price_xml = (xmlNodePtr) data_for_children;
2999 if (parent_data)
return TRUE;
3003 if (!price_xml)
return FALSE;
3004 if (price_xml->next)
3007 goto cleanup_and_exit;
3009 if (price_xml->prev)
3012 goto cleanup_and_exit;
3014 if (!price_xml->xmlChildrenNode)
3017 goto cleanup_and_exit;
3024 goto cleanup_and_exit;
3027 for (child = price_xml->xmlChildrenNode; child; child = child->next)
3029 switch (child->type)
3031 case XML_COMMENT_NODE:
3034 case XML_ELEMENT_NODE:
3035 if (!price_parse_xml_sub_node (p, child, pstatus->book))
3038 goto cleanup_and_exit;
3042 PERR (
"Unknown node type (%d) while parsing gnc-price xml.", child->type);
3045 goto cleanup_and_exit;
3060 xmlFreeNode (price_xml);
3065 cleanup_gnc_price (sixtp_child_result* result)
3071 gnc_price_parser_new (
void)
3073 return sixtp_dom_parser_new (price_parse_xml_end_handler,
3096 pricedb_start_handler (GSList* sibling_data,
3097 gpointer parent_data,
3098 gpointer global_data,
3099 gpointer* data_for_children,
3106 g_return_val_if_fail (db, FALSE);
3112 pricedb_after_child_handler (gpointer data_for_children,
3113 GSList* data_from_children,
3114 GSList* sibling_data,
3115 gpointer parent_data,
3116 gpointer global_data,
3119 const gchar* child_tag,
3120 sixtp_child_result* child_result)
3122 GNCPriceDB* db = (GNCPriceDB*) * result;
3124 g_return_val_if_fail (db, FALSE);
3127 if (!child_result)
return (FALSE);
3128 if (child_result->type != SIXTP_CHILD_RESULT_NODE)
return (FALSE);
3130 if (strcmp (child_result->tag,
"price") == 0)
3132 GNCPrice* p = (GNCPrice*) child_result->data;
3134 g_return_val_if_fail (p, FALSE);
3146 pricedb_cleanup_result_handler (sixtp_child_result* result)
3150 GNCPriceDB* db = (GNCPriceDB*) result->data;
3152 result->data = NULL;
3157 gnc_pricedb_parser_new (
void)
3160 sixtp* price_parser;
3163 sixtp_set_any (sixtp_new (), TRUE,
3164 SIXTP_START_HANDLER_ID, pricedb_start_handler,
3165 SIXTP_AFTER_CHILD_HANDLER_ID, pricedb_after_child_handler,
3166 SIXTP_CHARACTERS_HANDLER_ID,
3167 allow_and_ignore_only_whitespace,
3168 SIXTP_RESULT_FAIL_ID, pricedb_cleanup_result_handler,
3169 SIXTP_CLEANUP_RESULT_ID, pricedb_cleanup_result_handler,
3170 SIXTP_NO_MORE_HANDLERS);
3172 if (!top_level)
return NULL;
3174 price_parser = gnc_price_parser_new ();
3178 sixtp_destroy (top_level);
3182 sixtp_add_sub_parser (top_level,
"price", price_parser);
void xaccAccountSetType(Account *acc, GNCAccountType tip)
Set the account's type.
void xaccSplitSetValue(Split *split, gnc_numeric val)
The xaccSplitSetValue() method sets the value of this split in the transaction's commodity.
gnc_commodity * gnc_commodity_table_insert(gnc_commodity_table *table, gnc_commodity *comm)
Add a new commodity to the commodity table.
Account * gnc_account_get_parent(const Account *acc)
This routine returns a pointer to the parent of the specified account.
GNCPrice * gnc_price_create(QofBook *book)
gnc_price_create - returns a newly allocated and initialized price with a reference count of 1...
This is the private header for the account structure.
#define xaccTransAppendSplit(t, s)
Add a split to the transaction.
gnc_commodity_table * gnc_commodity_table_get_table(QofBook *book)
Returns the commodity table associated with a book.
Transaction * xaccMallocTransaction(QofBook *book)
The xaccMallocTransaction() will malloc memory and initialize it.
void xaccSplitSetAction(Split *split, const char *actn)
The Action is an arbitrary user-assigned string.
void gnc_account_append_child(Account *new_parent, Account *child)
This function will remove from the child account any pre-existing parent relationship, and will then add the account as a child of the new parent.
void xaccAccountTreeScrubCommodities(Account *acc)
The xaccAccountTreeScrubCommodities will scrub the currency/commodity of all accounts & transactions ...
gnc_commodity * DxaccAccountGetCurrency(const Account *acc)
void xaccAccountSetNotes(Account *acc, const char *str)
Set the account's notes.
a simple price database for gnucash
gboolean xaccSplitDestroy(Split *split)
Destructor.
void gnc_price_unref(GNCPrice *p)
gnc_price_unref - indicate you're finished with a price (i.e.
GncGUID * guid_copy(const GncGUID *guid)
Returns a newly allocated GncGUID that matches the passed-in GUID.
void xaccLogDisable(void)
document me
gboolean string_to_guid(const gchar *string, GncGUID *guid)
Given a string, replace the given guid with the parsed one unless the given value is null...
gboolean gnc_pricedb_add_price(GNCPriceDB *db, GNCPrice *p)
Add a price to the pricedb.
void xaccAccountSetCode(Account *acc, const char *str)
Set the account's accounting code.
void xaccTransSetDescription(Transaction *trans, const char *desc)
Sets the transaction Description.
void xaccTransSetNum(Transaction *trans, const char *xnum)
Sets the transaction Number (or ID) field; rather than use this function directly, see 'gnc_set_num_action' in engine/engine-helpers.c & .h which takes a user-set book option for selecting the source for the num-cell (the transaction-number or the split-action field) in registers/reports into account automatically.
void xaccSplitSetReconcile(Split *split, char recn)
Set the reconcile flag.
#define PERR(format, args...)
Log a serious error.
api for Version 1 XML-based file format
GNCPriceDB * gnc_pricedb_get_db(QofBook *book)
Return the pricedb associated with the book.
void xaccTransDestroy(Transaction *trans)
Destroys a transaction.
void xaccAccountDestroy(Account *acc)
The xaccAccountDestroy() routine can be used to get rid of an account.
Transaction * xaccTransLookup(const GncGUID *guid, QofBook *book)
The xaccTransLookup() subroutine will return the transaction associated with the given id...
convert single-entry accounts to clean double-entry
Split * xaccSplitLookup(const GncGUID *guid, QofBook *book)
The xaccSplitLookup() subroutine will return the split associated with the given id, or NULL if there is no such split.
void xaccSplitSetAmount(Split *split, gnc_numeric amt)
The xaccSplitSetAmount() method sets the amount in the account's commodity that the split should have...
Account handling public routines.
void xaccSplitSetMemo(Split *split, const char *memo)
The memo is an arbitrary string associated with a split.
void gnc_pricedb_destroy(GNCPriceDB *db)
Destroy the given pricedb and unref all of the prices it contains.
gnc_commodity * gnc_commodity_new(QofBook *book, const char *fullname, const char *name_space, const char *mnemonic, const char *cusip, int fraction)
Create a new commodity.
gboolean xaccAccountStringToType(const char *str, GNCAccountType *type)
Conversion routines for the account types to/from strings that are used in persistent storage...
void xaccTransCommitEdit(Transaction *trans)
The xaccTransCommitEdit() method indicates that the changes to the transaction and its splits are com...
#define xaccSplitGetGUID(X)
void xaccTransBeginEdit(Transaction *trans)
The xaccTransBeginEdit() method must be called before any changes are made to a transaction or any of...
GNCAccountType
The account types are used to determine how the transaction data in the account is displayed...
Split * xaccMallocSplit(QofBook *book)
Constructor.
#define xaccTransGetGUID(X)
GList * gnc_account_get_descendants(const Account *account)
This routine returns a flat list of all of the accounts that are descendants of the specified account...
API for the transaction logger.
void xaccSplitSetDateReconciledSecs(Split *split, time64 secs)
Set the date on which this split was reconciled by specifying the time as time64. ...
void xaccTransSetDatePostedSecs(Transaction *trans, time64 secs)
The xaccTransSetDatePostedSecs() method will modify the posted date of the transaction, specified by a time64 (see ctime(3)).
void xaccAccountBeginEdit(Account *acc)
The xaccAccountBeginEdit() subroutine is the first phase of a two-phase-commit wrapper for account up...
gnc_commodity * xaccAccountGetCommodity(const Account *acc)
Get the account's commodity.
#define xaccAccountInsertSplit(acc, s)
The xaccAccountInsertSplit() method will insert the indicated split into the indicated account...
gboolean qof_session_load_from_xml_file(QofBook *, const char *filename)
Read in an account group from a file.
gnc_numeric gnc_numeric_from_string(const gchar *str)
Read a gnc_numeric from str, skipping any leading whitespace.
Account * xaccMallocAccount(QofBook *book)
Constructor.
GNCNumericErrorCode gnc_numeric_check(gnc_numeric in)
Check for error signal in value.
gint64 time64
Most systems that are currently maintained, including Microsoft Windows, BSD-derived Unixes and Linux...
void xaccAccountSetDescription(Account *acc, const char *str)
Set the account's description.
void DxaccAccountSetCurrency(Account *acc, gnc_commodity *currency)
void xaccTransSetDateEnteredSecs(Transaction *trans, time64 secs)
Modify the date of when the transaction was entered.
API for Transactions and Splits (journal entries)
The type used to store guids in C.
void xaccAccountCommitEdit(Account *acc)
ThexaccAccountCommitEdit() subroutine is the second phase of a two-phase-commit wrapper for account u...
void xaccAccountSetName(Account *acc, const char *str)
Set the account's name.
void gnc_commodity_destroy(gnc_commodity *cm)
Destroy a commodity.
void xaccLogEnable(void)
document me
gboolean gnc_is_xml_data_file(const gchar *name)
The is_gncxml_file() routine checks to see if the first few chars of the file look like gnc-xml data...
void xaccAccountSetCommodity(Account *acc, gnc_commodity *com)
Set the account's commodity.
Account * xaccAccountLookup(const GncGUID *guid, QofBook *book)
The xaccAccountLookup() subroutine will return the account associated with the given id...