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

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.14    ! parser      7:        $Id: pa_vresponse.h,v 1.13 2001/09/21 14:46:09 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.2       paf        31:        Hash *get_hash() { 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.13      parser     45: #ifdef XML
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());              
1.13      parser     51: #endif
                     52: 
1.1       paf        53:                ffields.put(name, value);
                     54:        }
1.4       paf        55: 
                     56: protected: // VAliased
                     57: 
1.6       paf        58:        /// disable .CLASS element. @see VAliased::get_element
1.7       paf        59:        bool hide_class() { return true; }
1.1       paf        60: 
                     61: public: // usage
                     62: 
1.3       paf        63:        VResponse(Pool& apool) : VStateless_object(apool, *response_class),
1.1       paf        64:                ffields(apool) {
                     65:        }
1.11      parser     66: public:        
1.12      parser     67: 
1.1       paf        68:        Hash& fields() { return ffields; }
                     69: 
                     70: private:
                     71: 
                     72:        Hash ffields;
                     73: 
                     74: };
                     75: 
                     76: #endif

E-mail: