CYD-UI
A C++ library for building native graphic user interfaces
Loading...
Searching...
No Matches
component_identifier.cppm
Go to the documentation of this file.
1
//
2
// Created by castle on 3/10/25.
3
//
4
5
export
module
cydui.components.base.identifier
;
6
7
import
std;
8
import
reflect;
9
10
export
namespace
cydui::components
{
11
class
identifier_t
{
12
public
:
13
consteval
identifier_t
(std::source_location
loc
= std::source_location::current())
14
: loc_(
loc
) {}
15
16
identifier_t
(
17
const
std::string&
id
, std::source_location
loc
= std::source_location::current()
18
)
19
: loc_(
loc
),
20
computed_id_(id) {}
21
22
identifier_t
(
23
const
char
*
id
, std::source_location
loc
= std::source_location::current()
24
)
25
: loc_(
loc
),
26
computed_id_(id) {}
27
28
std::string
str
()
const
{
29
if
(computed_id_.empty()) {
30
return
compute_id();
31
}
32
return
computed_id_;
33
}
34
35
std::string
str
() {
36
if
(computed_id_.empty()) {
37
computed_id_ = compute_id();
38
}
39
return
computed_id_;
40
}
41
42
void
set_id
(
const
std::string&
id
) {
43
computed_id_ = id;
44
}
45
46
const
std::source_location&
loc
()
const
{
47
return
loc_;
48
}
49
50
private
:
51
std::string compute_id()
const
{
52
return
std::format(
"{}:{}:{}"
, loc_.file_name(), loc_.line(), loc_.column());
53
}
54
55
private
:
56
const
std::source_location loc_{};
57
std::string computed_id_;
58
};
59
}
cydui::components::identifier_t::str
std::string str() const
Definition
component_identifier.cppm:28
cydui::components::identifier_t::identifier_t
consteval identifier_t(std::source_location loc=std::source_location::current())
Definition
component_identifier.cppm:13
cydui::components::identifier_t::identifier_t
identifier_t(const std::string &id, std::source_location loc=std::source_location::current())
Definition
component_identifier.cppm:16
cydui::components::identifier_t::set_id
void set_id(const std::string &id)
Definition
component_identifier.cppm:42
cydui::components::identifier_t::identifier_t
identifier_t(const char *id, std::source_location loc=std::source_location::current())
Definition
component_identifier.cppm:22
cydui::components::identifier_t::str
std::string str()
Definition
component_identifier.cppm:35
cydui::components::identifier_t::loc
const std::source_location & loc() const
Definition
component_identifier.cppm:46
cydui.components.base.identifier
cydui::components
Definition
component_anchors.cppm:19
include
cyd_ui
components
base
component_identifier.cppm
Generated by
1.13.2