Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Zortech C++ 3.0r4 - <b>a streambuf specialized for files - filebuf</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
A streambuf Specialized for Files - filebuf

   The filebuf class is a derivation of streambuf that uses a file as
   ultimate source and or destination. Characters are obtained (underflow)
   from the file by reading, and disposed of (overflow) by writing.

   The get and put pointers of a filebuf are notionally tied together. If
   the file involved supports seeking, the filebuf seekpos() and seekoff()
   functions support seek operations.

   Four characters of putback are supported. The extra public interface is
   as follows:

   class filebuf : public streambuf {
   public:
       enum { openprot = 0644 };

   // Constructors
       filebuf();

       filebuf(int file_descriptor);
       filebuf(int descriptor, char *memory, int length);
       ~filebuf();

   // Attach a file to an existing filebuf
       filebuf *attach(int file_descriptor);

   // Close the file associated with the filebuf
       filebuf *close();

   // Open a file and attach it to an existing filebuf
       filebuf *open(const char *name, int io_mode,
                      int protection = openprot);

   // Information functions
       int fd() const;
       int is_open() const;

   // Seek functions
       virtual streampos seekpos(streampos, int which_pointers);

       virtualstreampos seekoff(streamoff offset, relative_to,
                                 int which_pointers);

   // Offer a buffer area for use
       streambuf *setbuf(char *memory, int length);

   // Synchronize the file with the filebuf
       virtual int sync();
   };

   The following functions require the inclusion of file fstream.hpp.





Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson