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

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

E-mail: