2015-06-26 15:37:47 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* Icinga 2 *
|
2017-01-10 15:54:22 +01:00
|
|
|
* Copyright (C) 2012-2017 Icinga Development Team (https://www.icinga.com/) *
|
2015-06-26 15:37:47 +02:00
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or *
|
|
|
|
* modify it under the terms of the GNU General Public License *
|
|
|
|
* as published by the Free Software Foundation; either version 2 *
|
|
|
|
* of the License, or (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
* along with this program; if not, write to the Free Software Foundation *
|
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
#ifndef URL_H
|
|
|
|
#define URL_H
|
|
|
|
|
2015-07-20 17:21:27 +02:00
|
|
|
#include "remote/i2-remote.hpp"
|
2015-06-26 15:37:47 +02:00
|
|
|
#include "base/object.hpp"
|
|
|
|
#include "base/string.hpp"
|
2015-07-29 13:09:42 +02:00
|
|
|
#include "base/array.hpp"
|
2015-06-26 15:37:47 +02:00
|
|
|
#include "base/value.hpp"
|
|
|
|
#include <map>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace icinga
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A url class to use with the API
|
|
|
|
*
|
|
|
|
* @ingroup base
|
|
|
|
*/
|
2015-07-20 13:41:58 +02:00
|
|
|
class I2_REMOTE_API Url : public Object
|
2015-06-26 15:37:47 +02:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
DECLARE_PTR_TYPEDEFS(Url);
|
|
|
|
|
2015-09-01 11:11:45 +02:00
|
|
|
Url();
|
2015-06-26 15:37:47 +02:00
|
|
|
Url(const String& url);
|
|
|
|
|
2017-09-06 16:01:02 +02:00
|
|
|
String Format(bool onlyPathAndQuery = false, bool printCredentials = false) const;
|
2015-06-26 15:37:47 +02:00
|
|
|
|
|
|
|
String GetScheme(void) const;
|
|
|
|
String GetAuthority(void) const;
|
2015-09-01 11:11:45 +02:00
|
|
|
String GetUsername(void) const;
|
|
|
|
String GetPassword(void) const;
|
|
|
|
String GetHost(void) const;
|
|
|
|
String GetPort(void) const;
|
2015-06-26 15:37:47 +02:00
|
|
|
const std::vector<String>& GetPath(void) const;
|
2015-07-29 13:09:42 +02:00
|
|
|
const std::map<String, std::vector<String> >& GetQuery(void) const;
|
|
|
|
String GetQueryElement(const String& name) const;
|
|
|
|
const std::vector<String>& GetQueryElements(const String& name) const;
|
2015-06-26 15:37:47 +02:00
|
|
|
String GetFragment(void) const;
|
|
|
|
|
2015-09-01 11:11:45 +02:00
|
|
|
void SetScheme(const String& scheme);
|
2015-11-02 16:35:21 +01:00
|
|
|
void SetUsername(const String& username);
|
|
|
|
void SetPassword(const String& password);
|
2015-09-30 14:02:18 +02:00
|
|
|
void SetHost(const String& host);
|
|
|
|
void SetPort(const String& port);
|
2015-09-01 11:11:45 +02:00
|
|
|
void SetPath(const std::vector<String>& path);
|
|
|
|
void SetQuery(const std::map<String, std::vector<String> >& query);
|
2015-11-02 16:35:21 +01:00
|
|
|
|
2015-09-01 11:11:45 +02:00
|
|
|
void AddQueryElement(const String& name, const String& query);
|
|
|
|
void SetQueryElements(const String& name, const std::vector<String>& query);
|
|
|
|
void SetFragment(const String& fragment);
|
|
|
|
|
2015-06-26 15:37:47 +02:00
|
|
|
private:
|
|
|
|
String m_Scheme;
|
2015-09-01 11:11:45 +02:00
|
|
|
String m_Username;
|
|
|
|
String m_Password;
|
|
|
|
String m_Host;
|
|
|
|
String m_Port;
|
2015-06-26 15:37:47 +02:00
|
|
|
std::vector<String> m_Path;
|
2015-07-29 13:09:42 +02:00
|
|
|
std::map<String, std::vector<String> > m_Query;
|
2015-06-26 15:37:47 +02:00
|
|
|
String m_Fragment;
|
|
|
|
|
|
|
|
bool ParseScheme(const String& scheme);
|
|
|
|
bool ParseAuthority(const String& authority);
|
2015-09-01 11:11:45 +02:00
|
|
|
bool ParseUserinfo(const String& userinfo);
|
|
|
|
bool ParsePort(const String& port);
|
2015-06-26 15:37:47 +02: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 */
|