1 #ifndef CPR_MULTIPART_H 2 #define CPR_MULTIPART_H 5 #include <initializer_list> 15 template <
typename StringType>
24 template <
typename Iterator,
typename StringType>
25 explicit Buffer(Iterator begin, Iterator end, StringType&& filename)
26 :
data{
reinterpret_cast<data_t
>(&(*begin))},
27 datalen{
static_cast<unsigned long>(std::distance(begin, end))},
29 is_random_access_iterator(begin, end);
30 static_assert(
sizeof(*begin) == 1,
"only byte buffers can be used");
33 template <
typename Iterator>
34 typename std::enable_if<std::is_same<typename std::iterator_traits<Iterator>::iterator_category,
35 std::random_access_iterator_tag>
::value>::type
45 : name{name}, value{value}, content_type{content_type}, is_file{
false},
48 : name{name}, value{std::to_string(value)}, content_type{content_type}, is_file{
false},
51 : name{name}, value{file.
filepath}, content_type{content_type}, is_file{
true},
54 : name{name}, value{buffer.
filename}, content_type{content_type},
data{buffer.
data},
55 datalen{buffer.
datalen}, is_file{
false}, is_buffer{
true} {}
68 Multipart(
const std::initializer_list<Part>& parts);
const unsigned char * data_t
File(StringType &&filepath)
Part(const std::string &name, const std::string &value, const std::string &content_type={})
std::enable_if< std::is_same< typename std::iterator_traits< Iterator >::iterator_category, std::random_access_iterator_tag >::value >::type is_random_access_iterator(Iterator, Iterator)
Part(const std::string &name, const Buffer &buffer, const std::string &content_type={})
Part(const std::string &name, const std::int32_t &value, const std::string &content_type={})
std::vector< Part > parts
Buffer(Iterator begin, Iterator end, StringType &&filename)
Part(const std::string &name, const File &file, const std::string &content_type={})
UNITTEST_START int * value