Annotation of parser3/src/types/pa_vxdoc.h, revision 1.25

1.1       parser      1: /** @file
1.5       parser      2:        Parser: @b xdoc parser class decl.
1.1       parser      3: 
1.18      paf         4:        Copyright (c) 2001, 2002 ArtLebedev Group (http://www.artlebedev.com)
1.19      paf         5:        Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)
1.1       parser      6: */
                      7: 
                      8: #ifndef PA_VXDOC_H
                      9: #define PA_VXDOC_H
                     10: 
1.25    ! paf        11: static const char* IDENT_VXDOC_H="$Date: 2002/08/09 14:18:40 $";
1.22      paf        12: 
1.1       parser     13: #include "classes.h"
                     14: #include "pa_common.h"
                     15: #include "pa_vstateless_object.h"
                     16: #include "pa_vxnode.h"
                     17: 
1.17      paf        18: // defines
                     19: 
                     20: #define VXDOC_TYPE "xdoc"
                     21: 
                     22: // externals
                     23: 
1.1       parser     24: extern Methoded *Xdoc_class;
                     25: 
                     26: void VXdoc_cleanup(void *);
                     27: 
1.25    ! paf        28: /// value of type 'xdoc'. implemented with libxml & co
1.1       parser     29: class VXdoc : public VXnode {
1.13      paf        30:        friend void VXdoc_destructor(void *);
1.1       parser     31: public: // Value
1.4       parser     32: 
1.17      paf        33:        const char *type() const { return VXDOC_TYPE; }
1.24      paf        34:        Value *as(const char *atype) {
                     35:                if(Value *result=Value::as(atype))
                     36:                        return result;
                     37:                else
                     38:                        return VXnode::as(atype);
                     39:        }
                     40: 
1.21      paf        41:        VStateless_class *get_class() { return Xdoc_class; }
1.6       parser     42: 
1.4       parser     43:        /// VXdoc: true
                     44:        bool as_bool() const { return true; }
                     45: 
                     46:        /// VXdoc: true
                     47:        Value *as_expr_result(bool return_string_as_is=false) { return NEW VBool(pool(), as_bool()); }
1.1       parser     48: 
1.6       parser     49:        /// VXnode: $CLASS,$method, fields
                     50:        Value *get_element(const String& name);
                     51: 
1.25    ! paf        52: public: // VXNode
1.1       parser     53: 
1.15      paf        54:        virtual GdomeNode *get_node(const String *source) { 
                     55:                return (GdomeNode *)get_document(source);
1.1       parser     56:        }
                     57: 
                     58: public: // usage
                     59: 
1.15      paf        60:        VXdoc(Pool& apool, GdomeDocument *adocument) : 
1.21      paf        61:                VXnode(apool, 0), 
1.15      paf        62:                fdocument(adocument/*not adding ref, owning a doc*/) {
1.14      paf        63: 
1.13      paf        64:                register_cleanup(VXdoc_destructor, this);
1.16      paf        65:                memset(&output_options, 0, sizeof(output_options));
1.1       parser     66:        }
1.14      paf        67: protected:
1.13      paf        68:        ~VXdoc() {
1.14      paf        69:                GdomeException exc;
                     70:                if(fdocument)                   
                     71:                        gdome_doc_unref(fdocument, &exc);
1.1       parser     72:        }
                     73: public:
                     74: 
1.14      paf        75:        void set_document(GdomeDocument *adocument) { 
                     76:                GdomeException exc;
                     77:                if(fdocument)                   
                     78:                        gdome_doc_unref(fdocument, &exc);
1.8       parser     79: 
1.14      paf        80:                gdome_doc_ref(fdocument=adocument, &exc);
1.8       parser     81:        }
1.15      paf        82:        GdomeDocument *get_document(const String *source) { 
1.1       parser     83:                if(!fdocument)
1.20      paf        84:                        throw Exception(0,
1.1       parser     85:                                source,
                     86:                                "can not be applied to uninitialized instance");
1.14      paf        87:                return fdocument; 
1.1       parser     88:        }
1.13      paf        89: 
                     90: public:
                     91:        struct Output_options {
1.16      paf        92:                const String *method;            /* the output method */
                     93:                const String *encoding;          /* encoding string */
                     94:                const String *mediaType;         /* media-type string */
                     95:                const String *doctypeSystem;     /* doctype-system string */
                     96:                const String *doctypePublic;     /* doctype-public string */
                     97:                bool indent;                 /* should output being indented */
                     98:                const String *version;           /* version string */
                     99:                bool standalone;             /* standalone = "yes" | "no" */
                    100:                bool omitXmlDeclaration;     /* omit-xml-declaration = "yes" | "no" */
1.13      paf       101:        } output_options;
1.1       parser    102: private:
                    103: 
1.14      paf       104:        GdomeDocument *fdocument;
1.1       parser    105: };
                    106: 
                    107: #endif

E-mail: