1 #include "lxgui/gui_registry.hpp"
3 #include "lxgui/gui_out.hpp"
4 #include "lxgui/gui_region.hpp"
5 #include "lxgui/utils_string.hpp"
10 if (utils::has_no_content(name)) {
12 <<
"Cannot create a region with a blank name." << std::endl;
16 if (utils::is_number(name[0])) {
18 <<
"A region's name cannot start by a number: \"" << name <<
"\" is forbidden."
23 std::size_t pos = name.find(
"$");
24 if (pos != name.npos && pos != 0) {
26 <<
"A region's name cannot contain the character '$' except at the begining: \""
27 << name <<
"\" is forbidden." << std::endl;
32 if ((std::isalnum(c) == 0) && c !=
'_' && c !=
'$') {
34 <<
"A region's name can only contain alphanumeric symbols, or underscores: \""
35 << name <<
"\" is forbidden." << std::endl;
49 auto iter_named_obj = named_object_list_.find(obj->get_name());
50 if (iter_named_obj != named_object_list_.end()) {
52 <<
"A region with the name \"" << obj->get_name() <<
"\" already exists."
57 named_object_list_[obj->get_name()] = std::move(obj);
63 named_object_list_.erase(obj.
get_name());
67 auto iter = named_object_list_.find(std::string{name});
68 if (iter != named_object_list_.end())
The base class of all elements in the GUI.
const std::string & get_name() const
Returns this region's name.
void remove_region(const region &obj)
Removes a region from this registry.
bool add_region(utils::observer_ptr< region > obj)
Adds a region to be handled by this registry.
bool check_region_name(std::string_view name) const
Checks the provided string is suitable for naming a region.
utils::observer_ptr< const region > get_region_by_name(std::string_view name) const
Returns the region associated with the given name.
const std::string warning