33 defineDefaultProperty(
QLatin1String(
"toString"), method_getHref);
34 defineDefaultProperty(
QLatin1String(
"toJSON"), method_getHref);
36 defineAccessorProperty(
QLatin1String(
"hash"), method_getHash, method_setHash);
37 defineAccessorProperty(
QLatin1String(
"host"), method_getHost, method_setHost);
38 defineAccessorProperty(
QLatin1String(
"hostname"), method_getHostname, method_setHostname);
39 defineAccessorProperty(
QLatin1String(
"href"), method_getHref, method_setHref);
40 defineAccessorProperty(
QLatin1String(
"origin"), method_getOrigin,
nullptr);
41 defineAccessorProperty(
QLatin1String(
"password"), method_getPassword, method_setPassword);
42 defineAccessorProperty(
QLatin1String(
"pathname"), method_getPathname, method_setPathname);
43 defineAccessorProperty(
QLatin1String(
"port"), method_getPort, method_setPort);
44 defineAccessorProperty(
QLatin1String(
"protocol"), method_getProtocol, method_setProtocol);
45 defineAccessorProperty(
QLatin1String(
"search"), method_getSearch, method_setSearch);
46 defineAccessorProperty(
QLatin1String(
"searchParams"), method_getSearchParams,
nullptr);
47 defineAccessorProperty(
QLatin1String(
"username"), method_getUsername, method_setUsername);
196 if (firstColonPos != -1)
197 protocolOrScheme.truncate(firstColonPos);
218 search = search.
mid(1);
262void UrlObject::updateOrigin()
286void UrlObject::updateHost()
313 Scoped<UrlObject>
r(scope, thisObject);
321 const Value *argv,
int)
327 String *stringValue =
arg->stringValue();
329 if (stringValue ==
nullptr)
332 Scoped<UrlObject>
r(scope, thisObject);
347 Scoped<UrlObject>
r(scope, thisObject);
355 const Value *argv,
int)
361 String *stringValue =
arg->stringValue();
363 if (stringValue ==
nullptr)
366 Scoped<UrlObject>
r(scope, thisObject);
371 if (!
r->setHost(host))
383 Scoped<UrlObject>
r(scope, thisObject);
391 const Value *argv,
int)
397 String *stringValue =
arg->stringValue();
399 if (stringValue ==
nullptr)
402 Scoped<UrlObject>
r(scope, thisObject);
407 if (!
r->setHostname(hostname))
419 Scoped<UrlObject>
r(scope, thisObject);
427 const Value *argv,
int)
433 String *stringValue =
arg->stringValue();
435 if (stringValue ==
nullptr)
438 Scoped<UrlObject>
r(scope, thisObject);
443 if (!
r->setHref(href))
455 Scoped<UrlObject>
r(scope, thisObject);
468 Scoped<UrlObject>
r(scope, thisObject);
476 const Value *argv,
int)
482 String *stringValue =
arg->stringValue();
484 if (stringValue ==
nullptr)
487 Scoped<UrlObject>
r(scope, thisObject);
502 Scoped<UrlObject>
r(scope, thisObject);
510 const Value *argv,
int)
516 String *stringValue =
arg->stringValue();
518 if (stringValue ==
nullptr)
521 Scoped<UrlObject>
r(scope, thisObject);
536 Scoped<UrlObject>
r(scope, thisObject);
544 const Value *argv,
int)
550 String *stringValue =
arg->stringValue();
554 if (stringValue !=
nullptr)
556 else if (
arg->isInt32())
561 Scoped<UrlObject>
r(scope, thisObject);
565 if (!
r->setPort(
port))
577 Scoped<UrlObject>
r(scope, thisObject);
585 const Value *argv,
int)
591 String *stringValue =
arg->stringValue();
593 if (stringValue ==
nullptr)
596 Scoped<UrlObject>
r(scope, thisObject);
611 Scoped<UrlObject>
r(scope, thisObject);
619 const Value *argv,
int)
625 String *stringValue =
arg->stringValue();
627 if (stringValue ==
nullptr)
630 Scoped<UrlObject>
r(scope, thisObject);
645 Scoped<UrlObject>
r(scope, thisObject);
653 const Value *argv,
int)
659 String *stringValue =
arg->stringValue();
661 if (stringValue ==
nullptr)
664 Scoped<UrlObject>
r(scope, thisObject);
679 Scoped<UrlObject>
r(scope, thisObject);
686 usp->initializeParams(
r->search());
688 return usp->asReturnedValue();
692 int argc,
const Value *newTarget)
696 if (argc < 1 || argc > 2)
710 if (arg2StringValue ==
nullptr)
714 QUrl relativeUrl =
QUrl(arg1String);
717 QString relativePath = relativeUrl.path();
722 baseUrlPath.truncate(lastSlash);
733 urlString = arg1String;
742 obj->setProtoFromNewTarget(newTarget);
746 if (!urlObject->
setHref(urlString))
749 return obj->asReturnedValue();
765 defineDefaultProperty(
QLatin1String(
"toString"), method_toString);
767 defineDefaultProperty(
QLatin1String(
"append"), method_append);
768 defineDefaultProperty(
QLatin1String(
"delete"), method_delete);
772 defineDefaultProperty(
QLatin1String(
"getAll"), method_getAll);
773 defineDefaultProperty(
QLatin1String(
"forEach"), method_forEach);
774 defineDefaultProperty(
QLatin1String(
"entries"), method_entries);
776 defineDefaultProperty(
QLatin1String(
"values"), method_values);
780 int argc,
const Value *newTarget)
799 obj->setProtoFromNewTarget(newTarget);
803 if (argArrayObject !=
nullptr) {
806 uint len = argArray->getLength();
812 if (pairArrayObject ==
nullptr) {
821 uint pairLen = pairArray->getLength();
831 urlSearchParamsObject->initializeParams(argArray);
832 }
else if (argObject !=
nullptr) {
834 urlSearchParamsObject->initializeParams(scopedObject);
837 urlSearchParamsObject->initializeParams(
value);
840 return obj->asReturnedValue();
845 auto *arrayObject =
engine()->newArrayObject(0);
849 d()->params.set(
engine(), arrayObject);
872 if (equalsIndex != -1) {
904 scopedKeys->put(
i,
key);
905 scopedValues->put(
i,
value);
927 name =
it.nextPropertyNameAsString(val);
940 auto *arrayObject =
engine()->newArrayObject(0);
955 auto *valuePair =
engine()->newArrayObject(2);
961 valuePairObject->put(
uint(0),
key);
964 scopedKeys->put(
len,
key);
967 scopedArray->put(
len, valuePairObject);
971 d()->params.set(
engine(), arrayObject);
989 auto *valuePair =
engine()->newArrayObject(2);
995 valuePairObject->put(
uint(0), keyScoped);
996 valuePairObject->put(
uint(1), valueScoped);
998 uint len = scopedArray->getLength();
1000 scopedKeys->put(
len, keyScoped);
1001 scopedValues->put(
len, valueScoped);
1003 scopedArray->put(
len, valuePairObject);
1008 auto *arrayObject =
d()->params.get();
1012 QList<QStringList>
result;
1014 uint len = scopedArray->getLength();
1031 return d()->url.get();
1039 for (
int i = 0;
i <
len; ++
i) {
1050 auto *arrayObject =
d()->params.get();
1054 return scopedArray->getLength();
1059 auto *arrayObject =
d()->params.get();
1063 int len = scopedArray->getLength();
1065 for (
int i = last + 1;
i <
len;
i++) {
1078QString UrlSearchParamsObject::stringAt(
int index,
int pairIndex)
const
1080 auto *arrayObject =
d()->params.get();
1084 if (
index >= scopedArray->getLength())
1097 auto *arrayObject =
d()->params.get();
1101 if (
index >= scopedArray->getLength())
1114 return stringAt(
index, 0);
1119 return stringAtRaw(
index, 0);
1125 return stringAt(
index, 1);
1130 return stringAtRaw(
index, 1);
1149 if (arrayIndex <
len) {
1155 pd->
value = usp->engine()->newString(usp->nameAt(
index));
1176 if (
id.isArrayIndex()) {
1177 const int index =
id.asArrayIndex();
1179 if (index < usp->
length()) {
1181 p->
value = usp->engine()->newString(usp->nameAt(
index));
1204 Scoped<UrlSearchParamsObject>
o(scope, thisObject);
1227 Scoped<UrlSearchParamsObject>
o(scope, thisObject);
1231 QList<QStringList>
params =
o->params();
1240 const Value *argv,
int argc)
1253 if (argNameString ==
nullptr)
1259 Scoped<UrlSearchParamsObject>
o(scope, thisObject);
1269 const Value *argv,
int argc)
1281 if (argNameString ==
nullptr)
1286 Scoped<UrlSearchParamsObject>
o(scope, thisObject);
1290 QList<QStringList>
params =
o->params();
1291 params.removeIf([&
name](
const auto &pair) {
return pair.at(0) ==
name; });
1299 const Value *argv,
int argc)
1311 if (argNameString ==
nullptr)
1314 Scoped<UrlSearchParamsObject>
o(scope, thisObject);
1324 const Value *argv,
int argc)
1337 if (argNameString ==
nullptr)
1340 Scoped<UrlSearchParamsObject>
o(scope, thisObject);
1349 bool matched =
false;
1370 Scoped<UrlObject> scopedUrlObject(scope,
o->d()->url.get());
1371 if (scopedUrlObject)
1372 scopedUrlObject->setSearch(
o->searchString());
1378 const Value *argv,
int argc)
1390 if (argNameString ==
nullptr)
1393 Scoped<UrlSearchParamsObject>
o(scope, thisObject);
1421 if (argNameString ==
nullptr)
1424 Scoped<UrlSearchParamsObject>
o(scope, thisObject);
1439 return Encode(arrayObject);
1456 if (
func ==
nullptr)
1459 Scoped<UrlSearchParamsObject>
o(scope, thisObject);
1463 for (
int i = 0;
i <
o->length();
i++) {
1464 Scoped<String>
name(scope,
o->nameAtRaw(
i));
1465 Scoped<String>
value(scope,
o->valueAtRaw(
i));
1469 calldata.args[0] =
value;
1470 calldata.args[1] =
name;
1472 func->call(calldata);
1488 Scoped<UrlSearchParamsObject>
o(scope, thisObject);
1496 return paramsIterator->asReturnedValue();
1509 Scoped<UrlSearchParamsObject>
o(scope, thisObject);
1517 return keysIterator->asReturnedValue();
1530 Scoped<UrlSearchParamsObject>
o(scope, thisObject);
1538 return valuesIterator->asReturnedValue();
QString arg(Args &&...args) const
iterator erase(const_iterator i)
\macro QT_RESTRICTED_CAST_FROM_ASCII
qsizetype lastIndexOf(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
void chop(qsizetype n)
Removes n characters from the end of the string.
QStringList split(const QString &sep, Qt::SplitBehavior behavior=Qt::KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Splits the string into substrings wherever sep occurs, and returns the list of those strings.
QString mid(qsizetype position, qsizetype n=-1) const &
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
static QString fromUtf8(QByteArrayView utf8)
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QString & append(QChar c)
QString & prepend(QChar c)
QString fragment(ComponentFormattingOptions options=PrettyDecoded) const
Returns the fragment of the URL.
QString query(ComponentFormattingOptions=PrettyDecoded) const
Returns the query string of the URL if there's a query string, or an empty result if not.
void setPassword(const QString &password, ParsingMode mode=DecodedMode)
Sets the URL's password to password.
void setUserName(const QString &userName, ParsingMode mode=DecodedMode)
Sets the URL's user name to userName.
void setFragment(const QString &fragment, ParsingMode mode=TolerantMode)
Sets the fragment of the URL to fragment.
bool isRelative() const
Returns true if the URL is relative; otherwise returns false.
bool isValid() const
Returns true if the URL is non-empty and valid; otherwise returns false.
QString userName(ComponentFormattingOptions options=FullyDecoded) const
Returns the user name of the URL if it is defined; otherwise an empty string is returned.
QString host(ComponentFormattingOptions=FullyDecoded) const
Returns the host of the URL if it is defined; otherwise an empty string is returned.
void setQuery(const QString &query, ParsingMode mode=TolerantMode)
Sets the query string of the URL to query.
QString password(ComponentFormattingOptions=FullyDecoded) const
Returns the password of the URL if it is defined; otherwise an empty string is returned.
static QByteArray toPercentEncoding(const QString &, const QByteArray &exclude=QByteArray(), const QByteArray &include=QByteArray())
Returns an encoded copy of input.
QString scheme() const
Returns the scheme of the URL.
void setScheme(const QString &scheme)
Sets the scheme of the URL to scheme.
void setHost(const QString &host, ParsingMode mode=DecodedMode)
Sets the host of the URL to host.
int port(int defaultPort=-1) const
void setPath(const QString &path, ParsingMode mode=DecodedMode)
Sets the path of the URL to path.
QString toString(FormattingOptions options=FormattingOptions(PrettyDecoded)) const
Returns a string representation of the URL.
void setPort(int port)
Sets the port of the URL to port.
QString path(ComponentFormattingOptions options=FullyDecoded) const
Returns the path of the URL.
QHash< int, QWidget * > hash
[35multi]
list append(new Employee("Blackpool", "Stephen"))
QSet< QString >::iterator it
Scoped< String > ScopedString
static struct AttrInfo attrs[]
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
GLenum GLsizei GLsizei GLint * values
[15]
GLboolean GLboolean GLboolean b
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLuint GLenum GLsizei length
GLenum const GLint * param
GLuint GLuint GLuint GLuint arg1
GLuint GLuint GLuint GLuint GLuint GLuint GLuint arg2
QLatin1StringView QLatin1String
#define QStringLiteral(str)
request setUrl(QUrl("http://qt-project.org"))
static bool checkSearchParamsType(ExecutionEngine *v4, const Scoped< UrlSearchParamsObject > &o)
static bool checkUrlObjectType(ExecutionEngine *v4, const Scoped< UrlObject > &r)
#define DEFINE_OBJECT_VTABLE(classname)
QUrl url("example.com")
[constructor-url-reference]
\inmodule QtCore \reentrant
static constexpr ReturnedValue undefined()
static constexpr ReturnedValue null()
ReturnedValue throwError(const Value &value)
Heap::UrlSearchParamsObject * newUrlSearchParamsObject()
Heap::UrlObject * newUrlObject()
Heap::String * newString(char16_t c)
Heap::ArrayObject * newArrayObject(int count=0)
Heap::Object * newArrayIteratorObject(Object *o)
ReturnedValue throwTypeError()
void init(ExecutionEngine *engine)
void init(ExecutionEngine *engine)
ExecutionEngine * engine() const
PropertyKey next(const Object *o, Property *pd=nullptr, PropertyAttributes *attrs=nullptr) override
static PropertyKey fromArrayIndex(uint idx)
QV4_NEARLY_ALWAYS_INLINE constexpr quint32 value() const
QString toQString() const
bool setSearch(QString search)
Q_QML_AUTOTEST_EXPORT QString search() const
bool setPathname(QString pathname)
bool setHostname(QString hostname)
void setUrl(const QUrl &url)
bool setHash(QString hash)
bool setHref(QString href)
bool setProtocol(QString protocol)
bool setUsername(QString username)
bool setPort(QString port)
bool setPassword(QString password)
bool setHost(QString host)
static ReturnedValue method_getPathname(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_getPort(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_getSearchParams(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_setProtocol(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_getUsername(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_getProtocol(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_setHostname(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_setHref(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_setSearch(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_getHash(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_setHost(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_setPort(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_getPassword(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
void init(ExecutionEngine *engine, Object *ctor)
static ReturnedValue method_getOrigin(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_setUsername(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_getSearch(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_setPassword(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_getHost(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_getHostname(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_getHref(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_setPathname(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_setHash(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
void setParams(QList< QStringList > params)
QString valueAt(int index) const
QList< QStringList > params() const
Heap::UrlObject * urlObject() const
int indexOf(QString name, int last=-1) const
QString searchString() const
Heap::String * nameAtRaw(int index) const
void append(Heap::String *name, Heap::String *value)
Heap::String * valueAtRaw(int index) const
void setUrlObject(const UrlObject *url)
QString nameAt(int index) const
static ReturnedValue method_keys(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_forEach(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_get(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_sort(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_delete(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
void init(ExecutionEngine *engine, Object *ctor)
static ReturnedValue method_getAll(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_toString(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_append(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_has(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_set(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_entries(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static ReturnedValue method_values(const FunctionObject *, const Value *thisObject, const Value *argv, int argc)
static constexpr VTable::OwnPropertyKeys virtualOwnPropertyKeys
static constexpr VTable::GetOwnProperty virtualGetOwnProperty
static constexpr VTable::CallAsConstructor virtualCallAsConstructor
QML_NEARLY_ALWAYS_INLINE String * stringValue() const
static Value fromHeapObject(HeapBasePtr m)
QString toQString() const
PropertyKey next(const QV4::Object *o, Property *pd=nullptr, PropertyAttributes *attrs=nullptr) override
~UrlSearchParamsObjectOwnPropertyKeyIterator() override=default