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

1.1       parser      1: /** @file
1.5       parser      2:        Parser: @b xdoc parser class decl.
1.1       parser      3: 
1.58      moko        4:        Copyright (c) 2001-2017 Art. Lebedev Studio (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.61    ! moko       11: #define IDENT_PA_VXDOC_H "$Id: pa_vxdoc.h,v 1.60 2017/11/15 22:48:58 moko Exp $"
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.60      moko       27: struct XDocOutputOptions : public PA_Allocated {
1.46      misha      28:        const String* method;       /* the output method */
                     29:        const String* encoding;     /* encoding string */
                     30:        const String* mediaType;    /* media-type string */
                     31:        int indent;                 /* should output being indented */
                     32:        const String* version;      /* version string */
                     33:        int standalone;             /* standalone = "yes" | "no" */
                     34:        int omitXmlDeclaration;     /* omit-xml-declaration = "yes" | "no" */
1.48      misha      35:        const String* filename;     /* Parser3 option: filename */
1.46      misha      36: 
                     37:        XDocOutputOptions() {
                     38:                memset(this, 0, sizeof(*this));
                     39:                indent=standalone=omitXmlDeclaration=-1;
                     40:        };
                     41: 
1.52      moko       42:        void append(Request& r, HashStringValue* options, bool with_filename=false);
1.46      misha      43: };
                     44: 
1.25      paf        45: /// value of type 'xdoc'. implemented with libxml & co
1.32      paf        46: class VXdoc: public VXnode {
1.1       parser     47: public: // Value
1.4       parser     48: 
1.32      paf        49:        override const char* type() const { return VXDOC_TYPE; }
1.45      misha      50:        override Value* as(const char* atype);
1.24      paf        51: 
1.32      paf        52:        override VStateless_class* get_class() { return xdoc_class; }
1.6       parser     53: 
1.4       parser     54:        /// VXdoc: true
1.32      paf        55:        override bool as_bool() const { return true; }
1.4       parser     56: 
1.43      misha      57:        /// VXdoc: true  
1.50      moko       58:        override Value& as_expr_result();
1.43      misha      59: 
1.46      misha      60:        /// VFile: json-string
1.51      moko       61:        override const String* get_json_string(Json_options& options);
1.46      misha      62: 
1.53      misha      63:        /// VXdoc: $method, fields
1.45      misha      64:        override Value* get_element(const String& aname);
1.6       parser     65: 
1.25      paf        66: public: // VXNode
1.1       parser     67: 
1.55      moko       68:        override xmlNode& get_xmlnode() {
1.41      paf        69:                return *reinterpret_cast<xmlNode*>(&get_xmldoc());
1.1       parser     70:        }
                     71: 
1.41      paf        72:        override VXdoc& get_vxdoc() {
1.39      paf        73:                return *this;
                     74:        }
                     75: 
1.1       parser     76: public: // usage
                     77: 
1.61    ! moko       78:        VXdoc() : VXnode(*this), fcharsets(0), fdocument(0) {}
1.32      paf        79: 
1.41      paf        80:        VXdoc(Request_charsets& acharsets, xmlDoc& adocument) : VXnode(*this) {
                     81:                set_xmldoc(acharsets, adocument);
1.1       parser     82:        }
                     83: 
1.32      paf        84: public: // VXdoc
                     85: 
1.41      paf        86:        void set_xmldoc(Request_charsets& acharsets, xmlDoc& adocument) { 
                     87:                fcharsets=&acharsets;
                     88:                fdocument=&adocument;
                     89:                fdocument->_private=this;
1.8       parser     90:        }
1.56      moko       91: 
1.55      moko       92:        xmlDoc& get_xmldoc() {
1.37      paf        93:                if(!fdocument)
1.59      moko       94:                        throw Exception(PARSER_RUNTIME, 0, "using uninitialized xdoc object");
1.55      moko       95:                return *fdocument;
1.41      paf        96:        }
                     97: 
1.55      moko       98:        Request_charsets& charsets() {
1.41      paf        99:                if(!fcharsets)
1.59      moko      100:                        throw Exception(PARSER_RUNTIME, 0, "using uninitialized xdoc object");
1.55      moko      101:                return *fcharsets;
1.1       parser    102:        }
1.13      paf       103: 
1.41      paf       104:        VXnode& wrap(xmlNode& anode);
                    105: 
1.13      paf       106: public:
1.39      paf       107: 
                    108:        VHash search_namespaces;
1.32      paf       109: 
1.52      moko      110:        XDocOutputOptions output_options;
                    111: 
1.32      paf       112: private:
                    113: 
1.41      paf       114:        Request_charsets* fcharsets;
                    115:        xmlDoc* fdocument;
1.1       parser    116: };
                    117: 
                    118: #endif

E-mail: