20#ifndef LIBREPCB_CORE_COMPONENTPREFIX_H
21#define LIBREPCB_CORE_COMPONENTPREFIX_H
26#include "../../exceptions.h"
27#include "../../qtcompat.h"
28#include "../../serialization/sexpression.h"
29#include "../../utils/toolbox.h"
31#include <type_safe/constrained_type.hpp>
46 userInput, QRegularExpression(
"[^a-zA-Z_]"),
true,
false,
false,
"_", 16);
50 template <
typename Value,
typename Predicate>
51 static constexpr auto verify(Value&& val,
const Predicate& p) ->
52 typename std::decay<Value>::type {
54 ? std::forward<Value>(val)
57 QString(QCoreApplication::translate(
58 "ComponentPrefix",
"Invalid component prefix: '%1'"))
60 std::forward<Value>(val));
66 return QRegularExpression(
"\\A[a-zA-Z_]{0,16}\\z")
67 .match(value, 0, QRegularExpression::PartialPreferCompleteMatch)
88 const QString& rhs)
noexcept {
96 const QString& rhs)
noexcept {
101 return lhs != (*rhs);
104 const QString& rhs)
noexcept {
129 stream << QString(
"ComponentPrefix('%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
static QString cleanComponentPrefix(const QString &userInput) noexcept
Definition: componentprefix.h:44
bool operator==(const AttributeKey &lhs, const QString &rhs) noexcept
Definition: attributekey.h:86
QtCompat::Hash qHash(const ComponentPrefix &key, QtCompat::Hash seed=0) noexcept
Definition: componentprefix.h:133
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
type_safe::constrained_type< QString, ComponentPrefixConstraint, ComponentPrefixVerifier > ComponentPrefix
Definition: componentprefix.h:85
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
QString operator%(const ComponentPrefix &lhs, const QString &rhs) noexcept
Definition: componentprefix.h:103
Definition: componentprefix.h:64
bool operator()(const QString &value) const noexcept
Definition: componentprefix.h:65
Definition: componentprefix.h:49
static constexpr auto verify(Value &&val, const Predicate &p) -> typename std::decay< Value >::type
Definition: componentprefix.h:51