Annotation of parser3/src/types/pa_vxdoc.h, revision 1.55
1.1 parser 1: /** @file
1.5 parser 2: Parser: @b xdoc parser class decl.
1.1 parser 3:
1.54 moko 4: Copyright (c) 2001-2015 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.55 ! moko 11: #define IDENT_PA_VXDOC_H "$Id: pa_vxdoc.h,v 1.54 2015/10/26 01:22:03 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.46 misha 27: struct XDocOutputOptions {
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:
45:
1.25 paf 46: /// value of type 'xdoc'. implemented with libxml & co
1.32 paf 47: class VXdoc: public VXnode {
1.1 parser 48: public: // Value
1.4 parser 49:
1.32 paf 50: override const char* type() const { return VXDOC_TYPE; }
1.45 misha 51: override Value* as(const char* atype);
1.24 paf 52:
1.32 paf 53: override VStateless_class* get_class() { return xdoc_class; }
1.6 parser 54:
1.4 parser 55: /// VXdoc: true
1.32 paf 56: override bool as_bool() const { return true; }
1.4 parser 57:
1.43 misha 58: /// VXdoc: true
1.50 moko 59: override Value& as_expr_result();
1.43 misha 60:
1.46 misha 61: /// VFile: json-string
1.51 moko 62: override const String* get_json_string(Json_options& options);
1.46 misha 63:
1.53 misha 64: /// VXdoc: $method, fields
1.45 misha 65: override Value* get_element(const String& aname);
1.6 parser 66:
1.25 paf 67: public: // VXNode
1.1 parser 68:
1.55 ! moko 69: override xmlNode& get_xmlnode() {
1.41 paf 70: return *reinterpret_cast<xmlNode*>(&get_xmldoc());
1.1 parser 71: }
72:
1.41 paf 73: override VXdoc& get_vxdoc() {
1.39 paf 74: return *this;
75: }
76:
1.1 parser 77: public: // usage
78:
1.55 ! moko 79: VXdoc() : VXnode(*this), fcharsets(0), fdocument(0) {}
1.32 paf 80:
1.41 paf 81: VXdoc(Request_charsets& acharsets, xmlDoc& adocument) : VXnode(*this) {
82: set_xmldoc(acharsets, adocument);
1.1 parser 83: }
84:
1.32 paf 85: public: // VXdoc
86:
1.41 paf 87: void set_xmldoc(Request_charsets& acharsets, xmlDoc& adocument) {
88: fcharsets=&acharsets;
89: fdocument=&adocument;
90: fdocument->_private=this;
1.8 parser 91: }
1.55 ! moko 92: xmlDoc& get_xmldoc() {
1.37 paf 93: if(!fdocument)
1.55 ! moko 94: throw Exception(PARSER_RUNTIME, 0, "using unitialized xdoc object");
! 95: return *fdocument;
1.41 paf 96: }
97:
1.55 ! moko 98: Request_charsets& charsets() {
1.41 paf 99: if(!fcharsets)
1.55 ! moko 100: throw Exception(PARSER_RUNTIME, 0, "using unitialized xdoc object");
! 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: