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