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

1.4       paf         1: /** @file
                      2:        Parser: file object decl.
                      3: 
1.1       paf         4:        Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)
1.4       paf         5: 
1.1       paf         6:        Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)
                      7: 
1.9     ! paf         8:        $Id: pa_vfile.h,v 1.8 2001/03/26 09:09:48 paf Exp $
1.1       paf         9: */
                     10: 
                     11: #ifndef PA_VFILE_H
                     12: #define PA_VFILE_H
                     13: 
                     14: #include "pa_common.h"
                     15: #include "pa_globals.h"
1.3       paf        16: #include "pa_vstateless_object.h"
1.1       paf        17: #include "_file.h"
                     18: 
1.4       paf        19: /** holds received file.
1.1       paf        20: 
1.4       paf        21:        @see VForm
                     22: */
1.3       paf        23: class VFile : public VStateless_object {
1.1       paf        24: public: // Value
                     25:        
1.2       paf        26:        /// all: for error reporting after fail(), etc
1.1       paf        27:        const char *type() const { return "file"; }
                     28: 
1.2       paf        29:        /// VFile: this
1.9     ! paf        30:        Value *get_expr_result(bool return_string_as_is=false) { return this; }
1.2       paf        31:        /// VFile: true
                     32:        bool get_bool() { return true; }
                     33: 
                     34:        /// VFile: CLASS,BASE,method,field
1.1       paf        35:        Value *VFile::get_element(const String& aname) {
                     36:                // $CLASS,$BASE,$method
1.3       paf        37:                if(Value *result=VStateless_object::get_element(aname))
1.1       paf        38:                        return result;
                     39: 
                     40:                // $element
                     41:                return static_cast<Value *>(fields.get(aname));
                     42:        }
1.7       paf        43: 
                     44: protected: // VAliased
                     45: 
1.8       paf        46:        /// disable .CLASS element. @see VAliased::get_class_alias
1.7       paf        47:        VStateless_class *get_class_alias() { return 0; }
1.1       paf        48: 
                     49: public: // usage
                     50: 
                     51:        VFile(Pool& apool, 
                     52:                const char *avalue_ptr, size_t avalue_size,
1.2       paf        53:                const char *afile_name);
1.1       paf        54: 
1.6       paf        55:        void save(const String& file_spec) {
1.5       paf        56:                file_write(pool(), file_spec, fvalue_ptr, fvalue_size, false);
1.1       paf        57:        }
                     58: 
                     59: private:
                     60: 
                     61:        const char *fvalue_ptr;
                     62:        size_t fvalue_size;
                     63:        Hash fields;
                     64: 
                     65: };
                     66: 
                     67: #endif

E-mail: