9#include "kitinerary_export.h"
19namespace KnowledgeDb {
24 KITINERARY_EXPORT uint32_t alphaIdFromString(
QStringView s,
int size);
25 KITINERARY_EXPORT
QString alphaIdToString(uint32_t
id,
int size);
33template <
typename T,
int N>
35 static_assert((N * 5) < (
sizeof(T) * 8),
"Not enough space to hold identifier.");
37 inline constexpr AlphaId() =
default;
39 inline explicit constexpr AlphaId(
const char s[N])
41 for (
int i = 0; i < N; ++i) {
42 if (s[i] <
'A' || s[i] >
'Z') {
46 m_id |= (s[i] -
'@') << (5 * (N-i-1));
52 m_id = Internal::alphaIdFromString(s, N);
63 return m_id < rhs.m_id;
65 inline constexpr bool operator==(AlphaId<T, N> other)
const
67 return m_id == other.m_id;
69 inline constexpr bool operator!=(AlphaId<T, N> other)
const
71 return m_id != other.m_id;
77 return Internal::alphaIdToString(m_id, N);
81 inline constexpr T
value()
const
93template <
typename T,
int N>
101template <
typename T,
int N>
struct hash<
KItinerary::KnowledgeDb::AlphaId<T, N>>
104 typedef std::size_t result_type;
105 result_type operator()(argument_type
id)
const noexcept
107 return std::hash<T>()(
id.value());
Compact storage for fixed-size identifiers consisting out of uppercase latin letters,...
constexpr bool isValid() const
Returns true if this is a valid identifier.
constexpr T value() const
QString toString() const
Returns a string representation of this identifier.
constexpr AlphaId(const char s[N])
Create identifier from a literal.
AlphaId(QStringView s)
Create identifier from a QString.
KCALENDARCORE_EXPORT QDataStream & operator<<(QDataStream &out, const KCalendarCore::Alarm::Ptr &)
Classes for reservation/travel data models, data extraction and data augmentation.
QString toString(T &&object)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:28:48 by
doxygen 1.12.0 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.