Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PIM
KItinerary
Commits
8283ad88
Commit
8283ad88
authored
Aug 28, 2021
by
Volker Krause
Browse files
Port AlphaId/IataCode to QStringView
parent
cf21b1d0
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/lib/knowledgedb/alphaid.cpp
View file @
8283ad88
...
...
@@ -8,7 +8,7 @@
using
namespace
KItinerary
;
uint16_t
KnowledgeDb
::
Internal
::
alphaIdFromString
(
const
QString
&
s
,
int
size
)
uint16_t
KnowledgeDb
::
Internal
::
alphaIdFromString
(
QString
View
s
,
int
size
)
{
uint16_t
res
=
{};
if
(
size
!=
s
.
size
())
{
...
...
src/lib/knowledgedb/alphaid.h
View file @
8283ad88
...
...
@@ -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
(
QString
View
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
(
QString
View
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 iden
ti
fier. */
inline
constexpr
bool
isValid
()
const
{
return
m_id
!=
0
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment