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

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.24    ! paf        11: static const char* IDENT_VXDOC_H="$Date: 2002/08/01 11:41:25 $";
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.5       parser     28: /// value of type 'xdoc'. implemented with XalanDocument & 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.1       parser     52: protected: // VAliased
                     53: 
                     54:        /// disable .CLASS element. @see VAliased::get_element
                     55:        bool hide_class() { return true; }
                     56: 
                     57: public: // VDNode
                     58: 
1.14      paf        59:        /// @test conv validity
1.15      paf        60:        virtual GdomeNode *get_node(const String *source) { 
                     61:                return (GdomeNode *)get_document(source);
1.1       parser     62:        }
                     63: 
                     64: public: // usage
                     65: 
1.15      paf        66:        VXdoc(Pool& apool, GdomeDocument *adocument) : 
1.21      paf        67:                VXnode(apool, 0), 
1.15      paf        68:                fdocument(adocument/*not adding ref, owning a doc*/) {
1.14      paf        69: //             ftransformer(0) 
                     70: 
1.13      paf        71:                register_cleanup(VXdoc_destructor, this);
1.14      paf        72: //             ftransformer=new XalanTransformer2;
1.16      paf        73:                memset(&output_options, 0, sizeof(output_options));
1.1       parser     74:        }
1.14      paf        75: protected:
1.13      paf        76:        ~VXdoc() {
1.14      paf        77:                GdomeException exc;
                     78:                if(fdocument)                   
                     79:                        gdome_doc_unref(fdocument, &exc);
1.8       parser     80: 
1.14      paf        81: //             delete ftransformer;
1.1       parser     82:        }
                     83: public:
                     84: 
1.14      paf        85:        //XalanTransformer2& transformer() {return *ftransformer; }
                     86:        void set_document(GdomeDocument *adocument) { 
                     87:                GdomeException exc;
                     88:                if(fdocument)                   
                     89:                        gdome_doc_unref(fdocument, &exc);
1.8       parser     90: 
1.14      paf        91:                gdome_doc_ref(fdocument=adocument, &exc);
1.8       parser     92:        }
1.15      paf        93:        GdomeDocument *get_document(const String *source) { 
1.1       parser     94:                if(!fdocument)
1.20      paf        95:                        throw Exception(0,
1.1       parser     96:                                source,
                     97:                                "can not be applied to uninitialized instance");
1.14      paf        98:                return fdocument; 
1.1       parser     99:        }
1.13      paf       100: 
                    101: public:
                    102:        struct Output_options {
1.16      paf       103:                const String *method;            /* the output method */
                    104:                const String *encoding;          /* encoding string */
                    105:                const String *mediaType;         /* media-type string */
                    106:                const String *doctypeSystem;     /* doctype-system string */
                    107:                const String *doctypePublic;     /* doctype-public string */
                    108:                bool indent;                 /* should output being indented */
                    109:                const String *version;           /* version string */
                    110:                bool standalone;             /* standalone = "yes" | "no" */
                    111:                bool omitXmlDeclaration;     /* omit-xml-declaration = "yes" | "no" */
1.13      paf       112:        } output_options;
1.1       parser    113: private:
                    114: 
1.14      paf       115:        GdomeDocument *fdocument;
1.1       parser    116: };
                    117: 
                    118: #endif

E-mail: