Template Struct multipart_form

Nested Relationships

Struct Documentation

template<typename Iterator>
struct udho::multipart_form

Form accessor for multipart forms

Public Types

typedef Iterator iterator_type
typedef std::iterator_traits<iterator_type>::value_type value_type
typedef std::basic_string<value_type> string_type
typedef bounded_str<iterator_type> bounded_string_type
typedef std::map<string_type, bounded_string_type> header_map_type
typedef bounded_string_type bounded_string

Public Functions

void parse(const std::string &boundary, iterator_type begin, iterator_type end)
void parse_part(iterator_type begin, iterator_type end)
std::size_t count() const

number of fields in the form

bool has(const std::string name) const

checks whether the form has any field with the given name

const form_part &part(const std::string &name) const

returns the part associated with the given name

template<typename T>
const T field(const std::string &name) const

returns the value of the field lexically casted with the desired type

form.field<int>("age");

Public Members

std::string _boundary
std::map<string_type, form_part> _parts
struct form_part

A part in the multipart form data

Public Functions

form_part(iterator_type begin, iterator_type end)
void set_header(const header_map_type &headers)
const bounded_string_type &header(const std::string &key) const

returns the value associated with the key in the header of the part

header("Content-Disposition").copied<std::string>();

bounded_string_type header(const std::string &key, const std::string &sub) const

returns the value associated with the key and sub key in the header of the part

header("Content-Disposition", "name").copied<std::string>();

bounded_string_type name() const

name of the part

name().copied<std::string>();

bounded_string_type filename() const

filename of the part

name().copied<std::string>();

const bounded_string_type &body() const

body of the part returned as a pair of string iterators

body().copied<std::string>();

template<typename StrT>
StrT copied() const
std::string str() const

returns the body of the part as string

template<typename T>
T value() const

lexically convert the contents of the body to the requested type

Public Members

header_map_type _headers
bounded_string_type _body