00001 /* 00002 * WBXML Lib, the WBXML Library. 00003 * Copyright (C) 2002-2003 Aymerick Jéhanne 00004 * 00005 * This library is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU Lesser General Public 00007 * License (version 2.1) as published by the Free Software Foundation. 00008 * 00009 * This library is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 * Lesser General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU Lesser General Public 00015 * License along with this library; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 * 00018 * LGPL v2.1: http://www.gnu.org/licenses/lgpl.txt 00019 * 00020 * Author Contact: libwbxml@jehanne.org 00021 * WBXML Lib home: http://libwbxml.jehanne.org 00022 */ 00023 00034 #ifndef WBXML_TREE_H 00035 #define WBXML_TREE_H 00036 00037 00038 #ifdef __cplusplus 00039 extern "C" { 00040 #endif /* __cplusplus */ 00041 00047 /**************************************************** 00048 * WBXML Tree Structures 00049 */ 00050 00051 00055 typedef enum WBXMLTreeNodeType_e 00056 { 00057 WBXML_TREE_ELEMENT_NODE = 0, 00058 WBXML_TREE_TEXT_NODE, 00059 WBXML_TREE_PI_NODE, 00060 WBXML_TREE_TREE_NODE 00061 } WBXMLTreeNodeType; 00062 00063 00067 typedef struct WBXMLTreeAttribute_s 00068 { 00069 WBXMLAttribute *attr; 00070 struct WBXMLTreeAttribute_s *next; 00071 } WBXMLTreeAttribute; 00072 00073 00077 typedef struct WBXMLTreeNode_s 00078 { 00079 WBXMLTreeNodeType type; 00080 WBXMLTag *name; 00081 WBXMLTreeAttribute *attrs; 00082 WBXMLBuffer *content; 00083 struct WBXMLTree_s *tree; 00085 struct WBXMLTreeNode_s *parent; 00086 struct WBXMLTreeNode_s *children; 00087 struct WBXMLTreeNode_s *next; 00088 struct WBXMLTreeNode_s *prev; 00089 } WBXMLTreeNode; 00090 00091 00095 typedef struct WBXMLTree_s 00096 { 00097 const WBXMLLangEntry *lang; 00098 WBXMLTreeNode *root; 00099 } WBXMLTree; 00100 00101 00106 typedef struct WBXMLTreeClbCtx_s { 00107 /* For XML and WBXML Clb: */ 00108 WBXMLTree *tree; 00109 WBXMLTreeNode *current; 00110 WBXMLError error; 00111 /* For XML Clb: */ 00112 WB_ULONG skip_lvl; 00113 WB_LONG skip_start; 00114 WB_UTINY *input_buff; 00115 #if defined( HAVE_EXPAT ) 00116 XML_Parser xml_parser; 00117 #endif /* HAVE_EXPAT */ 00118 } WBXMLTreeClbCtx; 00119 00120 00121 /**************************************************** 00122 * WBXML Tree Building Functions 00123 */ 00124 00133 WBXML_DECLARE(WBXMLError) wbxml_tree_from_wbxml(WB_UTINY *wbxml, WB_ULONG wbxml_len, WBXMLLanguage lang, WBXMLTree **tree); 00134 00142 WBXML_DECLARE(WBXMLError) wbxml_tree_from_xml(WB_UTINY *xml, WBXMLTree **tree); 00143 00144 00145 /**************************************************** 00146 * WBXML Tree Functions 00147 */ 00148 00149 /* WBXMLTreeAttribute */ 00150 00155 WBXML_DECLARE(WBXMLTreeAttribute *) wbxml_tree_attribute_create(void); 00156 00161 WBXML_DECLARE(void) wbxml_tree_attribute_destroy(WBXMLTreeAttribute *attr); 00162 00163 00164 /* WBXMLTreeNode */ 00165 00171 WBXML_DECLARE(WBXMLTreeNode *) wbxml_tree_node_create(WBXMLTreeNodeType type); 00172 00177 WBXML_DECLARE(void) wbxml_tree_node_destroy(WBXMLTreeNode *node); 00178 00179 00180 /* WBXMLTree */ 00181 00186 WBXML_DECLARE(WBXMLTree *) wbxml_tree_create(void); 00187 00192 WBXML_DECLARE(void) wbxml_tree_destroy(WBXMLTree *tree); 00193 00202 WBXML_DECLARE(WBXMLTreeNode *) wbxml_tree_get_element_node_from_name(WBXMLTreeNode *node, const char *name, WB_BOOL recurs); 00203 00204 00207 #ifdef __cplusplus 00208 } 00209 #endif /* __cplusplus */ 00210 00211 #endif /* WBXML_TREE_H */