qsf-xml.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *            qsf-xml.h
00003  *
00004  *  Fri Nov 26 19:29:47 2004
00005  *  Copyright  2004-2005  Neil Williams  <linux@codehelp.co.uk>
00006  *
00007  ****************************************************************************/
00008 /*
00009  *  This program is free software; you can redistribute it and/or modify
00010  *  it under the terms of the GNU General Public License as published by
00011  *  the Free Software Foundation; either version 2 of the License, or
00012  *  (at your option) any later version.
00013  *
00014  *  This program is distributed in the hope that it will be useful,
00015  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  *  GNU Library General Public License for more details.
00018  *
00019  *  You should have received a copy of the GNU General Public License
00020  *  along with this program; if not, write to the Free Software
00021  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00022  */
00023 
00024  #ifndef QSF_XML_H
00025  #define QSF_XML_H
00026 
00032 #include <stdio.h>
00033 #include <stdlib.h>
00034 #include <glib.h>
00035 #include <regex.h>
00036 #include <time.h>
00037 #include <libxml/xmlmemory.h>
00038 #include <libxml/tree.h>
00039 #include <libxml/parser.h>
00040 #include <libxml/xmlschemas.h>
00041 #include "gnc-date.h"
00042 #include "qof_book_merge.h"
00043 #include "qofbook.h"
00044 #include "qofclass.h"
00045 #include "qofobject.h"
00046 #include "kvp_frame.h"
00047 #include "qofbackend-p.h"
00048 #include "qofsession-p.h"
00049 #include "qofbook-p.h"
00050 
00051 #if defined(HAVE_GETTEXT)             /* HAVE_GETTEXT */
00052 
00053 #include <libintl.h>
00054 #include <locale.h>
00055 
00056 #undef _
00057 #undef Q_
00058 
00059 #ifdef DISABLE_GETTEXT_UNDERSCORE
00060 #define _(String) (String)
00061 #define Q_(String) gnc_qualifier_prefix_noop(String)
00062 #else                                 /* ENABLE_GETTEXT_UNDERSCORE */
00063 #define _(String) gettext(String)
00064 #define Q_(String) gnc_qualifier_prefix_gettext(String)
00065 #endif                                /* End ENABLE_GETTEXT_UNDERSCORE */
00066 
00067 #else                                 /* Not HAVE_GETTEXT */
00068 #if !defined(__USE_GNU_GETTEXT)
00069 
00070 #undef _
00071 #undef Q_
00072 #define _(String)       (String)
00073 #define Q_(String) gnc_qualifier_prefix_noop(String)
00074 #define gettext(String) (String)
00075 #define ngettext(msgid, msgid_plural, n) (((n)==1) ? \
00076                                             (msgid) : (msgid_plural))
00077 
00078 #endif                                /* End not__USE_GNU_GETTEXT */
00079 #endif                                /* End Not HAVE_GETTEXT */
00080 
00081 #undef  N_
00082 #define N_(String) (String)
00083 
00084 
00085 typedef enum  {
00086         QSF_UNDEF = 0, 
00087         IS_QSF_MAP,   
00088         IS_QSF_OBJ,   
00089         HAVE_QSF_MAP, 
00090         OUR_QSF_OBJ,  
00091 }qsf_type;
00092         
00101 typedef struct qsf_object_set
00102 {
00103         GHashTable *parameters;
00104         QofIdType object_type;
00105         int object_count;
00106 }qsf_objects;
00107 
00108 #define QSF_QOF_VERSION QOF_OBJECT_VERSION 
00115 #define QSF_ROOT_TAG    "qof-qsf" 
00116 #define QSF_DEFAULT_NS  "http://qof.sourceforge.net/" 
00120 #define QSF_DATE_LENGTH 31 
00121 #define QSF_BOOK_TAG    "book" 
00122 #define QSF_BOOK_GUID   "book-guid" 
00123 #define QSF_BOOK_COUNT  "count" 
00124 #define QSF_OBJECT_TAG  "object" 
00125 #define QSF_OBJECT_TYPE "type" 
00126 #define QSF_OBJECT_COUNT "count" 
00127 #define QSF_XML_VERSION  "1.0"  
00142 #define QSF_OBJECT_KVP  "path" 
00143 #define QSF_OBJECT_VALUE "value" 
00148 #define MAP_ROOT_TAG    "qsf-map" 
00149 #define MAP_DEFINITION_TAG      "definition" 
00158 #define MAP_DEFINE_TAG  "define" 
00163 #define MAP_DEFAULT_TAG "default"  
00220 #define MAP_OBJECT_TAG  "object" 
00226 #define MAP_CALCULATE_TAG       "calculate" 
00232 #define MAP_QOF_VERSION "qof_version" 
00238 #define MAP_NAME_ATTR   "name" 
00245 #define MAP_TYPE_ATTR   "type" 
00250 #define MAP_VALUE_ATTR  "value" 
00257 #define MAP_E_TYPE      "e_type" 
00266 #define MAP_ENUM_TYPE "enum"
00267 
00270 #define QSF_BOOLEAN_DEFAULT "boolean"
00271 
00272 #define QSF_CONDITIONAL "if"  
00280 #define QSF_CONDITIONAL_SET "set" 
00288 #define QSF_CONDITIONAL_ELSE "else" 
00307 #define QSF_OPTION "option" 
00314 #define QSF_FORMATTING_OPTION "format" 
00324 #define QSF_XSD_TIME  QOF_UTC_DATE_FORMAT 
00353 #define QSF_XML_BOOLEAN_TEST "true" 
00355 #define QSF_OBJECT_SCHEMA "qsf-object.xsd.xml" 
00356 #define QSF_MAP_SCHEMA "qsf-map.xsd.xml" 
00363 typedef struct qsf_metadata
00364 {
00365         qsf_type file_type;          
00366         qsf_objects *object_set;     
00367         int count;                   
00368         GList *qsf_object_list;      
00369         GSList *qsf_sequence;        
00370         GList *referenceList;        
00371         GHashTable *qsf_parameter_hash; 
00372         GHashTable *qsf_calculate_hash, *qsf_default_hash, *qsf_define_hash;
00373         GSList *supported_types;     
00374         xmlDocPtr input_doc, output_doc; 
00376         xmlNodePtr child_node, cur_node, param_node, output_node, output_root, book_node, lister;
00377         xmlNsPtr qsf_ns, map_ns;     
00378         const char *qof_type;        
00379         QofIdType qof_obj_type;      
00380         QofEntity *qsf_ent;          
00381         QofBackend *be;              
00382         gboolean knowntype;          
00383         QofParam *qof_param;         
00384         QofBook *book;               
00388         int boolean_calculation_done; 
00389         char *filepath; 
00390 }qsf_param;
00391 
00397 void qsf_free_params(qsf_param *params);
00398 
00407 typedef struct qsf_validates
00408 {
00409         QofBackendError error_state;
00410         const char *object_path;
00411         const char *map_path;
00412         GHashTable *validation_table;
00413         int valid_object_count;
00414         int map_calculated_count;
00415         int qof_registered_count;
00416 }qsf_validator;
00417 
00418 
00424 int
00425 qsf_compare_tag_strings(const xmlChar *node_name, char *tag_name);
00426 
00432 int
00433 qsf_strings_equal(const xmlChar *node_name, char *tag_name);
00434 
00440 int
00441 qsf_is_element(xmlNodePtr a, xmlNsPtr ns, char *c);
00442 
00448 int
00449 qsf_check_tag(qsf_param *params, char *qof_type);
00450 
00456 void
00457 qsf_object_validation_handler(xmlNodePtr child, xmlNsPtr ns, qsf_validator *valid);
00458 
00471 void
00472 qsf_map_validation_handler(xmlNodePtr child, xmlNsPtr ns, qsf_validator *valid);
00473 
00474 void
00475 qsf_map_top_node_handler(xmlNodePtr child, xmlNsPtr ns, qsf_param *params);
00476 
00477 void
00478 qsf_map_object_handler(xmlNodePtr child, xmlNsPtr ns, qsf_param *params);
00493 gboolean
00494 qsf_is_valid(const char *schema_dir, const char* schema_filename, xmlDocPtr doc);
00495 
00513 gboolean is_qsf_object_be(qsf_param *params);
00514 
00529 gboolean is_our_qsf_object_be(qsf_param *params);
00530 
00542 gboolean is_qsf_map_be(qsf_param *params);
00543 
00560 gboolean is_qsf_object_with_map_be(char *map_path, qsf_param *params);
00561 
00562 gboolean is_qsf_object_with_map(const char *path, char *map_file);
00563 
00572 gboolean
00573 load_qsf_object(QofBook *book, const char *fullpath, qsf_param *params);
00574 
00580 gboolean
00581 load_our_qsf_object(QofBook *book, const char *fullpath, qsf_param *params);
00582 
00589 void qsf_book_node_handler(xmlNodePtr child, xmlNsPtr qsf_ns, qsf_param *params);
00590 
00614 void qsf_object_commitCB(gpointer key, gpointer value, gpointer data);
00615 
00628 KvpValue*
00629 string_to_kvp_value(const char *content, KvpValueType type);
00630 
00652 void qsf_param_init(qsf_param *params);
00653 
00654 
00660 typedef void (* qsf_nodeCB)(xmlNodePtr, xmlNsPtr, qsf_param*);
00661 
00667 typedef void (* qsf_validCB)(xmlNodePtr, xmlNsPtr, qsf_validator*);
00668 
00669 
00674 struct qsf_node_iterate {
00675         qsf_nodeCB *fcn;
00676         qsf_validCB *v_fcn;
00677         xmlNsPtr ns;
00678 };
00679 
00697 gboolean is_qsf_object(const char *path);
00698 
00718 gboolean is_our_qsf_object(const char *path);
00719 
00736 gboolean is_qsf_map(const char *path);
00737 
00754 void
00755 qsf_file_type (QofBackend *be, QofBook *book);
00756 
00757 void
00758 qsf_valid_foreach(xmlNodePtr parent, qsf_validCB cb,
00759         struct qsf_node_iterate *iter, qsf_validator *valid);
00760 
00761 void
00762 qsf_node_foreach(xmlNodePtr parent, qsf_nodeCB cb,
00763         struct qsf_node_iterate *iter, qsf_param *params);
00764 
00781 QofBackendError 
00782 qof_session_load_our_qsf_object(QofSession *first_session, const char *path);
00783 
00790 QofBackendError 
00791 qof_session_load_qsf_object(QofSession *first_session, const char *path);
00792 
00807 xmlDocPtr
00808 qsf_object_convert(xmlDocPtr mapDoc, xmlNodePtr qsf_root, qsf_param *params);
00809 
00810 void
00811 qsf_object_node_handler(xmlNodePtr child, xmlNsPtr qsf_ns, qsf_param *params);
00812 
00843 void qsf_write_file(QofBackend *be, QofBook *book);
00844 
00847 QofBackend* qsf_backend_new(void);
00848         
00852 #endif /* QSF_XML_H */

Generated on Fri Oct 21 15:49:56 2005 for QOF by  doxygen 1.4.5