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

1.1       parser      1: /** @file
1.5       parser      2:        Parser: @b xdoc parser class decl.
1.1       parser      3: 
1.45    ! misha       4:        Copyright (c) 2001-2009 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.45    ! misha      11: static const char * const IDENT_VXDOC_H="$Date: 2007/04/23 10:30:50 $";
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; }
1.45    ! misha      32:        override Value* as(const char* atype);
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: 
1.43      misha      39:        /// VXdoc: true  
                     40:        override Value& as_expr_result(bool /*return_string_as_is=false*/);
                     41: 
1.39      paf        42:        /// VXdoc: $CLASS,$method, fields
1.45    ! misha      43:        override Value* get_element(const String& aname);
1.6       parser     44: 
1.25      paf        45: public: // VXNode
1.1       parser     46: 
1.41      paf        47:        override xmlNode& get_xmlnode() { 
                     48:                return *reinterpret_cast<xmlNode*>(&get_xmldoc());
1.1       parser     49:        }
                     50: 
1.41      paf        51:        override VXdoc& get_vxdoc() {
1.39      paf        52:                return *this;
                     53:        }
                     54: 
1.1       parser     55: public: // usage
                     56: 
1.41      paf        57:        VXdoc() : 
                     58:                VXnode(*this), 
                     59:                fcharsets(0),
                     60:                fdocument(0) {}
1.32      paf        61: 
1.41      paf        62:        VXdoc(Request_charsets& acharsets, xmlDoc& adocument) : VXnode(*this) {
                     63:                set_xmldoc(acharsets, adocument);
1.1       parser     64:        }
                     65: 
1.32      paf        66: public: // VXdoc
                     67: 
1.41      paf        68:        void set_xmldoc(Request_charsets& acharsets, xmlDoc& adocument) { 
                     69:                fcharsets=&acharsets;
                     70:                fdocument=&adocument;
                     71:                fdocument->_private=this;
1.8       parser     72:        }
1.41      paf        73:        xmlDoc& get_xmldoc() { 
1.37      paf        74:                if(!fdocument)
1.44      misha      75:                        throw Exception(PARSER_RUNTIME,
1.37      paf        76:                                0,
                     77:                                "using unitialized xdoc object");
1.41      paf        78:                return *fdocument; 
                     79:        }
                     80: 
                     81:        Request_charsets& charsets() { 
                     82:                if(!fcharsets)
1.44      misha      83:                        throw Exception(PARSER_RUNTIME,
1.41      paf        84:                                0,
                     85:                                "using unitialized xdoc object");
                     86:                return *fcharsets; 
1.1       parser     87:        }
1.13      paf        88: 
1.41      paf        89:        VXnode& wrap(xmlNode& anode);
                     90: 
1.13      paf        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: 
1.41      paf       112:        Request_charsets* fcharsets;
                    113:        xmlDoc* fdocument;
1.1       parser    114: };
                    115: 
                    116: #endif

E-mail: