6#include "identifier_p.h"
18 return std::ranges::find_if(m_identifiers, [type](
const auto &
id) {
19 return id.type == type;
20 }) != m_identifiers.end();
25 const auto it = std::ranges::find_if(m_identifiers, [type](
const auto &
id) {
26 return id.type == type;
28 return it == m_identifiers.
end() ? QString() : (*it).value;
31void IdentifierSet::setIdentifier(
const QString &type,
const QString &value)
33 const auto it = std::ranges::find_if(m_identifiers, [type](
const auto &
id) {
34 return id.type == type;
36 if (it == m_identifiers.end()) {
37 if (!value.isEmpty()) {
38 m_identifiers.emplace_back(type, value);
41 if (value.isEmpty()) {
42 m_identifiers.erase(it);
52 l.
reserve((qsizetype)m_identifiers.size());
53 std::ranges::transform(m_identifiers, std::back_inserter(l), [](
const auto &
id) {
return id.type; });
57IdentifierSet::PartialCompare IdentifierSet::compare(
const IdentifierSet &other)
const
59 bool foundEqualId =
false;
60 for (
const auto &
id :m_identifiers) {
61 const auto otherValue = other.identifier(
id.type);
62 if (
id.value.isEmpty() || otherValue.isEmpty()) {
65 if (
id.value == otherValue) {
71 return foundEqualId ? Equal : NoIntersection;
74void IdentifierSet::merge(
const IdentifierSet &other)
76 for (
const auto &otherId : other.m_identifiers) {
77 if (otherId.value.isEmpty()) {
80 const auto it = std::ranges::find_if(m_identifiers, [&otherId](
const auto &
id) {
81 return id.type == otherId.type;
83 if (it == m_identifiers.end()) {
84 m_identifiers.push_back(otherId);
85 }
else if ((*it).value.isEmpty()) {
86 (*it).value = otherId.value;
94 for (
const auto &
id : m_identifiers) {
95 obj.
insert(
id.type,
id.value);
100void IdentifierSet::fromJson(
const QJsonObject &ids)
102 m_identifiers.clear();
103 m_identifiers.reserve(ids.
size());
104 for (
auto it = ids.
begin(); it != ids.
end(); ++it) {
105 m_identifiers.emplace_back(it.key(), it.value().toString());
Query operations and data types for accessing realtime public transport information from online servi...
iterator insert(QLatin1StringView key, const QJsonValue &value)
qsizetype size() const const
void reserve(qsizetype size)