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,2006  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 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00022  */
00023 
00024 #ifndef QSF_XML_H
00025 #define QSF_XML_H
00026 
00032 #include <stdio.h>
00033 #include <stdlib.h>
00034 #include <regex.h>
00035 #include <time.h>
00036 #include "qof.h"
00037 
00038 #include <libintl.h>
00039 #define _(String) dgettext (GETTEXT_PACKAGE, String)
00040 
00041 typedef enum
00042 {
00043     QSF_UNDEF = 0, 
00044     IS_QSF_MAP,   
00045     IS_QSF_OBJ,   
00046     HAVE_QSF_MAP, 
00047     OUR_QSF_OBJ,  
00048 } qsf_type;
00049 
00058 typedef struct qsf_object_set
00059 {
00060     GHashTable *parameters;
00061     QofIdType object_type;
00062     gint object_count;
00063 } qsf_objects;
00064 
00065 #define QSF_QOF_VERSION QOF_OBJECT_VERSION 
00072 #define QSF_ROOT_TAG    "qof-qsf" 
00073 #define QSF_DEFAULT_NS  "http://qof.sourceforge.net/" 
00077 #define QSF_DATE_LENGTH MAX_DATE_LENGTH 
00080 #define QSF_BOOK_TAG    "book"      
00081 #define QSF_BOOK_GUID   "book-guid" 
00083 #define QSF_BOOK_COUNT  "count"     
00084 #define QSF_OBJECT_TAG  "object"    
00085 #define QSF_OBJECT_TYPE "type"      
00086 #define QSF_OBJECT_COUNT "count"    
00088 #define QSF_XML_VERSION  "1.0"      
00103 #define QSF_OBJECT_KVP   "path" 
00104 #define QSF_OBJECT_VALUE "value" 
00109 #define MAP_ROOT_TAG     "qsf-map" 
00110 #define MAP_DEFINITION_TAG "definition" 
00119 #define MAP_DEFINE_TAG  "define" 
00124 #define MAP_ITERATE_ATTR "foreach" 
00126 #define MAP_DEFAULT_TAG "default"  
00186 #define MAP_OBJECT_TAG  "object" 
00194 #define MAP_CALCULATE_TAG   "calculate" 
00202 #define MAP_QOF_VERSION "qof_version" 
00208 #define MAP_NAME_ATTR   "name" 
00215 #define MAP_TYPE_ATTR   "type" 
00221 #define MAP_VALUE_ATTR  "value" 
00230 #define MAP_OBJECT_ATTR "object" 
00232 #define MAP_E_TYPE  "e_type" 
00241 #define MAP_ENUM_TYPE "enum"
00242 
00245 #define QSF_BOOLEAN_DEFAULT "boolean"
00246 
00247 #define QSF_CONDITIONAL "if"  
00255 #define QSF_CONDITIONAL_SET "set" 
00263 #define QSF_CONDITIONAL_ELSE "else" 
00283 #define QSF_OPTION "option" 
00290 #define QSF_FORMATTING_OPTION "format" 
00300 #define QSF_XSD_TIME  QOF_UTC_DATE_FORMAT 
00331 #define QSF_XML_BOOLEAN_TEST "true" 
00333 #define QSF_OBJECT_SCHEMA "qsf-object.xsd.xml" 
00334 #define QSF_MAP_SCHEMA "qsf-map.xsd.xml" 
00353 typedef enum
00354 {
00355     QSF_NO_OBJECT = 0,     
00356     QSF_DEFINED_OBJECT,    
00359     QSF_REGISTERED_OBJECT, 
00361     QSF_CALCULATED_OBJECT, 
00362     QSF_INVALID_OBJECT     
00363 } QsfStatus;
00364 
00371 typedef struct qsf_metadata
00372 {
00373     qsf_type file_type;          
00374     qsf_objects *object_set;     
00375     gint count;                  
00376     GList *qsf_object_list;      
00377     GSList *qsf_sequence;        
00378     GList *referenceList;        
00379     GHashTable *qsf_parameter_hash; 
00380     GHashTable *qsf_calculate_hash, *qsf_default_hash, *qsf_define_hash;
00381     GSList *supported_types;     
00383     xmlDocPtr input_doc;     
00384     xmlDocPtr output_doc;    
00385     xmlNodePtr child_node;   
00386     xmlNodePtr convert_node; 
00387     xmlNodePtr param_node;   
00388     xmlNodePtr output_node;  
00389     xmlNodePtr output_root;  
00390     xmlNodePtr book_node;    
00391     xmlNodePtr lister;       
00392     xmlNsPtr qsf_ns, map_ns; 
00393     const gchar *qof_type;   
00394     QofIdType qof_obj_type;  
00395     QofIdType qof_foreach;   
00396     gint foreach_limit;      
00397     QofEntity *qsf_ent;      
00398     QofBackend *be;          
00399     gboolean knowntype;      
00400     QofParam *qof_param;     
00401     QofBook *book;           
00405     gint boolean_calculation_done; 
00406     gchar *filepath;              
00407     gchar *map_path;              
00408     gchar *full_kvp_path;         
00409     gint64 use_gz_level;          
00410     GList *map_files;             
00414     const gchar *encoding;        
00415     gint64 convert;               
00416 } qsf_param;
00417 
00423 typedef struct qsf_validates
00424 {
00425     QofBackendError error_state;
00426     const gchar *object_path;
00427     const gchar *map_path;
00428     GHashTable *object_table;  
00430     GHashTable *map_table;     
00432     /* Need to match object names, not just counts. */
00433     gint valid_object_count;   
00435     gint map_calculated_count; 
00437     gint qof_registered_count; 
00439     gint incoming_count;       
00441 } qsf_validator;
00442 
00448 gint qsf_compare_tag_strings (const xmlChar * node_name, gchar * tag_name);
00449 
00455 gint qsf_strings_equal (const xmlChar * node_name, gchar * tag_name);
00456 
00462 gint qsf_is_element (xmlNodePtr a, xmlNsPtr ns, gchar * c);
00463 
00469 gint qsf_check_tag (qsf_param * params, gchar * qof_type);
00470 
00476 void
00477 qsf_object_validation_handler (xmlNodePtr child, xmlNsPtr ns,
00478                                qsf_validator * valid);
00479 
00492 gboolean
00493 qsf_is_valid (const gchar * schema_dir, const gchar * schema_filename,
00494               xmlDocPtr doc);
00495 
00502 GList **qsf_map_prepare_list (GList ** maps);
00503 
00525 typedef void (*qsf_nodeCB) (xmlNodePtr, xmlNsPtr, qsf_param *);
00531 typedef void (*qsf_validCB) (xmlNodePtr, xmlNsPtr, qsf_validator *);
00536 struct qsf_node_iterate
00537 {
00538     qsf_nodeCB *fcn;
00539     qsf_validCB *v_fcn;
00540     xmlNsPtr ns;
00541 };
00542 
00560 gboolean is_qsf_object_be (qsf_param * params);
00578 gboolean is_qsf_object (const gchar * path);
00593 gboolean is_our_qsf_object_be (qsf_param * params);
00608 gboolean is_our_qsf_object (const gchar * path);
00620 gboolean is_qsf_map_be (qsf_param * params);
00637 gboolean is_qsf_map (const gchar * path);
00653 gboolean is_qsf_object_with_map_be (gchar * map_path, qsf_param * params);
00667 gboolean is_qsf_object_with_map (const gchar * path, gchar * map_file);
00668 
00677 void qsf_book_node_handler (xmlNodePtr child, xmlNsPtr qsf_ns,
00678                             qsf_param * params);
00679 
00692 KvpValue *string_to_kvp_value (const gchar * content, KvpValueType type);
00693 
00700 void
00701 qsf_valid_foreach (xmlNodePtr parent, qsf_validCB cb,
00702                    struct qsf_node_iterate *iter, qsf_validator * valid);
00703 
00709 void
00710 qsf_node_foreach (xmlNodePtr parent, qsf_nodeCB cb,
00711                   struct qsf_node_iterate *iter, qsf_param * params);
00712 
00727 xmlDocPtr
00728 qsf_object_convert (xmlDocPtr mapDoc, xmlNodePtr qsf_root,
00729                     qsf_param * params);
00730 
00736 void
00737 qsf_object_node_handler (xmlNodePtr child, xmlNsPtr qsf_ns,
00738                          qsf_param * params);
00739 
00743 #endif /* QSF_XML_H */

Generated on Fri Sep 1 15:35:57 2006 for QOF by  doxygen 1.4.6