pleyo.com

/src/trunk2/BAL/Interfaces/BTXML.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2007 Pleyo.  All rights reserved.
00003  *
00004  * Redistribution and use in source and binary forms, with or without
00005  * modification, are permitted provided that the following conditions
00006  * are met:
00007  *
00008  * 1.  Redistributions of source code must retain the above copyright
00009  *     notice, this list of conditions and the following disclaimer.
00010  * 2.  Redistributions in binary form must reproduce the above copyright
00011  *     notice, this list of conditions and the following disclaimer in the
00012  *     documentation and/or other materials provided with the distribution.
00013  * 3.  Neither the name of Pleyo nor the names of
00014  *     its contributors may be used to endorse or promote products derived
00015  *     from this software without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY PLEYO AND ITS CONTRIBUTORS "AS IS" AND ANY
00018  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00019  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00020  * DISCLAIMED. IN NO EVENT SHALL PLEYO OR ITS CONTRIBUTORS BE LIABLE FOR ANY
00021  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00022  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00023  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00024  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00025  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
00026  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00027  */
00028 #ifndef BTXML_H_
00029 #define BTXML_H_
00030 
00031 
00032 namespace BAL {
00033     
00034     class BTXMLNode;
00035     class BTXMLDoc;
00036     class BTXMLNs;
00037     class BTXMLDict;
00038     
00039     #define BTXML_ELEMENT_NODE                 1
00040     #define BTXML_TEXT_NODE                    3
00041     #define BTXML_HTML_DOCUMENT_NODE          13
00042     #define BTXML_CHAR_ENCODING_UTF16LE        2
00043     #define BTXML_CHAR_ENCODING_UTF16BE        3
00044     #define BTXML_ENTITY_DECL                 17
00045     #define BTXML_INTERNAL_PREDEFINED_ENTITY   6
00046     #define BTXML_SAX2_MAGIC 0xDEEDBEAF
00047      
00048     typedef enum {
00049         BTXML_PARSE_RECOVER   = 1<<0, /* recover on errors */
00050         BTXML_PARSE_NOENT     = 1<<1, /* substitute entities */
00051         BTXML_PARSE_DTDLOAD   = 1<<2, /* load the external subset */
00052         BTXML_PARSE_DTDATTR   = 1<<3, /* default DTD attributes */
00053         BTXML_PARSE_DTDVALID  = 1<<4, /* validate with the DTD */
00054         BTXML_PARSE_NOERROR   = 1<<5, /* suppress error reports */
00055         BTXML_PARSE_NOWARNING = 1<<6, /* suppress warning reports */
00056         BTXML_PARSE_PEDANTIC  = 1<<7, /* pedantic error reporting */
00057         BTXML_PARSE_NOBLANKS  = 1<<8, /* remove blank nodes */
00058         BTXML_PARSE_SAX1      = 1<<9, /* use the SAX1 interface internally */
00059         BTXML_PARSE_XINCLUDE  = 1<<10,/* Implement XInclude substitition  */
00060         BTXML_PARSE_NONET     = 1<<11,/* Forbid network access */
00061         BTXML_PARSE_NODICT    = 1<<12,/* Do not reuse the context dictionnary */
00062         BTXML_PARSE_NSCLEAN   = 1<<13,/* remove redundant namespaces declarations */
00063         BTXML_PARSE_NOCDATA   = 1<<14,/* merge CDATA as text nodes */
00064         BTXML_PARSE_NOXINCNODE= 1<<15,/* do not generate XINCLUDE START/END nodes */
00065         BTXML_PARSE_COMPACT   = 1<<16 /* compact small text nodes */
00066     } BTXMLParserOption;
00067     
00068     class BTXMLDoc
00069     {
00070         public:
00071             BTXMLDoc();
00072             BTXMLDoc( int t, BTXMLNode *c, const unsigned char *e );
00073             ~BTXMLDoc();
00074        
00075             int  type;        /* XML_DOCUMENT_NODE, must be second ! */
00076             BTXMLNode *children;  /* the document tree */
00077             const unsigned char *encoding;   /* external initial encoding, if any */
00078     };
00079     
00080     class BTXMLNs
00081     {
00082         public:
00083             BTXMLNs();
00084             BTXMLNs(const unsigned char *ref);
00085             ~BTXMLNs();
00086             
00087             const unsigned char *href;        /* URL for the namespace */
00088     };
00089     
00090     
00091     class BTXMLAttr
00092     {
00093         public:
00094             BTXMLAttr();
00095             BTXMLAttr( BTXMLNode *p );
00096             ~BTXMLAttr();
00097             
00098             BTXMLNode *parent;    /* child->parent link */
00099 };
00100 
00101     
00102     class BTXMLNode
00103     {
00104         public:
00105             BTXMLNode();
00106             BTXMLNode(int t, const unsigned char *na, BTXMLNode *c, BTXMLNode *n, BTXMLNs *_ns, unsigned char *co );
00107             ~BTXMLNode();
00108             
00109             int  type;      /* type number, must be second ! */
00110             const unsigned char *name;      /* the name of the node, or the entity */
00111             BTXMLNode *children;  /* parent->childs link */
00112             BTXMLNode *next;      /* next sibling link  */
00113         
00114             /* End of common part */
00115             BTXMLNs         *ns;        /* pointer to the associated namespace */
00116             unsigned char   *content;   /* the content */
00117     };
00118     
00119     class BTXMLHashTable
00120     {
00121         public:
00122             BTXMLHashTable(){};
00123             ~BTXMLHashTable(){};
00124        
00125     };
00126     
00127     class BTXMLDict
00128     {
00129         public:
00130             BTXMLDict(){};
00131             ~BTXMLDict(){};
00132        
00133     };
00134     
00151     typedef int (* BTXMLCharEncodingInputFunc)(unsigned char *out, int *outlen,
00152                                             const unsigned char *in, int *inlen);
00153 
00172     typedef int (* BTXMLCharEncodingOutputFunc)(unsigned char *out, int *outlen,
00173                                             const unsigned char *in, int *inlen);
00174 
00175     class BTXMLCharEncodingHandler
00176     {
00177         public:
00178             BTXMLCharEncodingHandler();
00179             ~BTXMLCharEncodingHandler();
00180 
00181     };
00182 
00183 
00194     typedef int (* BTXMLOutputWriteCallback) (void * context, const char * buffer, int len);
00195 
00196     
00197     class BTXMLBuffer 
00198     {
00199         public:
00200             BTXMLBuffer();
00201             BTXMLBuffer( unsigned char *c );
00202             ~BTXMLBuffer();
00203         
00204             unsigned char *content;     /* The buffer content UTF8 */
00205     };
00206 
00207     class BTXMLOutputBuffer
00208     {
00209         public:
00210             BTXMLOutputBuffer();
00211             BTXMLOutputBuffer( void *c, BTXMLOutputWriteCallback wc );
00212             ~BTXMLOutputBuffer();
00213             
00214             void*                   context;
00215             BTXMLOutputWriteCallback  writecallback;
00216     };
00217     
00218     
00219     class BTXMLParserInput
00220     {
00221         public:
00222             BTXMLParserInput();
00223             BTXMLParserInput( int l, int c);
00224             ~BTXMLParserInput();
00225             
00226             int line;                         /* Current line */
00227             int col;                          /* Current column */
00228     };
00229     
00230     
00240     typedef void (*BTXMLGenericErrorFunc) (void *ctx, const char *msg, ...);
00241 
00242     class BTXMLParserCtxt
00243     {
00244         public :
00245         
00246             BTXMLParserCtxt();
00247             BTXMLParserCtxt(void *_p, int r, BTXMLNode *n, BTXMLDoc *d, BTXMLParserInput *pi );
00248             ~BTXMLParserCtxt();
00249             
00250             void        *_private;      /* For user data, libxml won't touch it */
00251             int         replaceEntities;        /* shall we replace entities ? */
00252             BTXMLNode   *node;          /* Current parsed Node */
00253             BTXMLDoc    *myDoc;        /* the document being built */
00254             BTXMLParserInput  *input;         /* Current input stream */
00255     };
00256     
00265     typedef void (*BTErrorSAXFunc) (void *ctx, const char *msg, ...);
00266 
00277     typedef void (*BTFatalErrorSAXFunc) (void *ctx, const char *msg, ...);
00278     
00287     typedef void (*BTCharactersSAXFunc) (void *ctx, const unsigned char *ch, int len);
00288 
00297     typedef void (*BTProcessingInstructionSAXFunc) (void *ctx, const unsigned char *target, const unsigned char *data);
00298     
00299     
00308     typedef void (*BTCdataBlockSAXFunc) ( void *ctx, const unsigned char *value, int len);
00309     
00317     typedef void (*BTCommentSAXFunc) (void *ctx, const unsigned char *value);
00318     
00327     typedef void (*BTWarningSAXFunc) (void *ctx,  const char *msg, ...);
00328     
00348     typedef void (*BTStartElementNsSAX2Func) (void *ctx,
00349                                             const unsigned char *localname,
00350                                             const unsigned char *prefix,
00351                                             const unsigned char *URI,
00352                                             int nb_namespaces,
00353                                             const unsigned char **namespaces,
00354                                             int nb_attributes,
00355                                             int nb_defaulted,
00356                                             const unsigned char **attributes);
00357 
00369     typedef void (*BTEndElementNsSAX2Func)   (void *ctx,
00370                                               const unsigned char *localname,
00371                                               const unsigned char *prefix,
00372                                               const unsigned char *URI);
00373 
00380     typedef void (*BTStartDocumentSAXFunc) (void *ctx);
00381 
00382     class BTXMLEntity;
00392     typedef BTXMLEntity* (*BTGetEntitySAXFunc) (void *ctx, const unsigned char *name);
00393 
00403     typedef void (*BTInternalSubsetSAXFunc) (void *ctx,
00404                                     const unsigned char *name,
00405                                     const unsigned char *ExternalID,
00406                                     const unsigned char *SystemID);
00407 
00417     typedef void (*BTExternalSubsetSAXFunc) (void *ctx,
00418                                     const unsigned char *name,
00419                                     const unsigned char *ExternalID,
00420                                     const unsigned char *SystemID);
00421 
00431     typedef void (*BTIgnorableWhitespaceSAXFunc) (void *ctx,
00432                                     const unsigned char *ch,
00433                                     int len);
00434 
00446     typedef void (*BTEntityDeclSAXFunc) (void *ctx,
00447                                     const unsigned char *name,
00448                                     int type,
00449                                     const unsigned char *publicId,
00450                                     const unsigned char *systemId,
00451                                     unsigned char *content);
00452 
00453 
00454     class BTXMLSAXHandler
00455     {
00456         public:
00457             BTXMLSAXHandler();
00458             ~BTXMLSAXHandler();
00459             
00460             BTErrorSAXFunc error;
00461             BTFatalErrorSAXFunc fatalError;
00462             BTCharactersSAXFunc characters;
00463             BTProcessingInstructionSAXFunc processingInstruction;
00464             BTCdataBlockSAXFunc cdataBlock;
00465             BTCommentSAXFunc comment;
00466             BTWarningSAXFunc warning;
00467             BTStartElementNsSAX2Func startElementNs;
00468             BTEndElementNsSAX2Func endElementNs;
00469             BTGetEntitySAXFunc getEntity;
00470             BTStartDocumentSAXFunc startDocument;
00471             BTInternalSubsetSAXFunc internalSubset;
00472             BTExternalSubsetSAXFunc externalSubset;
00473             BTIgnorableWhitespaceSAXFunc ignorableWhitespace;
00474             BTEntityDeclSAXFunc entityDecl;
00475             unsigned int initialized;
00476     };
00477     
00488     typedef int (*BTXMLInputMatchCallback) (char const *filename);
00489     
00499     typedef void * (*BTXMLInputOpenCallback) (char const *filename);
00500     
00511     typedef int (*BTXMLInputReadCallback) (void * context, char * buffer, int len);
00512     
00521     typedef int (*BTXMLInputCloseCallback) (void * context);
00522     
00523     
00534     typedef int (*BTXMLOutputMatchCallback) (char const *filename);
00543     typedef void * (*BTXMLOutputOpenCallback) (char const *filename);
00554     typedef int (*BTXMLOutputWriteCallback) (void * context, const char * buffer, int len);
00563     typedef int (*BTXMLOutputCloseCallback) (void * context);
00564     
00565     
00566     class BTXMLEntity
00567     {
00568         public:
00569             BTXMLEntity();
00570             BTXMLEntity( int t, const unsigned char *n, unsigned char *o, unsigned char *ct, int l, int et );
00571             ~BTXMLEntity();
00572             
00573             int                 type;       /* XML_ENTITY_DECL, must be second ! */
00574             const unsigned char *name;       /* Entity name */
00575             unsigned char       *orig;       /* content without ref substitution */
00576             unsigned char       *content;       /* content or ndata if unparsed */
00577             int                 length;       /* the content length */
00578             int                 etype;       /* The entity type */
00579     };
00580     
00581 }
00582 
00583 #endif // BTXML_H_
00584 

Generated on Wed Nov 21 20:04:16 2007 for Origyn Web Browser by Doxygen 1.5.3

pleyo.com
pleyo.com