Photon 1.0.0
Loading...
Searching...
No Matches
URL.hpp
Go to the documentation of this file.
1/*
2 * =====================================================================
3 *
4 * Photon
5 * Copyright Amlal EL Mahrouss, all rights reserved.
6 *
7 * File: URL.hpp
8 * Purpose: Photon URI parser
9 *
10 * =====================================================================
11 */
12
13#pragma once
14
15#include <core/Core.hpp>
16
17#ifndef PHOTON_HTTPS_PROTOCOL
18#define PHOTON_HTTPS_PROTOCOL ("https")
19#endif // !PHOTON_HTTPS_PROTOCOL
20
21#ifndef PHOTON_HTTP_PROTOCOL
22#define PHOTON_HTTP_PROTOCOL ("http")
23#endif // !PHOTON_HTTP_PROTOCOL
24
25#ifndef PHOTON_FILE_PROTOCOL
26#define PHOTON_FILE_PROTOCOL ("file")
27#endif // !PHOTON_FILE_PROTOCOL
28
29#ifndef PHOTON_MAIL_PROTOCOL
30#define PHOTON_MAIL_PROTOCOL ("mailto")
31#endif // !PHOTON_MAIL_PROTOCOL
32
33#ifndef PHOTON_ECMA_PROTOCOL
34#define PHOTON_ECMA_PROTOCOL ("javascript")
35#endif // !PHOTON_ECMA_PROTOCOL
36
37#ifndef PHOTON_PHOTON_PROTOCOL
38#define PHOTON_PHOTON_PROTOCOL ("photon")
39#endif // !PHOTON_PHOTON_PROTOCOL
40
41namespace Photon
42{
43 class PHOTON_API URL final
44 {
45 public:
46 URL(const char* protocol);
47 virtual ~URL();
48
49 URL& operator=(const URL&) = default;
50 URL(const URL&) = default;
51
52 String port() noexcept;
53 String protocol() noexcept;
54 String get() noexcept;
55
56 public:
57 String send(String data);
58 String fetch();
59
60 public:
61 URL& operator/=(const String& uri);
62 URL& operator/=(const char* uri);
63
64 private:
65 String m_data;
66 String m_protocol;
67 String m_port;
68 };
69
70 class PHOTON_API URLError final : public BrowserError
71 {
72 public:
73 URLError(URL& uri) : BrowserError("INVALID_URL_AT_DEST"), m_uri(uri)
74 {
75 }
76
77 ~URLError() = default; // let the ABI define that.
78
79 URLError& operator=(const URLError&) = default;
80 URLError(const URLError&) = default;
81
82 URL& get();
83
84 private:
86 };
87} // namespace Photon
Definition Core.hpp:46
Definition URL.hpp:71
URLError & operator=(const URLError &)=default
URLError(URL &uri)
Definition URL.hpp:73
URLError(const URLError &)=default
URL m_uri
Definition URL.hpp:85
~URLError()=default
Definition URL.hpp:44
URL & operator=(const URL &)=default
virtual ~URL()
URL(const URL &)=default
#define PHOTON_API
Definition Config.hpp:64
This file is also about defining core js concepts.
Definition BasePhotonWindow.hpp:22
std::string String
Definition Core.hpp:37
Definition format.h:1901