20#ifndef LIBREPCB_CORE_COMPONENTPREFIX_H
21#define LIBREPCB_CORE_COMPONENTPREFIX_H
26#include "../../exceptions.h"
27#include "../../serialization/sexpression.h"
28#include "../../utils/toolbox.h"
30#include <type_safe/constrained_type.hpp>
45 userInput, QRegularExpression(
"[^a-zA-Z_]"),
true,
false,
false,
"_", 16);
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 "ComponentPrefix",
"Invalid component prefix: '%1'"))
59 std::forward<Value>(val));
65 return QRegularExpression(
"\\A[a-zA-Z_]{0,16}\\z")
66 .match(value, 0, QRegularExpression::PartialPreferCompleteMatch)
87 const QString& rhs)
noexcept {
95 const QString& rhs)
noexcept {
100 return lhs != (*rhs);
103 const QString& rhs)
noexcept {
128 stream << QString(
"ComponentPrefix('%1')").arg(*obj);
133 std::size_t seed = 0) noexcept {
134 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
static QString cleanComponentPrefix(const QString &userInput) noexcept
Definition componentprefix.h:43
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
type_safe::constrained_type< QString, ComponentPrefixConstraint, ComponentPrefixVerifier > ComponentPrefix
Definition componentprefix.h:84
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
QString operator%(const ComponentPrefix &lhs, const QString &rhs) noexcept
Definition componentprefix.h:102
Definition componentprefix.h:63
bool operator()(const QString &value) const noexcept
Definition componentprefix.h:64
Definition componentprefix.h:48
static constexpr auto verify(Value &&val, const Predicate &p) -> typename std::decay< Value >::type
Definition componentprefix.h:50