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);
QDataStream & operator<<(QDataStream &stream, const AttributeKey &obj)
Definition: attributekey.h:108
Definition: occmodel.cpp:76
Definition: attributekey.h:47
type_safe::constrained_type< QString, AttributeKeyConstraint, AttributeKeyVerifier > AttributeKey
Definition: attributekey.h:83
Definition: attributekey.h:62
static constexpr auto verify(Value &&val, const Predicate &p) -> typename std::decay< Value >::type
Definition: attributekey.h:49
static QString cleanAttributeKey(const QString &userInput) noexcept
Definition: attributekey.h:42
bool operator()(const QString &value) const noexcept
Definition: attributekey.h:63
static SExpression createString(const QString &string)
Definition: sexpression.cpp:380
The RuntimeError class.
Definition: exceptions.h:216
AttributeKey deserialize(const SExpression &node)
Definition: attributekey.h:104
bool operator==(const AttributeKey &lhs, const QString &rhs) noexcept
Definition: attributekey.h:85
bool operator!=(const AttributeKey &lhs, const QString &rhs) noexcept
Definition: attributekey.h:91
SExpression serialize(const AttributeKey &obj)
Definition: attributekey.h:99
const QString & getValue() const
Definition: sexpression.cpp:71
The SExpression class.
Definition: sexpression.h:66
uint qHash(const AttributeKey &key, uint seed=0) noexcept
Definition: attributekey.h:118