20 #ifndef LIBREPCB_LIBRARY_COMPONENTPREFIX_H
21 #define LIBREPCB_LIBRARY_COMPONENTPREFIX_H
27 #include <type_safe/constrained_type.hpp>
42 template <
typename Value,
typename Predicate>
43 static constexpr
auto verify(Value&& val,
const Predicate& p) ->
44 typename std::decay<Value>::type {
45 return p(val) ? std::forward<Value>(val)
48 QString(QApplication::translate(
50 "Invalid component prefix: '%1'"))
52 std::forward<Value>(val));
58 return QRegularExpression(
"^[a-zA-Z_]{0,16}$")
59 .match(value, 0, QRegularExpression::PartialPreferCompleteMatch)
82 const QString& rhs) noexcept {
90 const QString& rhs) noexcept {
98 const QString& rhs) noexcept {
125 stream << QString(
"ComponentPrefix('%1'')").arg(*obj);
139 #endif // LIBREPCB_LIBRARY_COMPONENTPREFIX_H
bool operator()(const QString &value) const noexcept
Definition: componentprefix.h:57
QDataStream & operator<<(QDataStream &stream, const AttributeKey &obj)
Definition: attributekey.h:109
uint qHash(const library::ComponentPrefix &key, uint seed=0) noexcept
Definition: componentprefix.h:129
Definition: componentprefix.h:41
const QString & getStringOrToken(bool throwIfEmpty=false) const
Definition: sexpression.cpp:101
SExpression serializeToSExpression(const HAlign &obj)
Definition: alignment.h:76
HAlign deserializeFromSExpression(const SExpression &sexpr, bool throwIfEmpty)
Definition: alignment.h:90
static SExpression createString(const QString &string)
Definition: sexpression.cpp:284
type_safe::constrained_type< QString, ComponentPrefixConstraint, ComponentPrefixVerifier > ComponentPrefix
Definition: componentprefix.h:77
The RuntimeError class.
Definition: exceptions.h:219
QString operator%(const CircuitIdentifier &lhs, const QString &rhs) noexcept
Definition: circuitidentifier.h:107
Definition: componentprefix.h:56
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
static constexpr auto verify(Value &&val, const Predicate &p) -> typename std::decay< Value >::type
Definition: componentprefix.h:43
The SExpression class.
Definition: sexpression.h:57
uint qHash(const AttributeKey &key, uint seed=0) noexcept
Definition: attributekey.h:119