20#ifndef LIBREPCB_CORE_FILEPROOFNAME_H
21#define LIBREPCB_CORE_FILEPROOFNAME_H
26#include "../exceptions.h"
27#include "../serialization/sexpression.h"
28#include "../utils/toolbox.h"
30#include <type_safe/constrained_type.hpp>
45 QRegularExpression(
"[^-a-zA-Z0-9_+().]"),
46 true,
false,
false,
"-", 20);
50 template <
typename Value,
typename Predicate>
51 static constexpr auto verify(Value&& val,
const Predicate& p) ->
52 typename std::decay<Value>::type {
53 return p(val) ? std::forward<Value>(val)
56 QString(QCoreApplication::translate(
57 "FileProofName",
"Invalid name: '%1'"))
59 std::forward<Value>(val));
64 static QRegularExpression
regex() noexcept {
65 return QRegularExpression(
"\\A[-a-zA-Z0-9_+().]{1,20}\\z");
70 .match(value, 0, QRegularExpression::PartialPreferCompleteMatch)
100 return lhs != (*rhs);
103 const QString& rhs)
noexcept {
131 stream << QString(
"FileProofName('%1')").arg(*obj);
136 std::size_t seed = 0) noexcept {
137 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
bool operator==(const AttributeKey &lhs, const QString &rhs) noexcept
Definition attributekey.h:85
static QString cleanFileProofName(const QString &userInput) noexcept
Definition fileproofname.h:43
std::unique_ptr< SExpression > serialize(const AttributeKey &obj)
Definition attributekey.h:99
bool operator!=(const AttributeKey &lhs, const QString &rhs) noexcept
Definition attributekey.h:91
type_safe::constrained_type< QString, FileProofNameConstraint, FileProofNameVerifier > FileProofName
Definition fileproofname.h:88
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 fileproofname.h:63
bool operator()(const QString &value) const noexcept
Definition fileproofname.h:68
static QRegularExpression regex() noexcept
Definition fileproofname.h:64
Definition fileproofname.h:49
static constexpr auto verify(Value &&val, const Predicate &p) -> typename std::decay< Value >::type
Definition fileproofname.h:51