Moved URL class into fr namespace
It should not have been in the global namespace, as it's a part of the library.
This commit is contained in:
parent
c110fb6c81
commit
431f646bae
@ -8,7 +8,8 @@
|
||||
#include <unordered_map>
|
||||
|
||||
//Note, a URL looks like this: scheme:[//host[:port]][/path][?query][#fragment]
|
||||
|
||||
namespace fr
|
||||
{
|
||||
class URL
|
||||
{
|
||||
public:
|
||||
@ -27,6 +28,7 @@ public:
|
||||
* Constructors
|
||||
*/
|
||||
URL() = default;
|
||||
|
||||
URL(const std::string &url);
|
||||
|
||||
/*!
|
||||
@ -118,6 +120,6 @@ private:
|
||||
std::string fragment;
|
||||
static std::unordered_map<std::string, URL::Scheme> scheme_string_map;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif //FRNETLIB_URLPARSER_H
|
||||
|
||||
@ -7,6 +7,9 @@
|
||||
#include <iostream>
|
||||
#include "frnetlib/URL.h"
|
||||
|
||||
namespace fr
|
||||
{
|
||||
|
||||
std::unordered_map<std::string, URL::Scheme> URL::scheme_string_map = {
|
||||
{"http", URL::HTTP},
|
||||
{"https", URL::HTTPS},
|
||||
@ -117,7 +120,8 @@ std::string URL::to_lower(const std::string &str)
|
||||
|
||||
const std::string &URL::scheme_to_string(URL::Scheme scheme)
|
||||
{
|
||||
auto iter = std::find_if(scheme_string_map.begin(), scheme_string_map.end(), [&](const auto &i){
|
||||
auto iter = std::find_if(scheme_string_map.begin(), scheme_string_map.end(), [&](const auto &i)
|
||||
{
|
||||
return i.second == scheme;
|
||||
});
|
||||
|
||||
@ -125,3 +129,4 @@ const std::string &URL::scheme_to_string(URL::Scheme scheme)
|
||||
throw std::logic_error("Unknown URL::Scheme value " + std::to_string(scheme));
|
||||
return iter->first;
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user