2015-02-11 16:18:18 +11:00
|
|
|
/*
|
|
|
|
* This file is part of libgim.
|
|
|
|
*
|
|
|
|
* libgim 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 3 of the License, or (at your option) any later
|
|
|
|
* version.
|
|
|
|
*
|
|
|
|
* libgim 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 libgim. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* Copyright 2015 Danny Robson <danny@nerdcruft.net>
|
|
|
|
*/
|
|
|
|
|
2015-02-09 17:43:24 +11:00
|
|
|
|
|
|
|
#ifndef __UTIL_URI_HPP
|
|
|
|
#define __UTIL_URI_HPP
|
|
|
|
|
2015-02-11 16:18:43 +11:00
|
|
|
#include "view.hpp"
|
|
|
|
|
2015-02-09 17:43:24 +11:00
|
|
|
#include <string>
|
|
|
|
#include <stdexcept>
|
|
|
|
|
|
|
|
|
|
|
|
namespace util {
|
|
|
|
class uri {
|
|
|
|
public:
|
|
|
|
uri (std::string &&);
|
|
|
|
uri (const char *str);
|
|
|
|
uri (const char *first, const char *last);
|
|
|
|
|
|
|
|
class parse_error : public std::runtime_error
|
|
|
|
{ using runtime_error::runtime_error; };
|
|
|
|
|
|
|
|
enum component : unsigned {
|
|
|
|
SCHEME,
|
|
|
|
AUTHORITY,
|
|
|
|
PATH,
|
|
|
|
QUERY,
|
|
|
|
FRAGMENT,
|
|
|
|
|
|
|
|
NUM_COMPONENTS
|
|
|
|
};
|
|
|
|
|
2015-02-11 16:18:43 +11:00
|
|
|
view get (component);
|
2015-02-09 17:43:24 +11:00
|
|
|
|
2015-02-11 16:18:43 +11:00
|
|
|
static std::string percent_decode (view);
|
2015-02-09 17:43:24 +11:00
|
|
|
|
|
|
|
private:
|
2015-02-11 16:18:43 +11:00
|
|
|
view m_views[NUM_COMPONENTS];
|
2015-02-09 17:43:24 +11:00
|
|
|
std::string m_value;
|
|
|
|
};
|
|
|
|
|
|
|
|
std::ostream& operator<< (std::ostream&, uri::component);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|