// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/blob/master/LICENSE.md #include "UrcClip.hpp" using namespace at::urc; auto Clip::isValid() const noexcept -> bool { return tokens.size() >= minParametersCount; } std::string Clip::getNumber() const { if (!isValid()) { return std::string(); } return tokens[magic_enum::enum_integer(Tokens::Number)]; }; std::optional Clip::getType() const { if (!isValid()) { return std::nullopt; } auto addressType = utils::getNumericValue(tokens[magic_enum::enum_integer(Tokens::Type)]); constexpr auto addressTypes = magic_enum::enum_values(); for (const auto &type : addressTypes) { if (magic_enum::enum_integer(type) == addressType) { return type; } } return std::nullopt; }; std::optional Clip::getSubaddr() const { size_t minNumOfParams = magic_enum::enum_integer(Tokens::Subaddr) + 1; if (tokens.size() < minNumOfParams) { return std::nullopt; } if (tokens[magic_enum::enum_integer(Tokens::Subaddr)].empty()) { return std::nullopt; } return tokens[magic_enum::enum_integer(Tokens::Subaddr)]; }; std::optional Clip::getSatype() const { size_t minNumOfParams = magic_enum::enum_integer(Tokens::Satype) + 1; if (tokens.size() < minNumOfParams) { return std::nullopt; } if (tokens[magic_enum::enum_integer(Tokens::Satype)].empty()) { return std::nullopt; } return tokens[magic_enum::enum_integer(Tokens::Satype)]; }; std::optional Clip::getAlpha() const { size_t minNumOfParams = magic_enum::enum_integer(Tokens::Alpha) + 1; if (tokens.size() < minNumOfParams) { return std::nullopt; } if (tokens[magic_enum::enum_integer(Tokens::Alpha)].empty()) { return std::nullopt; } return tokens[magic_enum::enum_integer(Tokens::Alpha)]; }; std::optional Clip::getCLIValidity() const { size_t minNumOfParams = magic_enum::enum_integer(Tokens::CLIValidity) + 1; if (tokens.size() < minNumOfParams) { return std::nullopt; } if (tokens[magic_enum::enum_integer(Tokens::CLIValidity)].empty()) { return std::nullopt; } return tokens[magic_enum::enum_integer(Tokens::CLIValidity)]; };