Vous avez reçu un message "Your GitLab account has been locked ..." ? Pas d'inquiétude : lisez cet article https://docs.gricad-pages.univ-grenoble-alpes.fr/help/unlock/

Commit 905e024f authored by EXT Arnaud Clère's avatar EXT Arnaud Clère
Browse files

cosmetic changes

parent af60ff71
......@@ -169,36 +169,39 @@ public:
operator bool() const noexcept { return outer.operator bool(); } //!< Drives QBind<T>::bind() traversal
TResult* operator->() noexcept { return outer.operator ->(); }
/**/ Val<T_> meta (QIdentifierLiteral& n, QAsciiData& m) { outer->_meta(n,m); return std::move(*this); }
/**/ Seq<T_> sequence(quint32* s=nullptr) { return outer->_sequence (s) ? Seq<T_>(std::move(outer)) : Seq<T_>(); }
/**/ Rec<T_> record (quint32* s=nullptr) { return outer->_record (s) ? Rec<T_>(std::move(outer)) : Rec<T_>(); }
/**/ T_ null ( ) { return outer->_null ( ) ? std::move(outer) : T_ (); }
/**/ T_ any ( ) { return outer->_any ( ) ? std::move(outer) : T_ (); }
/**/ T_ bind ( const char* u) { return bind(QUtf8DataView(u)); }
/**/ T_ bind ( QUtf8DataView u) { return outer->_bind (u) ? std::move(outer) : T_ (); }
/**/ T_ bind ( QAsciiDataView a) { return outer->_bind (a) ? std::move(outer) : T_ (); }
/**/ T_ bind ( QLatin1String l) { return outer->_bind (l) ? std::move(outer) : T_ (); }
/**/ T_ bind ( QStringView u) { return outer->_bind (u) ? std::move(outer) : T_ (); }
template<typename T> T_ bind ( T&& t) { return outer->_bind(std::forward<T>(t)) ? std::move(outer) : T_ (); }
template<typename T> T_ bind (T& t, T&& defaultT) { return outer->_bind(QBindDefault<T>{t,defaultT})? std::move(outer) : T_ (); }
Val<T_> meta (QIdentifierLiteral& n, QAsciiData& m) { outer->_meta(n,m); return std::move(*this); }
Seq<T_> sequence(quint32* s=nullptr) { return outer->_sequence (s) ? Seq<T_>(std::move(outer)) : Seq<T_>(); }
Rec<T_> record (quint32* s=nullptr) { return outer->_record (s) ? Rec<T_>(std::move(outer)) : Rec<T_>(); }
/**/T_ null ( ) { return outer->_null ( ) ? std::move(outer) : T_ (); }
/**/T_ any ( ) { return outer->_any ( ) ? std::move(outer) : T_ (); }
/**/T_ bind ( const char* u) { return outer->_bind(QUtf8DataView(u)) ? std::move(outer) : T_ (); }
/**/T_ bind ( QUtf8DataView u) { return outer->_bind (u) ? std::move(outer) : T_ (); }
/**/T_ bind ( QAsciiDataView a) { return outer->_bind (a) ? std::move(outer) : T_ (); }
/**/T_ bind ( QLatin1String l) { return outer->_bind (l) ? std::move(outer) : T_ (); }
/**/T_ bind ( QStringView u) { return outer->_bind (u) ? std::move(outer) : T_ (); }
template<typename T> T_ bind ( T&& t) { return outer->_bind(std::forward<T>(t )) ? std::move(outer) : T_(); }
template<typename T> T_ bind (T& t, T&& defaultT) { return outer->_bind(QBindDefault<T>{t,defaultT}) ? std::move(outer) : T_(); }
// Custom bind support
/**/ T_ with ( QBindLambda customBind) { return customBind( std::move(unsafeThis())) ? std::move(outer) : T_(); }
template<typename T> T_ with (T& t, QBindFunction<T> customBind) { return customBind(t, std::move(unsafeThis())) ? std::move(outer) : T_(); }
// Literal metadata support
Val<T_> meta( QIdentifierLiteral&& n, QAsciiData&& m) { QIdentifierLiteral nref=n; QAsciiData mref=m; return meta(nref, mref); }
Val<T_> meta(const QIdentifierLiteral& n, QAsciiData&& m) { QIdentifierLiteral nref=n; QAsciiData mref=m; return meta(nref, mref); }
Val<T_> meta(const QIdentifierLiteral& n, const char* m) { QIdentifierLiteral nref=n; QAsciiData mref=QAsciiData(m); return meta(nref, mref); }
Val<T_> meta( QIdentifierLiteral&& n, const QAsciiData& m) { QIdentifierLiteral nref=n; QAsciiData mref=m; return meta(nref, mref); }
Val<T_> meta(const char* n, const char* m) { return meta(QIdentifierLiteral(n),QAsciiData(m)); }
Seq<T_> sequence( quint32 s) { return sequence(&s); }
Rec<T_> record ( quint32 s) { return record (&s); }
Val<T_> meta( QIdentifierLiteral&& n, QAsciiData&& m) { QIdentifierLiteral nref=n; QAsciiData mref= m ; return meta(nref, mref); }
Val<T_> meta(const QIdentifierLiteral& n, QAsciiData&& m) { QIdentifierLiteral nref=n; QAsciiData mref= m ; return meta(nref, mref); }
Val<T_> meta(const QIdentifierLiteral& n, const char* m) { QIdentifierLiteral nref=n; QAsciiData mref=QAsciiData(m); return meta(nref, mref); }
Val<T_> meta( QIdentifierLiteral&& n, const QAsciiData& m) { QIdentifierLiteral nref=n; QAsciiData mref= m ; return meta(nref, mref); }
Seq<T_> sequence(quint32 s) { return sequence(&s); }
Rec<T_> record (quint32 s) { return record (&s); }
Rec<T_> record (const char* n) { return meta(qmName,QAsciiData(n)).record(); }
// Shortcuts
template<typename T> Seq<T_> operator<<( T&& t) { return sequence().bind(std::forward<T>(t)); } // stream compatible
/**/ Rec<T_> record(const char* n) { return meta(qmName,QAsciiData(n)).record(); }
private:
Val<TResult> unsafeThis() noexcept { return Val<TResult>(outer->_unsafeCopy()); }
......@@ -217,21 +220,23 @@ public:
operator bool() const noexcept { return outer.operator bool(); } //!< Drives QBind<T>::bind() traversal
TResult* operator->() noexcept { return outer.operator ->(); }
operator TResult() { return out(); /* calls T_::operator TResult() if T_ != TResult */ }
operator TResult() { return out(); /* calls T_::operator TResult() if T_ != TResult */ }
/**/ T_ out() { return outer-> _out() ? std::move(outer) : T_ (); }
Val<Seq<T_>> item() { return outer->_item() ? Val<Seq<T_>>(std::move(*this)) : Val<Seq<T_>>(); }
// Shortcuts
/**/ Seq<Seq<T_>> sequence(quint32* s=nullptr) { return item().sequence (s) ; }
/**/ Rec<Seq<T_>> record (quint32* s=nullptr) { return item().record (s) ; }
/**/ Seq<T_> null ( ) { return item().null ( ) ; }
/**/ Seq<T_> any ( ) { return item().any ( ) ; }
/**/ Seq<T_> bind ( const char* u) { return bind(QUtf8DataView(u)); }
/**/ Seq<T_> bind ( QUtf8DataView u) { return item().bind (u) ; }
/**/ Seq<T_> bind ( QAsciiDataView a) { return item().bind (a) ; }
/**/ Seq<T_> bind ( QLatin1String l) { return item().bind (l) ; }
/**/ Seq<T_> bind ( QStringView u) { return item().bind (u) ; }
Seq<Seq<T_>> sequence(quint32* s=nullptr) { return item().sequence (s) ; }
Rec<Seq<T_>> record (quint32* s=nullptr) { return item().record (s) ; }
/**/Seq<T_> null ( ) { return item().null ( ) ; }
/**/Seq<T_> any ( ) { return item().any ( ) ; }
/**/Seq<T_> bind ( const char* u) { return item().bind(QUtf8DataView(u)); }
/**/Seq<T_> bind ( QUtf8DataView u) { return item().bind (u) ; }
/**/Seq<T_> bind ( QAsciiDataView a) { return item().bind (a) ; }
/**/Seq<T_> bind ( QLatin1String l) { return item().bind (l) ; }
/**/Seq<T_> bind ( QStringView u) { return item().bind (u) ; }
template<typename T> Seq<T_> bind ( T&& t) { return item().bind(std::forward<T>(t)); }
template<typename T> Rec<T_> bind (T& t, T&& defaultT) { return item().bind(t,std::forward<T>(defaultT)); }
......@@ -241,8 +246,8 @@ public:
template<class Ts> Seq<T_> forEach (Ts& ts, TResult(*)( typename Ts::value_type&, Val<TResult>&&)
, bool (*)(const typename Ts::value_type&) = [](const typename Ts::value_type&) { return true; });
// Stream compatible shortcut
template<typename T> Seq<T_> operator<<(T&& t) { return item().bind(std::forward<T>(t)); }
// Shortcut
template<typename T> Seq<T_> operator<<(T&& t) { return item().bind(std::forward<T>(t)); } // stream compatible
private:
template<typename T, class TResult, typename TEnabledIf> friend struct QBind;
Val<TResult> unsafeItem() noexcept { return outer->_item() ? Val<TResult>(outer->_unsafeCopy()) : Val<TResult>(); }
......@@ -270,20 +275,22 @@ public:
Val<Rec<T_>> item(const char* n) { return outer->_item(QIdentifierLiteral(n)) ? Val<Rec<T_>>(std::move(*this)) : Val<Rec<T_>>(); }
// Shortcuts
/**/ Seq<Rec<T_>> sequence(const char* n, quint32* s=nullptr) { return item(n).sequence (s) ; }
/**/ Rec<Rec<T_>> record (const char* n, quint32* s=nullptr) { return item(n).record (s) ; }
/**/ Rec<T_> null (const char* n ) { return item(n).null ( ) ; }
/**/ Rec<T_> bind (const char* n, const char* u) { return item(n).bind( QUtf8DataView(u)); }
/**/ Rec<T_> bind (const char* n, QUtf8DataView u) { return item(n).bind (u) ; }
/**/ Rec<T_> bind (const char* n, QAsciiDataView a) { return item(n).bind (a) ; }
/**/ Rec<T_> bind (const char* n, QLatin1String l) { return item(n).bind (l) ; }
/**/ Rec<T_> bind (const char* n, QStringView u) { return item(n).bind (u) ; }
template<typename T> Rec<T_> bind (const char* n, T&& t) { return item(n).bind(std::forward<T>(t)); }
template<typename T> Rec<T_> bind (const char* n, T& t, T&& defaultT) { return item(n).bind(t,std::forward<T>(defaultT)); }
Seq<Rec<T_>> sequence(const char* n, quint32* s=nullptr) { return item(n).sequence (s) ; }
Rec<Rec<T_>> record (const char* n, quint32* s=nullptr) { return item(n).record (s) ; }
/**/Rec<T_> null (const char* n ) { return item(n).null ( ) ; }
/**/Rec<T_> bind (const char* n, const char* u) { return item(n).bind(QUtf8DataView(u)); }
/**/Rec<T_> bind (const char* n, QUtf8DataView u) { return item(n).bind (u) ; }
/**/Rec<T_> bind (const char* n, QAsciiDataView a) { return item(n).bind (a) ; }
/**/Rec<T_> bind (const char* n, QLatin1String l) { return item(n).bind (l) ; }
/**/Rec<T_> bind (const char* n, QStringView u) { return item(n).bind (u) ; }
template<typename T> Rec<T_> bind (const char* n, T&& t) { return item(n).bind( std::forward<T>( t)); }
template<typename T> Rec<T_> bind (const char* n, T& t, T&& defaultT) { return item(n).bind(t, std::forward<T>(defaultT)); }
// Custom bind support
/**/ Rec<T_> with (const char* n, QBindLambda customBind) { return item(n).with ( customBind); }
template<typename T> Rec<T_> with (const char* n, T& t, QBindFunction<T> customBind) { return item(n).bind (t, customBind); }
/**/ Rec<T_> with (const char* n, QBindLambda customBind) { return item(n).with( customBind); }
template<typename T> Rec<T_> with (const char* n, T& t, QBindFunction<T> customBind) { return item(n).bind(t, customBind); }
private:
template<typename T, class TResult, typename TEnabledIf> friend struct QBind;
Val<TResult> unsafeItem(QIdentifier& n) noexcept { return outer->_item(n) ? Val<TResult>(outer._unsafeCopy()) : Val<TResult>(); }
......@@ -797,8 +804,8 @@ class QBindable
std::function<TResult(Val<TResult>&&)> f;
public:
QBindable() {}
template<typename T> QBindable(T& t) : f( /*captured T ref */[&t] (Val<TResult>&& v) { return v.bind(t); } ) {}
template<typename T> QBindable(T&& t) : f( /*captured T copy*/[ t] (Val<TResult>&& v) { return v.bind(t); } ) {}
template<typename T> QBindable(T& t) : f(/*captured T ref */[&t] (Val<TResult>&& v) { return v.bind(t); } ) {}
template<typename T> QBindable(T&& t) : f(/*captured T copy*/[ t] (Val<TResult>&& v) { return v.bind(t); } ) {}
TResult bind(Val<TResult>&& v) { return f(std::move(v)); }
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment