Annotation of parser3/src/types/pa_vfile.h, revision 1.1

1.1     ! paf         1: /*
        !             2:        Parser
        !             3:        Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)
        !             4:        Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)
        !             5: 
        !             6:        $Id: pa_vfile.h,v 1.8 2001/03/19 16:06:17 paf Exp $
        !             7: */
        !             8: 
        !             9: #ifndef PA_VFILE_H
        !            10: #define PA_VFILE_H
        !            11: 
        !            12: #include "pa_common.h"
        !            13: #include "pa_globals.h"
        !            14: #include "pa_vstateless_class.h"
        !            15: #include "_file.h"
        !            16: #include "pa_vint.h"
        !            17: 
        !            18: class Request;
        !            19: 
        !            20: class VFile : public VStateless_class {
        !            21: public: // Value
        !            22:        
        !            23:        // all: for error reporting after fail(), etc
        !            24:        const char *type() const { return "file"; }
        !            25: 
        !            26:        // file: CLASS,BASE,method,field
        !            27:        Value *VFile::get_element(const String& aname) {
        !            28:                // $CLASS,$BASE,$method
        !            29:                if(Value *result=VStateless_class::get_element(aname))
        !            30:                        return result;
        !            31: 
        !            32:                // $element
        !            33:                return static_cast<Value *>(fields.get(aname));
        !            34:        }
        !            35: 
        !            36: public: // usage
        !            37: 
        !            38:        VFile(Pool& apool, 
        !            39:                const char *avalue_ptr, size_t avalue_size,
        !            40:                const char *afile_name) : 
        !            41:                VStateless_class(apool, file_base_class),
        !            42: 
        !            43:                fvalue_ptr(avalue_ptr),
        !            44:                fvalue_size(avalue_size),
        !            45:                fields(apool) {
        !            46: 
        !            47:                // $name
        !            48:                fields.put(*name_name, NEW VString(*NEW String(pool(), afile_name, true)));
        !            49:                // $size
        !            50:                fields.put(*size_name, NEW VInt(pool(), fvalue_size));
        !            51:                // $text
        !            52:                String& text=*NEW String(pool());
        !            53:                text.APPEND(fvalue_ptr, fvalue_size, "<input type=file>", 0);
        !            54:                fields.put(*text_name, NEW VString(text));
        !            55: 
        !            56:        }
        !            57: 
        !            58:        void save(const char *file_spec) {
        !            59:                file_write(pool(), file_spec, fvalue_ptr, fvalue_size);
        !            60:        }
        !            61: 
        !            62: private:
        !            63: 
        !            64:        const char *fvalue_ptr;
        !            65:        size_t fvalue_size;
        !            66:        Hash fields;
        !            67: 
        !            68: };
        !            69: 
        !            70: #endif

E-mail: