Annotation of parser3/src/types/pa_vform.h, revision 1.70

1.10      paf         1: /** @file
1.16      paf         2:        Parser: @b form class decls.
1.10      paf         3: 
1.69      moko        4:        Copyright (c) 2001-2024 Art. Lebedev Studio (http://www.artlebedev.com)
1.68      moko        5:        Authors: Konstantin Morshnev <moko@design.ru>, Alexandr Petrosian <paf@design.ru>
1.1       paf         6: */
                      7: 
                      8: #ifndef PA_VFORM_H
                      9: #define PA_VFORM_H
1.36      paf        10: 
1.70    ! moko       11: #define IDENT_PA_VFORM_H "$Id: pa_vform.h,v 1.69 2024/11/04 03:53:25 moko Exp $"
1.46      paf        12: 
                     13: // includes
1.1       paf        14: 
1.19      paf        15: #include "classes.h"
1.8       paf        16: #include "pa_common.h"
1.46      paf        17: #include "pa_value.h"
1.70    ! moko       18: #include "pa_vhash.h"
1.22      parser     19: 
1.46      paf        20: // forwards
                     21: 
                     22: class Request_info;
                     23: class Request_charsets;
1.4       paf        24: 
1.56      misha      25: enum POST_CONTENT_TYPE {
                     26:        UNKNOWN,
                     27:        FORM_URLENCODED,
                     28:        MULTIPART_FORMDATA
                     29: };
                     30: 
1.10      paf        31: /**
1.13      paf        32:        derivates from VStateless_class so that :CLASS element referred to @a this.
1.10      paf        33: 
                     34:        and users could do such tricks:
                     35:        @verbatim
                     36:                ^rem{pass somebody something with elements}
                     37: 
                     38:                ^rem{this time that would be elements of a form}
1.12      paf        39:                ^somebody[$form:CLASS]
1.10      paf        40: 
                     41:                ^rem{this time that would be elements of a table record}
                     42:                $news[^table:sql[select * from news]]
                     43:                ^somebody[^news.record[]]
                     44:        @endverbatim
                     45: */
1.46      paf        46: class VForm: public VStateless_class {
1.1       paf        47: public: // Value
                     48:        
1.46      paf        49:        const char* type() const { return "form"; }
1.24      parser     50:        
1.62      misha      51:        // form: fields,tables,files,imap,method,field
1.57      misha      52:        Value* get_element(const String& aname);
1.63      moko       53:        Charset* get_body_charset();
1.1       paf        54: 
1.66      moko       55:        /// form: (field)=value
                     56:        override const VJunction* put_element(const String& name, Value* value);
                     57: 
1.1       paf        58: public: // usage
                     59: 
1.48      paf        60:        VForm(Request_charsets& acharsets, Request_info& arequest_info);
1.31      paf        61:        
1.6       paf        62: private:
                     63: 
1.48      paf        64:        Request_charsets& fcharsets;
                     65:        Request_info& frequest_info;
1.46      paf        66: 
1.61      misha      67:        bool can_have_body;
                     68:        bool charset_detected;
1.56      misha      69:        POST_CONTENT_TYPE post_content_type;
                     70: 
1.53      misha      71:        char *strpart(const char* str, size_t len);
1.60      moko       72:        char *getAttributeValue(const char* data,const char *attr,size_t len);
1.46      paf        73:        void UnescapeChars(char **sp, const char* cp, size_t len);
                     74:        void ParseGetFormInput(const char* query_string, size_t length);
1.56      misha      75:        void ParseFormInput(const char* data, size_t length, Charset* client_charset=0);
                     76:        void ParseMimeInput(char *content_type, const char* data, size_t length, Charset* client_charset=0);
1.6       paf        77:        void AppendFormEntry(
1.46      paf        78:                const char* cname_cstr, 
1.56      misha      79:                const char* raw_cvalue_ptr, const size_t raw_cvalue_size, Charset* client_charset=0);
1.51      misha      80:        void AppendFormFileEntry(
                     81:                const char* cname_cstr, 
1.46      paf        82:                const char* raw_cvalue_ptr, const size_t raw_cvalue_size,
1.56      misha      83:                const char* file_name_cstr, Charset* client_charset=0);
1.1       paf        84: 
1.51      misha      85:        bool should_refill_fields_tables_and_files();
                     86:        void refill_fields_tables_and_files();
1.48      paf        87: 
1.58      misha      88:        void detect_post_charset();
1.1       paf        89: private:
                     90: 
1.48      paf        91:        Charset* filled_source;
                     92:        Charset* filled_client;
1.56      misha      93:        Charset* fpost_charset; // charset which was specified in content-type in incoming POST
1.70    ! moko       94: 
        !            95:        VHash vfields, vtables, vfiles, vimap, velements;
        !            96:        HashStringValue &fields, &tables, &files, &imap, &elements;
1.30      paf        97: 
                     98: private:
                     99: 
1.56      misha     100:        String::C transcode(const char* client, size_t client_size, Charset* client_charset=0);
1.1       paf       101: 
                    102: };
                    103: 
                    104: #endif

E-mail: