~aleteoryx/muditaos

ref: b4568c32eb2a4b37e9dfbbe08c446430eee2145c muditaos/module-services/service-cellular/src/volte/ImsiParser.cpp -rw-r--r-- 771 bytes
b4568c32 — Kuba Kleczkowski [MOS-977] Added VoLTE support in additional countries 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "ImsiParser.hpp"

namespace cellular
{
    auto service::ImsiParser::isAllowed(const std::string &imsi) const -> bool
    {
        if (operatorCodes.empty()) {
            return false;
        }

        for (auto const &code : operatorCodes) {
            if (textStartsWith(imsi, code)) {
                return true;
            }
        }

        return false;
    }

    auto service::ImsiParser::textStartsWith(std::string_view text, std::string_view prefix) const -> bool
    {
        return !text.empty() && !prefix.empty() && std::equal(prefix.begin(), prefix.end(), text.begin());
    }
} // namespace cellular