20#ifndef LIBREPCB_CORE_COMPONENTSYMBOLVARIANTITEMSUFFIX_H
21#define LIBREPCB_CORE_COMPONENTSYMBOLVARIANTITEMSUFFIX_H
26#include "../../exceptions.h"
27#include "../../serialization/sexpression.h"
28#include "../../utils/toolbox.h"
30#include <type_safe/constrained_type.hpp>
46 template <
typename Value,
typename Predicate>
47 static constexpr auto verify(Value&& val,
const Predicate& p) ->
48 typename std::decay<Value>::type {
49 return p(val) ? std::forward<Value>(val)
52 QString(QCoreApplication::translate(
53 "ComponentSymbolVariantItemSuffix",
54 "Invalid component symbol suffix: '%1'"))
56 std::forward<Value>(val));
62 return QRegularExpression(
"\\A[0-9a-zA-Z_]{0,16}\\z")
63 .match(value, 0, QRegularExpression::PartialPreferCompleteMatch)
81 type_safe::constrained_type<QString,
86 const QString& rhs)
noexcept {
94 const QString& rhs)
noexcept {
102 const QString& rhs)
noexcept {
129 stream << QString(
"ComponentSymbolVariantItemSuffix('%1')").arg(*obj);
134 std::size_t seed = 0) noexcept {
135 return ::qHash(*key, seed);
139 const QString& userInput)
noexcept {
141 QRegularExpression(
"[^0-9a-zA-Z_]"),
142 true,
false,
false,
"_", 16);
145inline static std::optional<ComponentSymbolVariantItemSuffix>
149 : std::optional<ComponentSymbolVariantItemSuffix>();
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
std::size_t qHash(const AttributeKey &key, std::size_t seed=0) noexcept
Definition attributekey.h:113
bool operator==(const AttributeKey &lhs, const QString &rhs) noexcept
Definition attributekey.h:80
std::unique_ptr< SExpression > serialize(const AttributeKey &obj)
Definition attributekey.h:94
bool operator!=(const AttributeKey &lhs, const QString &rhs) noexcept
Definition attributekey.h:86
static std::optional< ComponentSymbolVariantItemSuffix > parseComponentSymbolVariantItemSuffix(const QString &suffix) noexcept
Definition componentsymbolvariantitemsuffix.h:146
static QString cleanComponentSymbolVariantItemSuffix(const QString &userInput) noexcept
Definition componentsymbolvariantitemsuffix.h:138
AttributeKey deserialize(const SExpression &node)
Definition attributekey.h:99
QDataStream & operator<<(QDataStream &stream, const AttributeKey &obj)
Definition attributekey.h:103
QString operator%(const ComponentPrefix &lhs, const QString &rhs) noexcept
Definition componentprefix.h:99
type_safe::constrained_type< QString, ComponentSymbolVariantItemSuffixConstraint, ComponentSymbolVariantItemSuffixVerifier > ComponentSymbolVariantItemSuffix
Definition componentsymbolvariantitemsuffix.h:83
Definition componentsymbolvariantitemsuffix.h:60
bool operator()(const QString &value) const noexcept
Definition componentsymbolvariantitemsuffix.h:61
Definition componentsymbolvariantitemsuffix.h:45
static constexpr auto verify(Value &&val, const Predicate &p) -> typename std::decay< Value >::type
Definition componentsymbolvariantitemsuffix.h:47