File indexing completed on 2024-11-10 04:16:42

0001 /*
0002     SPDX-FileCopyrightText: 2021 Volker Krause <vkrause@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #ifndef KPUBLICTRANSPORT_UICSTATIONCODE_H
0008 #define KPUBLICTRANSPORT_UICSTATIONCODE_H
0009 
0010 #include <cstdint>
0011 #include <vector>
0012 
0013 class QStringView;
0014 
0015 namespace KPublicTransport {
0016 
0017 
0018 /** Utility functions for dealing with UIC station codes.
0019  *  Also works for the syntactically identical IBNR station codes.
0020  */
0021 namespace UicStationCode
0022 {
0023 
0024 /** Returns @c true if @p id is a valid UIC station code.
0025  *  @params allowedCountryCodes if non-empty, only UIC station codes with an UIC country code included
0026  *  in that list are considered valid. This list has to be sorted.
0027  */
0028 bool isValid(QStringView id, const std::vector<uint8_t> &allowedCountryCodes = {});
0029 
0030 /** Returns the country code of a given valid UIC station code. */
0031 QStringView country(QStringView id);
0032 
0033 }
0034 
0035 }
0036 
0037 #endif // KPUBLICTRANSPORT_UICSTATIONCODE_H