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         QSF_UNDEF = 0, 
00043         IS_QSF_MAP,   
00044         IS_QSF_OBJ,   
00045         HAVE_QSF_MAP, 
00046         OUR_QSF_OBJ,  
00047 }qsf_type;
00048 
00057 typedef struct qsf_object_set
00058 {
00059         GHashTable *parameters;
00060         QofIdType object_type;
00061         gint object_count;
00062 }qsf_objects;
00063 
00064 #define QSF_QOF_VERSION QOF_OBJECT_VERSION 
00071 #define QSF_ROOT_TAG    "qof-qsf" 
00072 #define QSF_DEFAULT_NS  "http://qof.sourceforge.net/" 
00076 #define QSF_DATE_LENGTH MAX_DATE_LENGTH 
00079 #define QSF_BOOK_TAG    "book"      
00080 #define QSF_BOOK_GUID   "book-guid" 
00082 #define QSF_BOOK_COUNT  "count"     
00083 #define QSF_OBJECT_TAG  "object"    
00084 #define QSF_OBJECT_TYPE "type"      
00085 #define QSF_OBJECT_COUNT "count"    
00087 #define QSF_XML_VERSION  "1.0"      
00102 #define QSF_OBJECT_KVP   "path" 
00103 #define QSF_OBJECT_VALUE "value" 
00108 #define MAP_ROOT_TAG     "qsf-map" 
00109 #define MAP_DEFINITION_TAG "definition" 
00118 #define MAP_DEFINE_TAG  "define" 
00123 #define MAP_ITERATE_ATTR "foreach" 
00125 #define MAP_DEFAULT_TAG "default"  
00185 #define MAP_OBJECT_TAG  "object" 
00193 #define MAP_CALCULATE_TAG       "calculate" 
00201 #define MAP_QOF_VERSION "qof_version" 
00207 #define MAP_NAME_ATTR   "name" 
00214 #define MAP_TYPE_ATTR   "type" 
00220 #define MAP_VALUE_ATTR  "value" 
00229 #define MAP_OBJECT_ATTR "object" 
00231 #define MAP_E_TYPE      "e_type" 
00240 #define MAP_ENUM_TYPE "enum"
00241 
00244 #define QSF_BOOLEAN_DEFAULT "boolean"
00245 
00246 #define QSF_CONDITIONAL "if"  
00254 #define QSF_CONDITIONAL_SET "set" 
00262 #define QSF_CONDITIONAL_ELSE "else" 
00282 #define QSF_OPTION "option" 
00289 #define QSF_FORMATTING_OPTION "format" 
00299 #define QSF_XSD_TIME  QOF_UTC_DATE_FORMAT 
00330 #define QSF_XML_BOOLEAN_TEST "true" 
00332 #define QSF_OBJECT_SCHEMA "qsf-object.xsd.xml" 
00333 #define QSF_MAP_SCHEMA "qsf-map.xsd.xml" 
00352 typedef enum {
00353         QSF_NO_OBJECT = 0,     
00354         QSF_DEFINED_OBJECT,    
00357         QSF_REGISTERED_OBJECT, 
00359         QSF_CALCULATED_OBJECT, 
00360         QSF_INVALID_OBJECT     
00361 }QsfStatus;
00362 
00369 typedef struct qsf_metadata
00370 {
00371         qsf_type file_type;          
00372         qsf_objects *object_set;     
00373         gint count;                  
00374         GList *qsf_object_list;      
00375         GSList *qsf_sequence;        
00376         GList *referenceList;        
00377         GHashTable *qsf_parameter_hash; 
00378         GHashTable *qsf_calculate_hash, *qsf_default_hash, *qsf_define_hash;
00379         GSList *supported_types;     
00381         xmlDocPtr input_doc;     
00382         xmlDocPtr output_doc;    
00383         xmlNodePtr child_node;   
00384         xmlNodePtr convert_node; 
00385         xmlNodePtr param_node;   
00386         xmlNodePtr output_node;  
00387         xmlNodePtr output_root;  
00388         xmlNodePtr book_node;    
00389         xmlNodePtr lister;       
00390         xmlNsPtr qsf_ns, map_ns; 
00391         const gchar *qof_type;   
00392         QofIdType qof_obj_type;  
00393         QofIdType qof_foreach;   
00394         gint foreach_limit;      
00395         QofEntity *qsf_ent;      
00396         QofBackend *be;          
00397         gboolean knowntype;      
00398         QofParam *qof_param;     
00399         QofBook *book;           
00403         gint boolean_calculation_done; 
00404         gchar *filepath;              
00405         gchar *map_path;              
00406         gchar* full_kvp_path;         
00407         gint64 use_gz_level;          
00408         GList *map_files;             
00412         const gchar *encoding;        
00413 }qsf_param;
00414 
00420 typedef struct qsf_validates
00421 {
00422         QofBackendError error_state;
00423         const gchar *object_path;
00424         const gchar *map_path;
00425         GHashTable *object_table;  
00427         GHashTable *map_table;     
00429         /* Need to match object names, not just counts. */
00430         gint valid_object_count;   
00432         gint map_calculated_count; 
00434         gint qof_registered_count; 
00436         gint incoming_count;       
00438 }qsf_validator;
00439 
00445 gint
00446 qsf_compare_tag_strings(const xmlChar *node_name, gchar *tag_name);
00447 
00453 gint
00454 qsf_strings_equal(const xmlChar *node_name, gchar *tag_name);
00455 
00461 gint
00462 qsf_is_element(xmlNodePtr a, xmlNsPtr ns, gchar *c);
00463 
00469 gint
00470 qsf_check_tag(qsf_param *params, gchar *qof_type);
00471 
00477 void
00478 qsf_object_validation_handler(xmlNodePtr child, xmlNsPtr ns, qsf_validator *valid);
00479 
00492 gboolean
00493 qsf_is_valid(const gchar *schema_dir, const gchar* schema_filename, xmlDocPtr doc);
00494 
00501 GList** qsf_map_prepare_list(GList **maps);
00502 
00524 typedef void (* qsf_nodeCB)(xmlNodePtr, xmlNsPtr, qsf_param*);
00530 typedef void (* qsf_validCB)(xmlNodePtr, xmlNsPtr, qsf_validator*);
00535 struct qsf_node_iterate {
00536         qsf_nodeCB *fcn;
00537         qsf_validCB *v_fcn;
00538         xmlNsPtr ns;
00539 };
00540 
00558 gboolean is_qsf_object_be(qsf_param *params);
00576 gboolean is_qsf_object(const gchar *path);
00591 gboolean is_our_qsf_object_be(qsf_param *params);
00606 gboolean is_our_qsf_object(const gchar *path);
00618 gboolean is_qsf_map_be(qsf_param *params);
00635 gboolean is_qsf_map(const gchar *path);
00651 gboolean is_qsf_object_with_map_be(gchar *map_path, qsf_param *params);
00665 gboolean is_qsf_object_with_map(const gchar *path, gchar *map_file);
00666 
00675 void qsf_book_node_handler(xmlNodePtr child, xmlNsPtr qsf_ns, qsf_param *params);
00676 
00689 KvpValue*
00690 string_to_kvp_value(const gchar *content, KvpValueType type);
00691 
00698 void
00699 qsf_valid_foreach(xmlNodePtr parent, qsf_validCB cb,
00700         struct qsf_node_iterate *iter, qsf_validator *valid);
00701 
00707 void
00708 qsf_node_foreach(xmlNodePtr parent, qsf_nodeCB cb,
00709         struct qsf_node_iterate *iter, qsf_param *params);
00710 
00725 xmlDocPtr
00726 qsf_object_convert(xmlDocPtr mapDoc, xmlNodePtr qsf_root, qsf_param *params);
00727 
00733 void
00734 qsf_object_node_handler(xmlNodePtr child, xmlNsPtr qsf_ns, qsf_param *params);
00735 
00739 #endif /* QSF_XML_H */

Generated on Fri May 12 18:00:33 2006 for QOF by  doxygen 1.4.4