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

1.1       parser      1: /** @file
1.5       parser      2:        Parser: @b xdoc parser class decl.
1.1       parser      3: 
1.36      paf         4:        Copyright (c) 2001-2004 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.38    ! paf        11: static const char * const IDENT_VXDOC_H="$Date: 2004/02/17 14:22:29 $";
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.32      paf        24: extern Methoded* xdoc_class;
1.1       parser     25: 
1.25      paf        26: /// value of type 'xdoc'. implemented with libxml & co
1.32      paf        27: class VXdoc: public VXnode {
1.1       parser     28: public: // Value
1.4       parser     29: 
1.32      paf        30:        override const char* type() const { return VXDOC_TYPE; }
                     31:        override Value* as(const char* atype, bool looking_up);
1.24      paf        32: 
1.32      paf        33:        override VStateless_class* get_class() { return xdoc_class; }
1.6       parser     34: 
1.4       parser     35:        /// VXdoc: true
1.32      paf        36:        override bool as_bool() const { return true; }
1.4       parser     37: 
                     38:        /// VXdoc: true
1.33      paf        39:        override Value& as_expr_result(bool /*return_string_as_is=false*/) { return *new VBool(as_bool()); }
1.1       parser     40: 
1.6       parser     41:        /// VXnode: $CLASS,$method, fields
1.32      paf        42:        override Value* get_element(const String& aname, Value& aself, bool /*looking_up*/);
1.6       parser     43: 
1.25      paf        44: public: // VXNode
1.1       parser     45: 
1.32      paf        46:        override GdomeNode* get_node() { 
                     47:                return (GdomeNode*)get_document();
1.1       parser     48:        }
                     49: 
                     50: public: // usage
                     51: 
1.32      paf        52:        VXdoc(Request_charsets* acharsets, GdomeDocument *adocument) : 
                     53:                VXnode(acharsets, 0), 
                     54:                fdocument(0) {
                     55:                assign_document(adocument); // not adding ref, owning a doc
1.1       parser     56:        }
1.32      paf        57: 
                     58:        override ~VXdoc() {
1.14      paf        59:                GdomeException exc;
1.32      paf        60:                if(fdocument) {
1.14      paf        61:                        gdome_doc_unref(fdocument, &exc);
1.32      paf        62:                        assign_document(0);
                     63:                }
1.1       parser     64:        }
                     65: 
1.32      paf        66: public: // VXdoc
                     67: 
                     68:        void set_document(Request_charsets* acharsets, GdomeDocument *adocument) { 
                     69:                fcharsets=acharsets;
                     70: 
1.14      paf        71:                GdomeException exc;
1.32      paf        72:                if(fdocument)
1.14      paf        73:                        gdome_doc_unref(fdocument, &exc);
1.8       parser     74: 
1.32      paf        75:                assign_document(adocument);
                     76:                gdome_doc_ref(fdocument, &exc);
1.8       parser     77:        }
1.32      paf        78:        GdomeDocument* get_document() { 
1.37      paf        79:                if(!fdocument)
                     80:                        throw Exception("parser.runtime",
                     81:                                0,
                     82:                                "using unitialized xdoc object");
1.14      paf        83:                return fdocument; 
1.1       parser     84:        }
1.13      paf        85: 
                     86: public:
1.32      paf        87: 
1.13      paf        88:        struct Output_options {
1.32      paf        89:                const String* method;            /* the output method */
                     90:                const String* encoding;          /* encoding string */
                     91:                const String* mediaType;         /* media-type string */
1.38    ! paf        92:                int indent;                 /* should output being indented */
1.32      paf        93:                const String* version;           /* version string */
1.38    ! paf        94:                int standalone;             /* standalone = "yes" | "no" */
        !            95:                int omitXmlDeclaration;     /* omit-xml-declaration = "yes" | "no" */
        !            96: 
        !            97:                Output_options() {
        !            98:                        memset(this, 0, sizeof(*this));
        !            99:                        indent=standalone=omitXmlDeclaration=-1;
        !           100:                };
1.13      paf       101:        } output_options;
1.32      paf       102: 
                    103: private:
                    104: 
                    105:        /// hold reference to prevent premature collecting
                    106:        void assign_document(GdomeDocument *adocument) {
                    107:                fdocument=adocument;
                    108: 
                    109:                gcref_doc=fdocument?gdome_xml_doc_get_xmlDoc(fdocument):0;
                    110:        }
                    111: 
1.1       parser    112: private:
                    113: 
1.32      paf       114:        GdomeDocument* fdocument;
                    115:        xmlDoc *gcref_doc;
1.1       parser    116: };
                    117: 
                    118: #endif

E-mail: