Annotation of parser3/src/types/pa_vresponse.h, revision 1.12
1.3 paf 1: /** @file
2: Parser: response class.
3:
1.1 paf 4: Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)
1.3 paf 5:
1.1 paf 6: Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)
7:
1.12 ! parser 8: $Id: pa_vresponse.h,v 1.11 2001/09/20 14:25:06 parser Exp $
1.1 paf 9: */
10:
11: #ifndef PA_VRESPONSE_H
12: #define PA_VRESPONSE_H
13:
1.3 paf 14: #include "pa_vstateless_object.h"
1.1 paf 15: #include "pa_string.h"
1.9 paf 16:
1.11 parser 17: // externals
18:
1.9 paf 19: extern Methoded *response_class;
1.1 paf 20:
1.11 parser 21: // forwards
22:
1.1 paf 23: class Response;
24:
1.5 paf 25: /// value of type 'response'
1.3 paf 26: class VResponse : public VStateless_object {
1.1 paf 27: public: // Value
28:
29: const char *type() const { return "response"; }
1.2 paf 30:
1.5 paf 31: /// Response: ffields
1.2 paf 32: Hash *get_hash() { return &ffields; }
1.1 paf 33:
1.8 paf 34: /// Response: method,fields
1.1 paf 35: Value *get_element(const String& name) {
1.8 paf 36: // $method
1.3 paf 37: if(Value *result=VStateless_object::get_element(name))
1.1 paf 38: return result;
39:
40: // $field
41: return static_cast<Value *>(ffields.get(name));
42: }
43:
1.5 paf 44: /// Response: (attribute)=value
1.1 paf 45: void put_element(const String& name, Value *value) {
1.11 parser 46: // guard charset change
47: if(name == *content_type_name)
48: if(Hash *hash=value->get_hash())
49: if(Value *vcharset=(Value *)hash->get(*charset_name))
50: pool().set_charset(vcharset->as_string());
51:
1.1 paf 52: ffields.put(name, value);
53: }
1.4 paf 54:
55: protected: // VAliased
56:
1.6 paf 57: /// disable .CLASS element. @see VAliased::get_element
1.7 paf 58: bool hide_class() { return true; }
1.1 paf 59:
60: public: // usage
61:
1.3 paf 62: VResponse(Pool& apool) : VStateless_object(apool, *response_class),
1.1 paf 63: ffields(apool) {
64: }
1.11 parser 65: public:
1.12 ! parser 66:
1.1 paf 67: Hash& fields() { return ffields; }
68:
69: private:
70:
71: Hash ffields;
72:
73: };
74:
75: #endif
E-mail: