From 0915b3ef56dfac3113cce55a59a5765dc94976be Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 14:34:54 +0200 Subject: Adding upstream version 2.13.6. Signed-off-by: Daniel Baumann --- lib/remote/url.hpp | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 lib/remote/url.hpp (limited to 'lib/remote/url.hpp') diff --git a/lib/remote/url.hpp b/lib/remote/url.hpp new file mode 100644 index 0000000..6012b2f --- /dev/null +++ b/lib/remote/url.hpp @@ -0,0 +1,78 @@ +/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */ + +#ifndef URL_H +#define URL_H + +#include "remote/i2-remote.hpp" +#include "base/object.hpp" +#include "base/string.hpp" +#include "base/array.hpp" +#include "base/value.hpp" +#include +#include +#include + +namespace icinga +{ + +/** + * A url class to use with the API + * + * @ingroup base + */ +class Url final : public Object +{ +public: + DECLARE_PTR_TYPEDEFS(Url); + + Url() = default; + Url(const String& url); + + String Format(bool onlyPathAndQuery = false, bool printCredentials = false) const; + + String GetScheme() const; + String GetAuthority() const; + String GetUsername() const; + String GetPassword() const; + String GetHost() const; + String GetPort() const; + const std::vector& GetPath() const; + const std::vector>& GetQuery() const; + String GetFragment() const; + + void SetScheme(const String& scheme); + void SetUsername(const String& username); + void SetPassword(const String& password); + void SetHost(const String& host); + void SetPort(const String& port); + void SetPath(const std::vector& path); + void SetQuery(const std::vector>& query); + void SetArrayFormatUseBrackets(bool useBrackets = true); + + void AddQueryElement(const String& name, const String& query); + void SetFragment(const String& fragment); + +private: + String m_Scheme; + String m_Username; + String m_Password; + String m_Host; + String m_Port; + std::vector m_Path; + std::vector> m_Query; + bool m_ArrayFormatUseBrackets; + String m_Fragment; + + bool ParseScheme(const String& scheme); + bool ParseAuthority(const String& authority); + bool ParseUserinfo(const String& userinfo); + bool ParsePort(const String& port); + bool ParsePath(const String& path); + bool ParseQuery(const String& query); + bool ParseFragment(const String& fragment); + + static bool ValidateToken(const String& token, const String& symbols); +}; + +} +#endif /* URL_H */ -- cgit v1.2.3