#include #include #include namespace XCEngine::UI::Editor { namespace { UIEditorPanelRegistryValidationResult MakeValidationError( UIEditorPanelRegistryValidationCode code, std::string message) { UIEditorPanelRegistryValidationResult result = {}; result.code = code; result.message = std::move(message); return result; } } // namespace const UIEditorPanelDescriptor* FindUIEditorPanelDescriptor( const UIEditorPanelRegistry& registry, std::string_view panelId) { for (const UIEditorPanelDescriptor& descriptor : registry.panels) { if (descriptor.panelId == panelId) { return &descriptor; } } return nullptr; } UIEditorPanelRegistryValidationResult ValidateUIEditorPanelRegistry( const UIEditorPanelRegistry& registry) { std::unordered_set panelIds = {}; for (const UIEditorPanelDescriptor& descriptor : registry.panels) { if (descriptor.panelId.empty()) { return MakeValidationError( UIEditorPanelRegistryValidationCode::EmptyPanelId, "Panel registry entry must define a panelId."); } if (descriptor.defaultTitle.empty()) { return MakeValidationError( UIEditorPanelRegistryValidationCode::EmptyDefaultTitle, "Panel descriptor '" + descriptor.panelId + "' must define a defaultTitle."); } if (!panelIds.insert(descriptor.panelId).second) { return MakeValidationError( UIEditorPanelRegistryValidationCode::DuplicatePanelId, "Panel descriptor '" + descriptor.panelId + "' is duplicated in the registry."); } } return {}; } } // namespace XCEngine::UI::Editor