AeonGUI
A portable video game graphic user interface library.
Loading...
Searching...
No Matches
Location.hpp
1/*
2Copyright (C) 2025,2026 Rodrigo Jose Hernandez Cordoba
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
16#ifndef AEONGUI_DOM_LOCATION_H
17#define AEONGUI_DOM_LOCATION_H
18#include "aeongui/dom/USVString.hpp"
19#include "aeongui/Platform.hpp"
20#include <vector>
21#include <functional>
22namespace AeonGUI
23{
24 namespace DOM
25 {
33 {
34 public:
36 DLL Location();
40 DLL Location ( std::function<void ( const Location& ) > callback );
42 DLL ~Location();
47 DLL void assign ( const USVString& url );
51 DLL void replace ( const USVString& url );
56 DLL Location& operator= ( const USVString& url );
58 DLL void reload();
61 DLL const USVString& href() const;
64 DLL const USVString& origin() const;
67 DLL const USVString& protocol() const;
70 DLL const USVString& host() const;
73 DLL const USVString& hostname() const;
76 DLL const USVString& port() const;
79 DLL const USVString& pathname() const;
82 DLL const USVString& search() const;
85 DLL const USVString& hash() const;
90 DLL void SetCallback ( std::function<void ( const Location& ) > callback );
91 private:
92 USVString m_href{"about:blank"};
93 USVString m_origin{"about:blank"};
94 USVString m_protocol{"about:"};
95 USVString m_host{"blank"};
96 USVString m_hostname{"blank"};
97 USVString m_port{};
98 USVString m_pathname{};
99 USVString m_search{};
100 USVString m_hash{};
101 std::function<void ( const Location& ) > mCallback{};
102 };
103 }
104}
105#endif
Platform-specific DLL import/export macros and compiler helpers.
Location & operator=(const USVString &url)
Assign a URL using the = operator.
Definition Location.cpp:57
void assign(const USVString &url)
Navigate to the given URL.
Definition Location.cpp:63
void SetCallback(std::function< void(const Location &) > callback)
Set or replace the change callback.
Definition Location.cpp:52
const USVString & hostname() const
Get the hostname.
Definition Location.cpp:128
const USVString & search() const
Get the query string (including leading '?').
Definition Location.cpp:146
~Location()
Destructor.
const USVString & hash() const
Get the fragment (including leading '#').
Definition Location.cpp:152
const USVString & pathname() const
Get the pathname.
Definition Location.cpp:140
const USVString & protocol() const
Get the protocol (e.g. "https:").
Definition Location.cpp:116
Location()
Default constructor. URL is "about:blank".
void replace(const USVString &url)
Replace the current URL without creating a history entry.
Definition Location.cpp:87
const USVString & port() const
Get the port number.
Definition Location.cpp:134
const USVString & origin() const
Get the origin portion of the URL.
Definition Location.cpp:110
const USVString & host() const
Get the host (hostname:port).
Definition Location.cpp:122
const USVString & href() const
Get the full URL.
Definition Location.cpp:104
void reload()
Reload the current document.
Definition Location.cpp:95