File indexing completed on 2024-05-12 04:42:47

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_IFOPTUTIL_H
0008 #define KPUBLICTRANSPORT_IFOPTUTIL_H
0009 
0010 class QString;
0011 class QStringView;
0012 
0013 namespace KPublicTransport {
0014 
0015 /** Utility functions for dealing with IFOPT (Identification of Fixed Objects in Public Transport).
0016  *  @see https://wiki.openstreetmap.org/wiki/Key:ref:IFOPT
0017  *  @see https://en.wikipedia.org/wiki/Identification_of_Fixed_Objects_in_Public_Transport
0018  */
0019 namespace IfoptUtil
0020 {
0021 
0022 /** Check if @p ifopt is a valid IFOPT identifier. */
0023 bool isValid(QStringView ifopt);
0024 
0025 /** Returns the country identifier for the given (valid!) IFOPT identifier @p ifopt. */
0026 QStringView country(QStringView ifopt);
0027 
0028 /** Returns the stop place identifier for the given (valid!) IFOPT identifier @p ifopt. */
0029 QStringView stopPlace(QStringView ifopt);
0030 
0031 /** Returns the stop level identifier for the given (valid!) IFOPT identifier @p ifopt. */
0032 QStringView level(QStringView ifopt);
0033 
0034 /** Checks whether two valid IFOPT ids refer to the same stop place. */
0035 bool isSameStopPlace(QStringView lhs, QStringView rhs);
0036 
0037 /** Merge two IFOPT ids that refer to the same stop place while retaining the maximum level of detail.
0038  *  Precondition: isValid(lhs) && isValid(rhs) && isSameStopPlace(lhs, rhs)
0039  */
0040 QStringView merge(QStringView lhs, QStringView rhs);
0041 
0042 /** The identifier type for use in @c Location::identifer for IFOPT ids. */
0043 QString identifierType();
0044 
0045 }
0046 
0047 }
0048 
0049 #endif // KPUBLICTRANSPORT_IFOPTUTIL_H