20#ifndef LIBREPCB_CORE_FILEPROOFNAME_H
21#define LIBREPCB_CORE_FILEPROOFNAME_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 QRegularExpression(
"[^-a-zA-Z0-9_+().]"),
47 true,
false,
false,
"-", 20);
51 template <
typename Value,
typename Predicate>
52 static constexpr auto verify(Value&& val,
const Predicate& p) ->
53 typename std::decay<Value>::type {
54 return p(val) ? std::forward<Value>(val)
57 QString(QCoreApplication::translate(
58 "FileProofName",
"Invalid name: '%1'"))
60 std::forward<Value>(val));
65 static QRegularExpression
regex() noexcept {
66 return QRegularExpression(
"\\A[-a-zA-Z0-9_+().]{1,20}\\z");
71 .match(value, 0, QRegularExpression::PartialPreferCompleteMatch)
101 return lhs != (*rhs);
104 const QString& rhs)
noexcept {
132 stream << QString(
"FileProofName('%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
bool operator==(const AttributeKey &lhs, const QString &rhs) noexcept
Definition: attributekey.h:86
static QString cleanFileProofName(const QString &userInput) noexcept
Definition: fileproofname.h:44
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
bool operator!=(const AttributeKey &lhs, const QString &rhs) noexcept
Definition: attributekey.h:92
type_safe::constrained_type< QString, FileProofNameConstraint, FileProofNameVerifier > FileProofName
Definition: fileproofname.h:89
QtCompat::Hash qHash(const FileProofName &key, QtCompat::Hash seed=0) noexcept
Definition: fileproofname.h:136
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: fileproofname.h:64
bool operator()(const QString &value) const noexcept
Definition: fileproofname.h:69
static QRegularExpression regex() noexcept
Definition: fileproofname.h:65
Definition: fileproofname.h:50
static constexpr auto verify(Value &&val, const Predicate &p) -> typename std::decay< Value >::type
Definition: fileproofname.h:52