Thread: problem with streambuf

  1. #16
    Registered User
    Join Date
    Nov 2007
    Posts
    99
    hello MacGyver ,

    i think u r the only person who always reply in negetive way,
    let others to reply.

  2. #17
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    Others have replied and you have ignored them. If you cannot understand something in a positive light, then perhaps a negative one is needed. And for that matter, I'll reply wherever I wish to, without your permission or blessing.

    As to the issue which you are being completely dense about, let me try yet again to make it perfectly clear: There is no platform independant way to do what you are doing outside of writing it multiple ways and incorporating it into a library of your own. In and of itself, you can't do this task with file descriptors and streams for all operating systems. File descriptors are a Unix-based concept. Windows has the same idea conceptually, but they use a generic void * which they typedef as a HANDLE.

    There is a reason why you are supposed to use FILE objects in C and file streams in C++. This is to make this entire thing abstract so that you can write your code portably no matter what operating system you're compiling against. Once you wish to go beyond that and delve into OS specific functionality, you have to create a library that supports every target platform you wish to cover. This is your only solution for this problem.

    I hope this finally gets the point across to you.

  3. #18
    Registered User
    Join Date
    Jul 2003
    Posts
    110
    Quote Originally Posted by MacGyver View Post
    There is a reason why you are supposed to use FILE objects in C and file streams in C++. This is to make this entire thing abstract so that you can write your code portably no matter what operating system you're compiling against.
    Quite right. Except that there isn't always an abstraction for everything you want to do. In this case, the OP seemed to have a problem where he needed to fit the file descriptor portion of a project that had already been done into another module that expects a streambuf object. What better glue than a derived class that implements the platform specific mechanism and provides the abstract interface for working in portable code? (modulo some error recovery for the sake of demonstration).

    I have been known to trumpet the portable mantra myself, and probably too much, but this is an example of how the streams abstraction can be used to solve problems when the parts just don't fit quite right.

    Know whud I mean?

  4. #19
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    I agree with you, however, his very requirements are not portable in nature, and thus require a library of sorts (ie. to be done in each specific manner). This is what I was trying to point out to him.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 11:22 AM
  2. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 08:38 AM
  3. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  4. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM
  5. beginner problem
    By The_Nymph in forum C Programming
    Replies: 4
    Last Post: 03-05-2002, 05:46 PM