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

1.1       parser      1: /** @file
1.5       parser      2:        Parser: @b xdoc parser class decl.
1.1       parser      3: 
1.32      paf         4:        Copyright (c) 2001-2003 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.35    ! paf        11: static const char * const IDENT_VXDOC_H="$Date: 2003/11/20 16:34:30 $";
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.16      paf        56:                memset(&output_options, 0, sizeof(output_options));
1.1       parser     57:        }
1.32      paf        58: 
                     59:        override ~VXdoc() {
1.14      paf        60:                GdomeException exc;
1.32      paf        61:                if(fdocument) {
1.14      paf        62:                        gdome_doc_unref(fdocument, &exc);
1.32      paf        63:                        assign_document(0);
                     64:                }
1.1       parser     65:        }
                     66: 
1.32      paf        67: public: // VXdoc
                     68: 
                     69:        void set_document(Request_charsets* acharsets, GdomeDocument *adocument) { 
                     70:                fcharsets=acharsets;
                     71: 
1.14      paf        72:                GdomeException exc;
1.32      paf        73:                if(fdocument)
1.14      paf        74:                        gdome_doc_unref(fdocument, &exc);
1.8       parser     75: 
1.32      paf        76:                assign_document(adocument);
                     77:                gdome_doc_ref(fdocument, &exc);
1.8       parser     78:        }
1.32      paf        79:        GdomeDocument* get_document() { 
                     80:                assert(fdocument);
1.14      paf        81:                return fdocument; 
1.1       parser     82:        }
1.13      paf        83: 
                     84: public:
1.32      paf        85: 
1.13      paf        86:        struct Output_options {
1.32      paf        87:                const String* method;            /* the output method */
                     88:                const String* encoding;          /* encoding string */
                     89:                const String* mediaType;         /* media-type string */
1.16      paf        90:                bool indent;                 /* should output being indented */
1.32      paf        91:                const String* version;           /* version string */
1.16      paf        92:                bool standalone;             /* standalone = "yes" | "no" */
                     93:                bool omitXmlDeclaration;     /* omit-xml-declaration = "yes" | "no" */
1.13      paf        94:        } output_options;
1.32      paf        95: 
                     96: private:
                     97: 
                     98:        /// hold reference to prevent premature collecting
                     99:        void assign_document(GdomeDocument *adocument) {
                    100:                fdocument=adocument;
                    101: 
                    102:                gcref_doc=fdocument?gdome_xml_doc_get_xmlDoc(fdocument):0;
                    103:        }
                    104: 
1.1       parser    105: private:
                    106: 
1.32      paf       107:        GdomeDocument* fdocument;
                    108:        xmlDoc *gcref_doc;
1.1       parser    109: };
                    110: 
                    111: #endif

E-mail: