Prison
13class Prison::MeCardPrivate
20 bool operator<(QStringView other)
const;
22 std::vector<Element> elements;
25bool MeCardPrivate::Element::operator<(
QStringView other)
const
31 : d(new MeCardPrivate())
36 : d(std::move(other.d))
43 std::swap(d, other.d);
52 if (idx <= 0 || idx >= data.
size() - 1) {
60 while (remaining.size() > 0) {
61 const auto keyIdx = remaining.indexOf(
QLatin1Char(
':'));
62 if (keyIdx <= 0 || keyIdx + 2 >= remaining.size()) {
67 auto elemIdx = keyIdx + 1;
69 for (; elemIdx < remaining.size() - 1; ++elemIdx) {
70 auto c = remaining.at(elemIdx);
71 if (elemIdx == (keyIdx + 1) && c ==
QLatin1Char(
'"')) {
83 c = remaining.at(elemIdx);
88 const auto key = remaining.left(keyIdx);
89 auto it = std::lower_bound(m.d->elements.begin(), m.d->elements.end(), key);
90 if (it == m.d->elements.end()) {
91 m.d->elements.push_back(MeCardPrivate::Element());
92 it = std::prev(m.d->elements.end());
93 }
else if ((*it).key != key) {
94 it = m.d->elements.insert(it, MeCardPrivate::Element());
97 (*it).values.push_back(
value);
99 remaining = remaining.mid(elemIdx + 1);
102 if (m.d->elements.empty()) {
111 return d->header.toString();
121 const auto it = std::lower_bound(d->elements.begin(), d->elements.end(), key);
122 if (it != d->elements.end() && (*it).key == key && (*it).values.
size() == 1) {
123 return (*it).values.at(0);
130 const auto it = std::lower_bound(d->elements.begin(), d->elements.end(), key);
131 if (it != d->elements.end() && (*it).key == key) {
140 for (
const auto &element : std::as_const(d->elements)) {
141 if (element.values.size() > 1) {
142 map.insert(element.key.toString(), element.values);
144 map.insert(element.key.toString(), element.values.at(0));
static std::optional< MeCard > parse(const QString &data)
Parse the given string.
QStringView headerView() const
Get the MeCard header as a string view.
QVariantMap toVariantMap() const
Get the parsed data as QVariantMap.
QStringList values(QStringView key) const
Get the list of values for a given key.
MeCard & operator=(MeCard &&other) noexcept
Move assignment.
MeCard(MeCard &&other) noexcept
Move constructor.
QString value(QStringView key) const
Get the value for a given key.
QString header() const
Get the MeCard header.
Provides classes and methods for generating barcodes.
qsizetype indexOf(QChar ch, qsizetype from, Qt::CaseSensitivity cs) const const
qsizetype size() const const
QStringView left(qsizetype length) const const
QStringView mid(qsizetype start, qsizetype length) const const
qsizetype size() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 24 2025 11:50:16 by
doxygen 1.13.2 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.