#pragma once
#include "DOMURL.h"
#include <wtf/Variant.h>
#include <wtf/Vector.h>
#include <wtf/text/WTFString.h>
namespace WebCore {
class URLSearchParams : public RefCounted<URLSearchParams> {
public:
static ExceptionOr<Ref<URLSearchParams>> create(Variant<Vector<Vector<String>>, Vector<WTF::KeyValuePair<String, String>>, String>&&);
static Ref<URLSearchParams> create(const String& string, DOMURL* associatedURL)
{
return adoptRef(*new URLSearchParams(string, associatedURL));
}
void associatedURLDestroyed() { m_associatedURL = nullptr; }
void append(const String& name, const String& value);
void remove(const String& name);
String get(const String& name) const;
Vector<String> getAll(const String& name) const;
bool has(const String& name) const;
void set(const String& name, const String& value);
String toString() const;
void updateFromAssociatedURL();
void sort();
class Iterator {
public:
explicit Iterator(URLSearchParams&);
std::optional<WTF::KeyValuePair<String, String>> next();
private:
Ref<URLSearchParams> m_target;
size_t m_index { 0 };
};
Iterator createIterator() { return Iterator { *this }; }
private:
const Vector<WTF::KeyValuePair<String, String>>& pairs() const { return m_pairs; }
URLSearchParams(const String&, DOMURL*);
URLSearchParams(const Vector<WTF::KeyValuePair<String, String>>&);
void updateURL();
DOMURL* m_associatedURL { nullptr };
Vector<WTF::KeyValuePair<String, String>> m_pairs;
};
}