Ticket #4695: iprimitive_position.diff

File iprimitive_position.diff, 2.2 KB (added by astukalov@…, 12 years ago)

add position() to packed_iprimitive and binary_buffer_iprimitive

  • boost/mpi/detail/packed_iprimitive.hpp

    old new  
    3434    packed_iprimitive(buffer_type & b, MPI_Comm const & comm, int position = 0)
    3535         : buffer_(b),
    3636           comm(comm),
    37            position(position)
     37           position_(position)
    3838        {
    3939        }
    4040
     
    5353      return size_ = buffer_.size();
    5454    }
    5555
     56    int position() const
     57    {
     58      return position_;
     59    }
     60
    5661    void resize(std::size_t s)
    5762    {
    5863      buffer_.resize(s);
     
    105110    void load_impl(void * p, MPI_Datatype t, int l)
    106111    {
    107112        BOOST_MPI_CHECK_RESULT(MPI_Unpack,
    108         (const_cast<char*>(boost::serialization::detail::get_data(buffer_)), buffer_.size(), &position, p, l, t, comm));
     113        (const_cast<char*>(boost::serialization::detail::get_data(buffer_)), buffer_.size(), &position_, p, l, t, comm));
    109114    }
    110115
    111116        buffer_type & buffer_;
    112117        mutable std::size_t size_;
    113118        MPI_Comm comm;
    114         int position;
     119        int position_;
    115120};
    116121
    117122} } // end namespace boost::mpi
  • boost/mpi/detail/binary_buffer_iprimitive.hpp

    old new  
    3434
    3535    binary_buffer_iprimitive(buffer_type & b, MPI_Comm const &, int position = 0)
    3636     : buffer_(b),
    37        position(position)
     37       position_(position)
    3838    {
    3939    }
    4040
     
    5353      return size_ = buffer_.size();
    5454    }
    5555
     56    int position() const
     57    {
     58      return position_;
     59    }
     60
    5661    void resize(std::size_t s)
    5762    {
    5863      buffer_.resize(s);
     
    106111
    107112    void load_impl(void * p, int l)
    108113    {
    109       assert(position+l<=static_cast<int>(buffer_.size()));
    110       std::memcpy(p,&buffer_[position],l);
    111       position += l;
     114      assert(position_+l<=static_cast<int>(buffer_.size()));
     115      std::memcpy(p,&buffer_[position_],l);
     116      position_ += l;
    112117    }
    113118
    114119    buffer_type & buffer_;
    115120    mutable std::size_t size_;
    116     int position;
     121    int position_;
    117122};
    118123
    119124} } // end namespace boost::mpi