Commit 8283ad88 authored by Volker Krause's avatar Volker Krause
Browse files

Port AlphaId/IataCode to QStringView

parent cf21b1d0
......@@ -8,7 +8,7 @@
using namespace KItinerary;
uint16_t KnowledgeDb::Internal::alphaIdFromString(const QString &s, int size)
uint16_t KnowledgeDb::Internal::alphaIdFromString(QStringView s, int size)
{
uint16_t res = {};
if (size != s.size()) {
......
......@@ -10,6 +10,7 @@
#include <QDebug>
#include <QString>
#include <QStringView>
#include <cstdint>
#include <functional>
......@@ -20,7 +21,7 @@ namespace KnowledgeDb {
///@cond internal
namespace Internal {
// "private" API for the template code below
KITINERARY_EXPORT uint16_t alphaIdFromString(const QString &s, int size);
KITINERARY_EXPORT uint16_t alphaIdFromString(QStringView s, int size);
KITINERARY_EXPORT QString alphaIdToString(uint16_t id, int size);
}
///@endcond
......@@ -46,13 +47,13 @@ public:
}
}
/** Create identifier from a QString. */
inline explicit AlphaId(const QString &s)
inline explicit AlphaId(QStringView s)
{
static_assert(sizeof(decltype(Internal::alphaIdFromString(s, N))) <= sizeof(T), "alphaIdFromString truncates result");
m_id = Internal::alphaIdFromString(s, N);
}
/** Returns @c true if this is a valid idenfier. */
/** Returns @c true if this is a valid identifier. */
inline constexpr bool isValid() const
{
return m_id != 0;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment