20#ifndef LIBREPCB_CORE_ATTRIBUTEKEY_H
21#define LIBREPCB_CORE_ATTRIBUTEKEY_H
26#include "../qtcompat.h"
27#include "../serialization/sexpression.h"
28#include "../utils/toolbox.h"
30#include <type_safe/constrained_type.hpp>
45 userInput, QRegularExpression(
"[^_0-9A-Z]"),
true,
false,
true,
"_", 40);
49 template <
typename Value,
typename Predicate>
50 static constexpr auto verify(Value&& val,
const Predicate& p) ->
51 typename std::decay<Value>::type {
53 ? std::forward<Value>(val)
56 QString(QCoreApplication::translate(
57 "AttributeKey",
"Invalid attribute key: '%1'"))
59 std::forward<Value>(val));
65 return QRegularExpression(
"\\A[_0-9A-Z]{1,40}\\z")
66 .match(value, 0, QRegularExpression::PartialPreferCompleteMatch)
115 stream << QString(
"AttributeKey('%1')").arg(*obj);
uint Hash
Return type of Qt's qHash() function.
Definition: qtcompat.h:58
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:77
type_safe::constrained_type< QString, AttributeKeyConstraint, AttributeKeyVerifier > AttributeKey
Definition: attributekey.h:84
bool operator==(const AttributeKey &lhs, const QString &rhs) noexcept
Definition: attributekey.h:86
QtCompat::Hash qHash(const AttributeKey &key, QtCompat::Hash seed=0) noexcept
Definition: attributekey.h:119
std::unique_ptr< SExpression > serialize(const AttributeKey &obj)
Definition: attributekey.h:100
static QString cleanAttributeKey(const QString &userInput) noexcept
Definition: attributekey.h:43
bool operator!=(const AttributeKey &lhs, const QString &rhs) noexcept
Definition: attributekey.h:92
AttributeKey deserialize(const SExpression &node)
Definition: attributekey.h:105
QDataStream & operator<<(QDataStream &stream, const AttributeKey &obj)
Definition: attributekey.h:109
Definition: attributekey.h:63
bool operator()(const QString &value) const noexcept
Definition: attributekey.h:64
Definition: attributekey.h:48
static constexpr auto verify(Value &&val, const Predicate &p) -> typename std::decay< Value >::type
Definition: attributekey.h:50