Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance and stabilize binary_data interface #3

Open
sque opened this issue Aug 19, 2013 · 1 comment
Open

Enhance and stabilize binary_data interface #3

sque opened this issue Aug 19, 2013 · 1 comment

Comments

@sque
Copy link
Owner

sque commented Aug 19, 2013

binary_data is the heart of liboonet, so we must take more care, although it is the best code inside liboonet. Some things must be revised and the interface must be stabilized.

  • scale_mem() It works... but we haven't investigate if it could do it better
  • operator[] It works... but it does a VERY expensive test for buffer over/under flow. We must follow std::vector specification operator[] does not do range check, at() does range check.
  • Implement binary_data to follow "ForwardContainer" concept. (Compatibility with stdlib)
  • Drop various constructors and leave only one from cmem_ref.
  • Cast to string() It is helpfull but there aren't only std::string in this world, so we must either provide ALL or nothing. [^1]
  • Investigate if we are taking full advantage of CoW.
  • Use the new mem_ref interface for reacting with external memory objects
  • Investigate if we can implement Concat On Read

[1] Still under discussion

@sque
Copy link
Owner Author

sque commented Aug 19, 2013

Proposed Stable Interface 1

binary_data

  binary_data(const binary_data &);
  binary_data & operator=(const binary_data &);

  binary_data operator+(const_mem_block &);
  binary_data operator+=(const_mem_block &);

  size_t find(const_mem_block &);
  binary_data sub_data(size_t start_offset, size_t desired_size);
  binary_data until(size_t desired_size);
  binary_data from(size_t offset);

  pointer c_array();
  const pointer c_array() const;
  size_t size();

  // Constants
  size_t npos;
  binary_data nothing;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant