Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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 Member Functions

Q_NETWORK_EXPORT QFormDataBuilder ()
 Constructs an empty QFormDataBuilder object.
 
 QFormDataBuilder (QFormDataBuilder &&other) noexcept
 Move-constructs a QFormDataBuilder instance, making it point at the same object that other was pointing to.
 
void swap (QFormDataBuilder &other) noexcept
 
Q_NETWORK_EXPORT ~QFormDataBuilder ()
 Destroys the QFormDataBuilder object.
 
Q_NETWORK_EXPORT QFormDataPartBuilderpart (QAnyStringView name)
 Constructs and returns a reference to a QFormDataPartBuilder object and sets name as the name parameter of the form-data.
 
Q_NETWORK_EXPORT std::unique_ptr< QHttpMultiPartbuildMultiPart ()
 Constructs and returns a pointer to a QHttpMultipart object.
 

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:93
The QFormDataBuilder class is a convenience class to simplify the construction of QHttpMultiPart obje...
Q_NETWORK_EXPORT std::unique_ptr< QHttpMultiPart > buildMultiPart()
Constructs and returns a pointer to a QHttpMultipart object.
Q_NETWORK_EXPORT QFormDataPartBuilder & part(QAnyStringView name)
Constructs and returns a reference to a QFormDataPartBuilder object and sets name as the name paramet...
Definition image.cpp:4
GLint GLint GLint GLint GLint GLint GLint GLbitfield mask
See also
QHttpPart, QHttpMultiPart, QFormDataPartBuilder

Definition at line 90 of file qformdatabuilder.h.

Constructor & Destructor Documentation

◆ QFormDataBuilder() [1/2]

QFormDataBuilder::QFormDataBuilder ( )

Constructs an empty QFormDataBuilder object.

Definition at line 302 of file qformdatabuilder.cpp.

◆ QFormDataBuilder() [2/2]

QFormDataBuilder::QFormDataBuilder ( QFormDataBuilder && other)
inlinenoexcept

Move-constructs a QFormDataBuilder instance, making it point at the same object that other was pointing to.

Definition at line 95 of file qformdatabuilder.h.

◆ ~QFormDataBuilder()

QFormDataBuilder::~QFormDataBuilder ( )

Destroys the QFormDataBuilder object.

Definition at line 312 of file qformdatabuilder.cpp.

Member Function Documentation

◆ buildMultiPart()

std::unique_ptr< QHttpMultiPart > QFormDataBuilder::buildMultiPart ( )

Constructs and returns a pointer to a QHttpMultipart object.

See also
QHttpMultiPart

Definition at line 355 of file qformdatabuilder.cpp.

References QHttpMultiPart::append(), d, QHttpMultiPart::FormDataType, multiPart, and part().

+ Here is the call graph for this function:

◆ part()

QFormDataPartBuilder & QFormDataBuilder::part ( QAnyStringView name)

Constructs and returns a reference to a QFormDataPartBuilder object and sets name as the name parameter of the form-data.

The returned reference is valid until the next call to this function.

Limiting name characters to US-ASCII is \l {https://datatracker.ietf.org/doc/html/rfc7578#section-5.1.1}{strongly recommended} for interoperability reasons.

See also
QFormDataPartBuilder, QHttpPart

Definition at line 342 of file qformdatabuilder.cpp.

References d.

Referenced by buildMultiPart().

+ Here is the caller graph for this function:

◆ swap()

void QFormDataBuilder::swap ( QFormDataBuilder & other)
inlinenoexcept

Definition at line 98 of file qformdatabuilder.h.

References other(), and qt_ptr_swap().

+ Here is the call graph for this function:

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