Exemplo n.º 1
0
    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 );
    };
Exemplo n.º 2
0
 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 ] );
     }
 }
Exemplo n.º 3
0
 void String::WriteTo( ByteBuffer& bb ) const
 {
     bb.VarWrite( (uint)dataLen );
     if( !dataLen ) return;
     bb.Write( buf, dataLen );
 }