/
farado
/
farado-binara
Обзор
Документация
Войти
/
farado
/
farado-binara
Код
Запросы
0
Пакеты
0
Релизы
0
CI/CD
Аналитика
develop
src/retejo/ui_session/ui_session_message.cpp
60 строк
1 KB
Ostapenko Alexey
[retejo] Корректировка сборки.
18 мар 2024, 09:06
18 мар 2024, 09:06
85c7fa8
Код
Авторство
О чём код?
#include "ui_session_message.h" namespace { std::string typeToString(UiSessionMessage::Type type) { switch (type) { case UiSessionMessage::Type::Success: return "success"; case UiSessionMessage::Type::Warning: return "warning"; case UiSessionMessage::Type::Alert: return "alert"; } return "success"; } } // namespace UiSessionMessage::UiSessionMessage( const crow::json::wvalue& caption, const crow::json::wvalue& text, Type type ) : m_caption(caption) , m_text(text) , m_type(type) { } Common::ContextValue UiSessionMessage::toContextValue() const { Common::ContextValue result { { "type", typeToString(m_type) }, { "caption", m_caption }, { "text", m_text }, }; return result; } void UiSessionMessageList::push(const UiSessionMessage& message) { std::unique_lock locker(m_lock); m_data.push_back(message); } Common::ContextList UiSessionMessageList::toContextList() { std::unique_lock locker(m_lock); Common::ContextList result; for (const auto& item : m_data) result << item.toContextValue(); m_data.clear(); return result; } Common::ContextValue UiSessionMessageList::toContextValue() { return toContextList().data(); }