Annotation of parser3/src/types/pa_vresponse.h, revision 1.16

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

E-mail: