/
farado
/
farado-binara
Обзор
Документация
Войти
/
farado
/
farado-binara
Код
Запросы
0
Пакеты
0
Релизы
0
CI/CD
Аналитика
develop
src/common/elements/project.cpp
137 строк
3 KB
Ostapenko Alexey
[common][datenaro][retejo][tests] Добавлены средства перевода в строки нижний регистр.
29 мар 2024, 18:01
29 мар 2024, 18:01
9bad5ab
Код
Авторство
О чём код?
#include <algorithm> #include <mutex> #include "common/elements/element.h" #include "common/more/string.h" #include "project.h" namespace Elements { Project::Project(const Project& other) : Element(other) , m_parentId(other.m_parentId) , m_caption(other.m_caption) , m_description(other.m_description) , m_searchCaption(other.m_searchCaption) , m_searchDescription(other.m_searchDescription) { } bool Project::isSame(Element* const other) const { const auto otherElement = dynamic_cast<Project const*>(other); if (nullptr == otherElement) return false; return bool( m_id == otherElement->m_id && m_parentId == otherElement->m_parentId && m_caption == otherElement->m_caption && m_description == otherElement->m_description && m_searchCaption == otherElement->m_searchCaption && m_searchDescription == otherElement->m_searchDescription ); } Common::Json Project::toJson() const { std::shared_lock locker(m_lock); Common::Json result; result["id"] = m_id; result["elementType"] = unsigned(elementType()); result["parentId"] = m_parentId; result["caption"] = m_caption; result["description"] = m_description; result["searchCaption"] = m_searchCaption; result["searchDescription"] = m_searchDescription; return result; } void Project::fromJson(const Common::Json& json) { std::shared_lock locker(m_lock); m_id = json["id"].get<unsigned>(); m_parentId = json["parentId"].get<unsigned>(); m_caption = json["caption"].get<std::string>(); m_description = json["description"].get<std::string>(); m_searchCaption = json["searchCaption"].get<std::string>(); m_searchDescription = json["searchDescription"].get<std::string>(); } Element* Project::clone() const { return new Project(*this); } ElementType Project::elementType() const { return ElementType::Project; } unsigned Project::parentId() const { std::shared_lock locker(m_lock); return m_parentId; } void Project::setParentId(unsigned value) { std::unique_lock locker(m_lock); m_parentId = value; } std::string Project::caption() const { std::shared_lock locker(m_lock); return m_caption; } void Project::setCaption(const std::string& value) { std::unique_lock locker(m_lock); m_caption = value; locker.unlock(); setSearchCaption(value); } std::string Project::description() const { std::shared_lock locker(m_lock); return m_description; } void Project::setDescription(const std::string& value) { std::unique_lock locker(m_lock); m_description = value; locker.unlock(); setSearchDescription(value); } std::string Project::searchCaption() const { std::shared_lock locker(m_lock); return m_searchCaption; } void Project::setSearchCaption(const std::string& value) { std::unique_lock locker(m_lock); m_searchCaption = Common::toLowerCase(value); } std::string Project::searchDescription() const { std::shared_lock locker(m_lock); return m_searchDescription; } void Project::setSearchDescription(const std::string& value) { std::unique_lock locker(m_lock); m_searchDescription = Common::toLowerCase(value); } } // namespace Elements