Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: sf::Packet seek method  (Read 2712 times)

0 Members and 1 Guest are viewing this topic.

wallacoloo

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
sf::Packet seek method
« on: July 25, 2012, 11:06:44 pm »
I recently found myself needing a seek method on sf::Packet in order to read some data from an arbitrary byte offset into the packet. I could have read the entire packet into an array and then parsed it myself using the network-to-host set of functions in C while keeping track of the index I'm at, etc. But that's reimplementing a lot of functionality already provided by the packet class. So I looked into the implementation and found that a Packet just uses a std::vector to store all the data and size_t to keep track of the index. A seek method can literally be implemented in two lines of code by just setting m_readPos and m_isValid.

Would a seek method expose too much of the implementation or does this seem like a reasonable feature to implement?
« Last Edit: July 26, 2012, 05:39:53 pm by Laurent »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: sf::Packet seek method
« Reply #1 on: July 26, 2012, 06:02:48 pm »
There's already some stuff about packets on the issue tracker, have you searched there first?
« Last Edit: July 28, 2012, 09:29:26 am by Laurent »
Laurent Gomila - SFML developer

wallacoloo

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
Re: sf::Packet seek method
« Reply #2 on: July 26, 2012, 08:30:16 pm »
Ah. I had searched the forums and turned up nothing, but there is an issue (that you yourself opened) that proposes this exact functionality. My bad - I'll check the tracker as well next time.

 

anything