// Generic fluent interface for traversing and processing structured value types (serialize, deserialize, construct generic in-memory data structures, etc...)
// Generic fluent interface for traversing structured values and processing them along the way:
// - serializing, deserializing
// - constructing generic in-memory data structures
// - etc...
// See Person::bind() definition below for an example
enumBindMode{Read,Write};//!< drives QBind<TResult,T>() traversal and processing (the design would support others like Append)
template<typenameT>Seq<T_>bind(constT&t){if(itemValue().bind(t))returnstd::move(*this);returnSeq<T_>();}// binding Val<T_> instead of Val<Seq<T_>> requires less code generation
Val<T_>itemValue(){if(Q_LIKELY(m_out)&&m_out->_item()){T_scopedT(m_out);returnstd::move(Val<T_>(std::move(scopedT)));}returnVal<T_>();}// the m_out copy must be scoped and will be invalid when the original is destroyed
T_m_out=T_();
};
//! Base class for TResult classes that require a single heap allocation (and lock) but:
//! - are simple to implement and de facto pimpled
//! - provide users with direct access to the fluent interface
//! Base class for TResult classes that require a single heap allocation (and lock)
//! but are simple to implement and de facto pimpled
static_assert(TSrcResult::Mode==Read,"cannot read from TSrcResult");
static_assert(TDst::Mode==Write,"cannot write to TDst");
Seq<TSrcResult>srcSeq;Seq<TDst>dstSeq;
if(srcSeq=src.sequence()){
/**/dstSeq=dst.sequence();
Val<TSrcResult>srcVal;Val<TDst>dstVal;
while(srcVal=srcSeq.itemValue()){// using item()'s Val<Seq<TSrcResult> would cause an infinite compiler loop to generate corresponding QBind<Val<Seq<Seq<...>>,_> functions