Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3221580
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:53:33+00:00 2026-05-17T15:53:33+00:00

I work on an open source portable C++ image compression library . Currently, my

  • 0

I work on an open source portable C++ image compression library. Currently, my API works by exchanging pointers to byte arrays with image data. I would like to support some kind of streaming mode for better performance and memory consumption.

For this, I would like to know if there is an interface or abstract base class (part of the C++ standard libraries) that I can use as an interface to a stream of input bytes, similar to Java’s InputStream, or C# Stream. It could be as simple as this:

 class inputstream 
 {
      public:
      virtual void readbytes(char*, size_t count) = 0;
 };

I could define an interface like this myself, but then I require everybody to implement some kind of adapter to interface to my code, and my flavor of IO error handling, and I would like to avoid that.

Ideally this interface or base class would be already implemented by some existing C++ standard libraries for reading files. If it is not a base class, it should be totally abstract so my users can connect to whatever bytestream they have (platform specific, socket, whatever). I have browsed around in iostream but found nothing that fits the bill. It should be as light weight as possible: Error handling should be defined, but there’s no need for seeking the stream.

If there is no such thing (which I fear), is there something like an existing best practice? Like a function pointer with a standard signature, and a contract for error handling? If there are creative solutions that would work in C as well, I am also interested.

Edit: the key thing is that base class’s read() method(s) are virtual.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T15:53:34+00:00Added an answer on May 17, 2026 at 3:53 pm

    If your library accepts a std::istream then it will work with files, memory buffers, and user-defined streams.

    Your source of confusion seems to be that istream doesn’t have any virtual members to override and customize. This is because istream delegates all customizable functionality to std::streambuf, which is where you’ll find the virtual members.

    If you wanted to expose the compression results as a stream, you’d want to derive from streambuf. Conversely, you could accept an istream to read from and an ostream to store compressed results into.

    By accepting an istream, your client can supply an istream constructed on any streambuf, either the library provided stringbuf or filebuf or a custom version.

    Since you don’t want to work with textual data but byte streams, perhaps using the streambuf directly would be better than using istream to wrap it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any open source gis library for mobile devices to work on J2ME?
I work on a project that uses multiple open source Java libraries. When upgrades
I use Perforce for source control at work and I want to 'open for
Intel's Threading Building Blocks (TBB) open source library looks really interesting. Even though there's
I have an open-source application on the Android market. It seems to work fine
Are there any native XML Databases (That are free and preferably open-source) that work
I am currently looking at building an Open Source People Intelligence Application (Fancy Word
Will a query like this on a recordset work rs.open select * from table
In the code below, why does the open function work but the close function
Here's an open ended question. I work on a lot of mssql files, and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.