00001 #ifndef DV_FORMDATA_H 00002 #define DV_FORMDATA_H 00003 00004 // $Id: formdata.h,v 1.10 2004/04/27 12:58:08 dvermeir Exp $ 00005 00006 #include <iostream> 00007 #include <dvutil/props.h> 00008 00009 /** @file 00010 * This file defines functions to retrieve name-value form data pairs 00011 * from a C string (which is probably obtained using Dv::Cgi::cgidata): 00012 * <ul> 00013 * <li> Dv::Cgi::urlencoded_formdata(const char* data,Dv::Util::Props&) 00014 * <li> Dv::Cgi::multipart_formdata(const char* data,Dv::Util::Props&) 00015 * <li> Dv::Cgi::formdata(const char* data,Dv::Util::Props&) 00016 * </ul> 00017 */ 00018 namespace Dv { namespace Cgi { 00019 00020 /** 00021 * Convert url encoded form data to <key,value> pairs in Dv::Util::Props. 00022 * 00023 * @param data raw data, typically the result of calling Cgi::cgidata(). 00024 * @param props where key=value pairs will be stored. 00025 * @return true unless something went wrong. 00026 * @warning several values for the same keys will be appended to the 00027 * value associated with the key, separated by comma's. 00028 * @see Dv::Util::Props 00029 */ 00030 bool urlencoded_formdata(const std::string& data, Dv::Util::Props& props) throw (); 00031 /** 00032 * Convert multipart encoded form data to <key,value> pairs in Dv::Util::Props. 00033 * 00034 * @param data raw data, typically the result of calling Cgi::cgidata(). 00035 * @param props where key=value pairs will be stored. For a ``file'' 00036 * field with name ``myfile'' in a form, \a props[myfile] will 00037 * contain the contents of the file while \a props[myfile-name] will 00038 * contain the filename, if any was transmitted. 00039 * @return true unless something went wrong. 00040 * @warning several values for the same keys will be appended to the 00041 * value associated with the key, separated by comma's. 00042 * @see Dv::Util::Props 00043 */ 00044 bool multipart_formdata(const std::string& data, Dv::Util::Props& props) throw (); 00045 /** 00046 * Convert formdata using either urlencoded_formdata or 00047 * multipart_formdata. 00048 * @param data raw data, typically the result of calling Cgi::cgidata(). 00049 * @param props where key=value pairs will be stored. 00050 * @return true unless something went wrong. 00051 * @warning several values for the same keys will be appended to the 00052 * value associated with the key, separated by comma's. 00053 * @see Dv::Util::Props 00054 */ 00055 bool formdata(const std::string& data, Dv::Util::Props& props) throw (); 00056 00057 }} 00058 #endif
dvcgi-0.5.14 | [22 January, 2006] |