#include <form.hpp>
Form: ordered parts ( application/x-www-form-urlencoded or multipart/form-data bodies). A name can be repeated (arrays).
form.
add(
"name",
"Rex").
add(
"tags",
"dog").
add(
"tags",
"brown");
std::optional<std::string_view> name = form.
field(
"name");
std::vector<std::string_view> tags = form.
fields(
"tags");
Fields are converted on server side with formField<T>() and requiredFormField<T>() .
- Author
- Vincent Lachenal
- Since
- 0.2
◆ Form()
| anch::rest::Form::Form |
( |
| ) |
|
◆ add() [1/2]
Add part
- Parameters
-
- Returns
this
◆ add() [2/2]
| Form & anch::rest::Form::add |
( |
std::string_view | name, |
|
|
std::string | value ) |
Add field
- Parameters
-
| name | the field name |
| value | the field value |
- Returns
this
◆ addFile()
| Form & anch::rest::Form::addFile |
( |
std::string_view | name, |
|
|
std::string_view | filename, |
|
|
anch::codec::MediaType | mediaType, |
|
|
std::string | content ) |
Add file
- Parameters
-
| name | the part name |
| filename | the file name |
| mediaType | the content media type |
| content | the content |
- Returns
this
◆ begin()
| std::vector< anch::rest::Part >::const_iterator anch::rest::Form::begin |
( |
| ) |
const |
|
noexcept |
Get parts begin iterator
- Returns
- the begin iterator
◆ empty()
| bool anch::rest::Form::empty |
( |
| ) |
const |
|
noexcept |
Check if form is empty
- Returns
true when form has no part
◆ end()
Get parts end iterator
- Returns
- the end iterator
◆ field()
| std::optional< std::string_view > anch::rest::Form::field |
( |
std::string_view | name | ) |
const |
Get first part content
- Parameters
-
- Returns
- the content, empty when there is no part with this name
◆ fields()
| std::vector< std::string_view > anch::rest::Form::fields |
( |
std::string_view | name | ) |
const |
Get every part content with name
- Parameters
-
- Returns
- the contents, in order
◆ getParts()
Get parts
- Returns
- the parts, in order
◆ has()
| bool anch::rest::Form::has |
( |
std::string_view | name | ) |
const |
|
noexcept |
Check if form has a part
- Parameters
-
- Returns
true when form has a part with this name
◆ part()
Get first part
- Parameters
-
- Returns
- the part,
nullptr when there is no part with this name
◆ parts()
| std::vector< const anch::rest::Part * > anch::rest::Form::parts |
( |
std::string_view | name | ) |
const |
Get every part with name
- Parameters
-
- Returns
- the parts, in order
◆ size()
| std::size_t anch::rest::Form::size |
( |
| ) |
const |
|
noexcept |
Get number of parts
- Returns
- the number of parts
The documentation for this class was generated from the following file: