typename std::enable_if<HasFunc_FastWriteTo<T>::value, void>::type FastWriteSwitch( ByteBuffer& b, T const& v ) { #if ENABLE_BYTEBUFFER_PTR_SUPPORT if( b.ptrStore ) { auto rtv = b.ptrStore->Insert( (void*)&v, (uint)b.dataLen ); b.VarWrite( rtv.first->value ); if( !rtv.second ) return; } #endif v.FastWriteTo( b ); };
void List<T>::WriteTo( ByteBuffer& bb ) const { bb.VarWrite( (uint)size ); if( !std::is_pointer<T>::value && std::is_pod<T>::value ) { if( !size ) return; bb.Write( (char*)buf, size * sizeof( T ) ); return; } for( int i = 0; i < size; ++i ) { bb.Write( buf[ i ] ); } }
void String::WriteTo( ByteBuffer& bb ) const { bb.VarWrite( (uint)dataLen ); if( !dataLen ) return; bb.Write( buf, dataLen ); }