20#ifndef LIBREPCB_CORE_SIMPLESTRING_H
21#define LIBREPCB_CORE_SIMPLESTRING_H
26#include "../exceptions.h"
27#include "../qtcompat.h"
28#include "../serialization/sexpression.h"
30#include <type_safe/constrained_type.hpp>
44 template <
typename Value,
typename Predicate>
45 static constexpr auto verify(Value&& val,
const Predicate& p) ->
46 typename std::decay<Value>::type {
48 ? std::forward<Value>(val)
50 QString(QCoreApplication::translate(
51 "SimpleString",
"Invalid name: '%1'"))
53 std::forward<Value>(val));
59 if (value != value.trimmed())
return false;
60 foreach (
const QChar& c, value) {
61 if (!c.isPrint())
return false;
106 const QString& userInput)
noexcept {
107 QString ret = userInput.simplified();
108 for (
int i = ret.length() - 1; i >= 0; --i) {
109 if (!ret[i].isPrint()) {
132 stream << QString(
"SimpleString('%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
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
QtCompat::Hash qHash(const SimpleString &key, QtCompat::Hash seed=0) noexcept
Definition: simplestring.h:136
bool operator!=(const AttributeKey &lhs, const QString &rhs) noexcept
Definition: attributekey.h:92
static SimpleString cleanSimpleString(const QString &userInput) noexcept
Definition: simplestring.h:105
type_safe::constrained_type< QString, SimpleStringConstraint, SimpleStringVerifier > SimpleString
Definition: simplestring.h:80
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: simplestring.h:57
bool operator()(const QString &value) const noexcept
Definition: simplestring.h:58
Definition: simplestring.h:43
static constexpr auto verify(Value &&val, const Predicate &p) -> typename std::decay< Value >::type
Definition: simplestring.h:45