Annotation of parser3/src/types/pa_vxdoc.h, revision 1.46
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.46 ! misha 11: static const char * const IDENT_VXDOC_H="$Date: 2009-08-08 13:30:22 $";
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" */
! 35:
! 36: XDocOutputOptions() {
! 37: memset(this, 0, sizeof(*this));
! 38: indent=standalone=omitXmlDeclaration=-1;
! 39: };
! 40:
! 41: XDocOutputOptions(Request& r, HashStringValue* options);
! 42: };
! 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
58: override Value& as_expr_result(bool /*return_string_as_is=false*/);
59:
1.46 ! misha 60: /// VFile: json-string
! 61: override const String* get_json_string(Json_options* options=0);
! 62:
1.39 paf 63: /// VXdoc: $CLASS,$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.41 paf 68: override xmlNode& get_xmlnode() {
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.41 paf 78: VXdoc() :
79: VXnode(*this),
80: fcharsets(0),
81: fdocument(0) {}
1.32 paf 82:
1.41 paf 83: VXdoc(Request_charsets& acharsets, xmlDoc& adocument) : VXnode(*this) {
84: set_xmldoc(acharsets, adocument);
1.1 parser 85: }
86:
1.32 paf 87: public: // VXdoc
88:
1.41 paf 89: void set_xmldoc(Request_charsets& acharsets, xmlDoc& adocument) {
90: fcharsets=&acharsets;
91: fdocument=&adocument;
92: fdocument->_private=this;
1.8 parser 93: }
1.41 paf 94: xmlDoc& get_xmldoc() {
1.37 paf 95: if(!fdocument)
1.44 misha 96: throw Exception(PARSER_RUNTIME,
1.37 paf 97: 0,
98: "using unitialized xdoc object");
1.41 paf 99: return *fdocument;
100: }
101:
102: Request_charsets& charsets() {
103: if(!fcharsets)
1.44 misha 104: throw Exception(PARSER_RUNTIME,
1.41 paf 105: 0,
106: "using unitialized xdoc object");
107: return *fcharsets;
1.1 parser 108: }
1.13 paf 109:
1.41 paf 110: VXnode& wrap(xmlNode& anode);
111:
1.13 paf 112: public:
1.39 paf 113:
114: VHash search_namespaces;
1.32 paf 115:
1.46 ! misha 116: XDocOutputOptions output_options;
1.32 paf 117:
118: private:
119:
1.41 paf 120: Request_charsets* fcharsets;
121: xmlDoc* fdocument;
1.1 parser 122: };
123:
124: #endif
E-mail: