20#ifndef LIBREPCB_CORE_ATTRIBUTEKEY_H
21#define LIBREPCB_CORE_ATTRIBUTEKEY_H
26#include "../serialization/sexpression.h"
27#include "../utils/toolbox.h"
29#include <type_safe/constrained_type.hpp>
44 userInput, QRegularExpression(
"[^_0-9A-Z]"),
true,
false,
true,
"_", 40);
48 template <
typename Value,
typename Predicate>
49 static constexpr auto verify(Value&& val,
const Predicate& p) ->
50 typename std::decay<Value>::type {
52 ? std::forward<Value>(val)
55 QString(QCoreApplication::translate(
56 "AttributeKey",
"Invalid attribute key: '%1'"))
58 std::forward<Value>(val));
64 return QRegularExpression(
"\\A[_0-9A-Z]{1,40}\\z")
65 .match(value, 0, QRegularExpression::PartialPreferCompleteMatch)
114 stream << QString(
"AttributeKey('%1')").arg(*obj);
119 std::size_t seed = 0) noexcept {
120 return ::qHash(*key, seed);
The RuntimeError class.
Definition exceptions.h:218
The SExpression class.
Definition sexpression.h:69
static std::unique_ptr< SExpression > createString(const QString &string)
Definition sexpression.cpp:407
const QString & getValue() const
Definition sexpression.cpp:71
Definition occmodel.cpp:76
std::size_t qHash(const AttributeKey &key, std::size_t seed=0) noexcept
Definition attributekey.h:118
type_safe::constrained_type< QString, AttributeKeyConstraint, AttributeKeyVerifier > AttributeKey
Definition attributekey.h:83
bool operator==(const AttributeKey &lhs, const QString &rhs) noexcept
Definition attributekey.h:85
std::unique_ptr< SExpression > serialize(const AttributeKey &obj)
Definition attributekey.h:99
static QString cleanAttributeKey(const QString &userInput) noexcept
Definition attributekey.h:42
bool operator!=(const AttributeKey &lhs, const QString &rhs) noexcept
Definition attributekey.h:91
AttributeKey deserialize(const SExpression &node)
Definition attributekey.h:104
QDataStream & operator<<(QDataStream &stream, const AttributeKey &obj)
Definition attributekey.h:108
Definition attributekey.h:62
bool operator()(const QString &value) const noexcept
Definition attributekey.h:63
Definition attributekey.h:47
static constexpr auto verify(Value &&val, const Predicate &p) -> typename std::decay< Value >::type
Definition attributekey.h:49