blob: f6dba957b8a84accaaeefd9a2b9a16caca99a6dd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
/*
* File: net/url.hpp
* Purpose: URL container in modern C++
* Author: Amlal El Mahrouss (founder@snu.systems)
* Copyright 2025, Amlal El Mahrouss and SNU Systems Corp.
*/
#pragma once
#include <string>
#include <iostream>
#include <sstream>
/// @author Amlal El Mahrouss (founder@snu.systems)
namespace snu::net
{
template <typename char_type>
class basic_url;
template <typename char_type>
class basic_url_traits;
/// @brief Basic URL parser container.
template <typename char_type>
class basic_url final
{
friend basic_url_traits<char_type>;
std::basic_stringstream<char_type> ss_{};
public:
explicit basic_url() = default;
~basic_url() = default;
basic_url& operator=(const basic_url&) = default;
basic_url(const basic_url&) = default;
basic_url& operator/=(const std::basic_string<char_type>& in)
{
if (in.empty())
return *this;
ss_ += in;
return *this;
}
basic_url& operator/=(const char_type& in)
{
ss_ += in;
return *this;
}
explicit operator bool()
{
return this->is_valid();
}
bool is_valid()
{
return ss_.size() > 0;
}
};
} // namespace snu::net
|