Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
QFormDataBuilder Class Reference

The QFormDataBuilder class is a convenience class to simplify the construction of QHttpMultiPart objects. More...

#include <qformdatabuilder.h>

Collaboration diagram for QFormDataBuilder:

Public Types

enum class  Option {
  Default = 0x00 , OmitRfc8187EncodedFilename = 0x01 , UseRfc7578PercentEncodedFilename = 0x02 , PreferLatin1EncodedFilename = 0x04 ,
  StrictRfc7578 = OmitRfc8187EncodedFilename | UseRfc7578PercentEncodedFilename
}

Public Member Functions

Q_NETWORK_EXPORT QFormDataBuilder ()
 QFormDataBuilder (QFormDataBuilder &&other) noexcept
void swap (QFormDataBuilder &other) noexcept
Q_NETWORK_EXPORT ~QFormDataBuilder ()
Q_NETWORK_EXPORT QFormDataPartBuilder part (QAnyStringView name)
Q_NETWORK_EXPORT std::unique_ptr< QHttpMultiPartbuildMultiPart (Options options={})

Detailed Description

The QFormDataBuilder class is a convenience class to simplify the construction of QHttpMultiPart objects.

Since
6.8

\inmodule QtNetwork

The QFormDataBuilder class can be used to build a QHttpMultiPart object with the content type set to be FormDataType by default.

The snippet below demonstrates how to build a multipart message with QFormDataBuilder:

QFile image(u"../../pic.png"_s); image.open(QFile::ReadOnly);
QFile mask(u"../../mask.png"_s); mask.open(QFile::ReadOnly);
builder.part("image"_L1).setBodyDevice(&image, "the actual image");
builder.part("mask"_L1).setBodyDevice(&mask, "the mask image");
builder.part("prompt"_L1).setBody("Lobster wearing a beret");
builder.part("n"_L1).setBody("2");
builder.part("size"_L1).setBody("512x512");
std::unique_ptr<QHttpMultiPart> mp = builder.buildMultiPart();
\inmodule QtCore
Definition qfile.h:96
Q_NETWORK_EXPORT QFormDataBuilder()
Q_NETWORK_EXPORT QFormDataPartBuilder part(QAnyStringView name)
Q_NETWORK_EXPORT std::unique_ptr< QHttpMultiPart > buildMultiPart(Options options={})
Q_WEAK_OVERLOAD QFormDataPartBuilder setBody(const QByteArray &data, QAnyStringView fileName={}, QAnyStringView mimeType={})
Q_NETWORK_EXPORT QFormDataPartBuilder setBodyDevice(QIODevice *body, QAnyStringView fileName={}, QAnyStringView mimeType={})
Sets body as the body device of this part and fileName as the file name parameter in the content disp...
Definition image.cpp:4
GLint GLint GLint GLint GLint GLint GLint GLbitfield mask
See also
QHttpPart, QHttpMultiPart, QFormDataPartBuilder

Definition at line 74 of file qformdatabuilder.h.

Member Enumeration Documentation

◆ Option

enum class QFormDataBuilder::Option
strong
Enumerator
Default 
OmitRfc8187EncodedFilename 
UseRfc7578PercentEncodedFilename 
PreferLatin1EncodedFilename 
StrictRfc7578 

Definition at line 77 of file qformdatabuilder.h.

Constructor & Destructor Documentation

◆ QFormDataBuilder() [1/2]

Q_NETWORK_EXPORT QFormDataBuilder::QFormDataBuilder ( )

◆ QFormDataBuilder() [2/2]

QFormDataBuilder::QFormDataBuilder ( QFormDataBuilder && other)
inlinenoexcept

Definition at line 89 of file qformdatabuilder.h.

◆ ~QFormDataBuilder()

Q_NETWORK_EXPORT QFormDataBuilder::~QFormDataBuilder ( )

Member Function Documentation

◆ buildMultiPart()

Q_NETWORK_EXPORT std::unique_ptr< QHttpMultiPart > QFormDataBuilder::buildMultiPart ( Options options = {})

◆ part()

Q_NETWORK_EXPORT QFormDataPartBuilder QFormDataBuilder::part ( QAnyStringView name)

◆ swap()

void QFormDataBuilder::swap ( QFormDataBuilder & other)
inlinenoexcept

Definition at line 92 of file qformdatabuilder.h.


The documentation for this class was generated from the following file: