GnuCash 2.4.99
io-gncxml-v2.h
Go to the documentation of this file.
00001 /********************************************************************\
00002  * io-gncxml-v2.h -- api for gnucash xml i/o                        *
00003  *                                                                  *
00004  * Copyright (c) 2001 Gnumatic Incorporated                         *
00005  *                                                                  *
00006  * This program is free software; you can redistribute it and/or    *
00007  * modify it under the terms of the GNU General Public License as   *
00008  * published by the Free Software Foundation; either version 2 of   *
00009  * the License, or (at your option) any later version.              *
00010  *                                                                  *
00011  * This program is distributed in the hope that it will be useful,  *
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
00014  * GNU General Public License for more details.                     *
00015  *                                                                  *
00016  * You should have received a copy of the GNU General Public License*
00017  * along with this program; if not, contact:                        *
00018  *                                                                  *
00019  * Free Software Foundation           Voice:  +1-617-542-5942       *
00020  * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
00021  * Boston, MA  02110-1301,  USA       gnu@gnu.org                   *
00022  *                                                                  *
00023 \********************************************************************/
00024 
00031 #ifndef IO_GNCXML_V2_H
00032 #define IO_GNCXML_V2_H
00033 
00034 #include <glib.h>
00035 
00036 #include "gnc-engine.h"
00037 #include "gnc-backend-xml.h"
00038 
00039 #include "sixtp.h"
00040 
00041 typedef struct
00042 {
00043     int accounts_total;
00044     int accounts_loaded;
00045 
00046     int books_total;
00047     int books_loaded;
00048 
00049     int commodities_total;
00050     int commodities_loaded;
00051 
00052     int transactions_total;
00053     int transactions_loaded;
00054 
00055     int prices_total;
00056     int prices_loaded;
00057 
00058     int schedXactions_total;
00059     int schedXactions_loaded;
00060 
00061     int budgets_total;
00062     int budgets_loaded;
00063 } load_counter;
00064 
00065 typedef struct sixtp_gdv2 sixtp_gdv2;
00066 typedef void (*countCallbackFn)(sixtp_gdv2 *gd, const char *type);
00067 struct sixtp_gdv2
00068 {
00069     QofBook *book;
00070     load_counter counter;
00071     countCallbackFn countCallback;
00072     QofBePercentageFunc gui_display_fn;
00073     gboolean exporting;
00074 };
00075 
00099 #define GNC_FILE_BACKEND        "gnc:file:2"
00100 #define GNC_FILE_BACKEND_VERS   2
00101 typedef struct
00102 {
00103     int         version;        /* backend version number */
00104     const char *        type_name;      /* The XML tag for this type */
00105 
00106     sixtp *     (*create_parser) (void);
00107     gboolean    (*add_item)(sixtp_gdv2 *, gpointer obj);
00108     int       (*get_count) (QofBook *);
00109     gboolean    (*write) (FILE*, QofBook*);
00110     void                (*scrub) (QofBook *);
00111     gboolean    (*ns) (FILE*);
00112 } GncXmlDataType_t;
00113 
00120 typedef struct
00121 {
00122     AccountList *accts;
00123     TransList   *transactions;
00124     QofBook *book;
00125 } gnc_template_xaction_data;
00126 
00128 void run_callback(sixtp_gdv2 *data, const char *type);
00129 
00131 gboolean qof_session_load_from_xml_file_v2(FileBackend *, QofBook *, QofBookFileType);
00132 
00133 /* write all book info to a file */
00134 gboolean gnc_book_write_to_xml_filehandle_v2(QofBook *book, FILE *fh);
00135 gboolean gnc_book_write_to_xml_file_v2(QofBook *book, const char *filename, gboolean compress);
00136 
00138 gboolean gnc_book_write_accounts_to_xml_filehandle_v2(QofBackend *be, QofBook *book, FILE *fh);
00139 gboolean gnc_book_write_accounts_to_xml_file_v2(QofBackend * be, QofBook *book,
00140         const char *filename);
00141 
00145 QofBookFileType gnc_is_xml_data_file_v2(const gchar *name, gboolean *with_encoding);
00146 
00150 gboolean gnc_xml2_write_namespace_decl (FILE *out, const char *namespace);
00151 
00152 
00153 typedef struct
00154 {
00155     GQuark encoding;
00156     gchar *utf8_string;
00157 } conv_type;
00158 
00180 gint gnc_xml2_find_ambiguous(
00181     const gchar *filename, GList *encodings, GHashTable **unique,
00182     GHashTable **ambiguous, GList **impossible);
00183 
00189 gboolean gnc_xml2_parse_with_subst (
00190     FileBackend *fbe, QofBook *book, GHashTable *subst);
00191 
00192 #endif /* __IO_GNCXML_V2_H__ */
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines