Annotation of parser3/src/types/pa_vxdoc.h, revision 1.51
1.1 parser 1: /** @file
1.5 parser 2: Parser: @b xdoc parser class decl.
1.1 parser 3:
1.49 moko 4: Copyright (c) 2001-2012 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.51 ! moko 11: #define IDENT_PA_VXDOC_H "$Id: pa_vxdoc.h,v 1.50 2012-05-23 16:26:41 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.48 misha 42: XDocOutputOptions(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.39 paf 64: /// VXdoc: $CLASS,$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.41 paf 69: override xmlNode& get_xmlnode() {
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.41 paf 79: VXdoc() :
80: VXnode(*this),
81: fcharsets(0),
82: fdocument(0) {}
1.32 paf 83:
1.41 paf 84: VXdoc(Request_charsets& acharsets, xmlDoc& adocument) : VXnode(*this) {
85: set_xmldoc(acharsets, adocument);
1.1 parser 86: }
87:
1.32 paf 88: public: // VXdoc
89:
1.41 paf 90: void set_xmldoc(Request_charsets& acharsets, xmlDoc& adocument) {
91: fcharsets=&acharsets;
92: fdocument=&adocument;
93: fdocument->_private=this;
1.8 parser 94: }
1.41 paf 95: xmlDoc& get_xmldoc() {
1.37 paf 96: if(!fdocument)
1.44 misha 97: throw Exception(PARSER_RUNTIME,
1.37 paf 98: 0,
99: "using unitialized xdoc object");
1.41 paf 100: return *fdocument;
101: }
102:
103: Request_charsets& charsets() {
104: if(!fcharsets)
1.44 misha 105: throw Exception(PARSER_RUNTIME,
1.41 paf 106: 0,
107: "using unitialized xdoc object");
108: return *fcharsets;
1.1 parser 109: }
1.13 paf 110:
1.41 paf 111: VXnode& wrap(xmlNode& anode);
112:
1.13 paf 113: public:
1.39 paf 114:
115: VHash search_namespaces;
1.32 paf 116:
117: private:
118:
1.41 paf 119: Request_charsets* fcharsets;
120: xmlDoc* fdocument;
1.1 parser 121: };
122:
123: #endif
E-mail: