icinga2/lib/remote/url.hpp

80 lines
2 KiB
C++
Raw Permalink Normal View History

Replace all existing copyright headers with `SPDX` headers I've used the following command to replace the original copyright header lines in a C-style comment block: ``` $ find . \( -type d \( -name '\..*' -o -name third-party -o -name scripts -o -name prefix -o -name malloc -o -name server -o -name docker -o -name build -o -name doc \) -prune \) -o -type f -exec perl -pi -e 's{/\*[^*]*\(\s*c\s*\)\s*(\d{4})\s*Icinga\s+GmbH[^*]*\*/}{// SPDX-FileCopyrightText: \1 Icinga GmbH <https://icinga.com>\n// SPDX-License-Identifier: GPL-2.0-or-later}gi' {} + ``` For files that use shell-style comments (#) like CMakeLists.txt, I've used this command: ``` $ find . \( -type d \( -name '\..*' -o -name third-party -o -name scripts -o -name prefix -o -name malloc -o -name server -o -name docker -o -name build -o -name doc \) -prune \) -o -type f -exec perl -pi -e 's{#.*\(\s*c\s*\)\s(\d{4})\sIcinga\s+GmbH.*}{# SPDX-FileCopyrightText: \1 Icinga GmbH <https://icinga.com>\n# SPDX-License-Identifier: GPL-2.0-or-later}gi' {} + ``` And for SQL files: ``` $ find . \( -type d \( -name '\..*' -o -name third-party -o -name scripts -o -name prefix -o -name malloc -o -name server -o -name docker -o -name build -o -name doc \) -prune \) -o -type f \( -name '*.sql' \) -exec perl -pi -e 's{--.*\(c\)\s(\d{4})\sIcinga\sGmbH.*}{-- SPDX-FileCopyrightText: \1 Icinga GmbH <https://icinga.com>\n-- SPDX-License-Identifier: GPL-2.0-or-later}gi' {} + $ find . \( -type d \( -name '\..*' -o -name third-party -o -name scripts -o -name prefix -o -name malloc -o -name server -o -name docker -o -name build -o -name doc \) -prune \) -o -type f \( -name '*.sql' \) -exec perl -pi -e 's{-- Copyright \(c\)\s(\d{4})\sIcinga\s+Development\sTeam.*}{-- SPDX-FileCopyrightText: \1 Icinga GmbH <https://icinga.com>\n-- SPDX-License-Identifier: GPL-2.0-or-later}gi' {} + ```
2026-01-27 09:06:40 -05:00
// SPDX-FileCopyrightText: 2012 Icinga GmbH <https://icinga.com>
// SPDX-License-Identifier: GPL-2.0-or-later
2015-06-26 09:37:47 -04:00
#ifndef URL_H
#define URL_H
2015-07-20 11:21:27 -04:00
#include "remote/i2-remote.hpp"
2015-06-26 09:37:47 -04:00
#include "base/object.hpp"
#include "base/string.hpp"
2015-07-29 07:09:42 -04:00
#include "base/array.hpp"
2015-06-26 09:37:47 -04:00
#include "base/value.hpp"
#include <map>
2018-12-21 05:52:37 -05:00
#include <utility>
2015-06-26 09:37:47 -04:00
#include <vector>
namespace icinga
{
/**
* A url class to use with the API
*
* @ingroup base
*/
2018-01-04 00:11:04 -05:00
class Url final : public Object
2015-06-26 09:37:47 -04:00
{
public:
DECLARE_PTR_TYPEDEFS(Url);
Url() = default;
2015-06-26 09:37:47 -04:00
Url(const String& url);
String Format(bool onlyPathAndQuery = false, bool printCredentials = false) const;
2015-06-26 09:37:47 -04:00
String GetScheme() const;
String GetAuthority() const;
String GetUsername() const;
String GetPassword() const;
String GetHost() const;
String GetPort() const;
const std::vector<String>& GetPath() const;
2018-12-21 05:52:37 -05:00
const std::vector<std::pair<String, String>>& GetQuery() const;
String GetFragment() const;
2015-06-26 09:37:47 -04:00
2015-09-01 05:11:45 -04:00
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);
2015-09-01 05:11:45 -04:00
void SetPath(const std::vector<String>& path);
2018-12-21 05:52:37 -05:00
void SetQuery(const std::vector<std::pair<String, String>>& query);
void SetArrayFormatUseBrackets(bool useBrackets = true);
2015-09-01 05:11:45 -04:00
void AddQueryElement(const String& name, const String& query);
void SetFragment(const String& fragment);
2015-06-26 09:37:47 -04:00
private:
String m_Scheme;
2015-09-01 05:11:45 -04:00
String m_Username;
String m_Password;
String m_Host;
String m_Port;
2015-06-26 09:37:47 -04:00
std::vector<String> m_Path;
2018-12-21 05:52:37 -05:00
std::vector<std::pair<String, String>> m_Query;
bool m_ArrayFormatUseBrackets;
2015-06-26 09:37:47 -04:00
String m_Fragment;
bool ParseScheme(const String& scheme);
bool ParseAuthority(const String& authority);
2015-09-01 05:11:45 -04:00
bool ParseUserinfo(const String& userinfo);
bool ParsePort(const String& port);
2015-06-26 09:37:47 -04:00
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 */