Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

dsMmapStream.h

Go to the documentation of this file.
00001 /*
00002  * $Id: dsMmapStream.h,v 1.1 2003/09/11 08:46:41 dsamersoff Exp $
00003  */
00004 #ifndef dsMmapStream_h
00005 #define dsMmapStream_h
00006 
00007 #include <iostream>
00008 #include <stdlib.h>
00009 #include <string.h>
00010 #include <limits.h>
00011 
00012 #include <dsMmap.h>
00013 
00019 typedef void *(*p_alloc)(size_t);
00020 typedef void (*p_free)(void *);
00021 
00022 class dsMmapStreambuf : public std::streambuf 
00023 {
00024     dsMmap *_map;
00025 
00026     std::streampos _seekoff_p(std::streamoff off, std::ios::seekdir dir);
00027     std::streampos _seekoff_g(std::streamoff off, std::ios::seekdir dir);
00028 
00029 public:
00030 
00031    dsMmapStreambuf(const int fd, const size_t size, std::ios::openmode mode);
00032    dsMmapStreambuf(const char *fname, std::ios::openmode mode);
00033 
00034     virtual ~dsMmapStreambuf();
00035 
00036     size_t pcount();
00037     char *str();
00038 
00039     int overflow(int ch);
00040     int underflow();
00041     int pbackfail(int c);
00042 
00043     std::streampos seekoff(std::streamoff off, std::ios::seekdir dir, std::ios::openmode mode);
00044     std::streampos seekpos(std::streamoff off, std::ios::openmode mode){ return seekoff(off, std::ios::beg, mode); }
00045 
00046     void clear();
00047 
00048 };
00049 
00050 class dsMmapStream :  public std::iostream
00051 {  
00052    dsMmapStreambuf* _sb;
00053    
00054   public:
00055    dsMmapStream(const int fd, const size_t size, std::ios::openmode mode=std::ios::in | std::ios::out);
00056    dsMmapStream(const char *fname, std::ios::openmode mode=std::ios::in | std::ios::out);
00057 
00058    virtual ~dsMmapStream();
00059 
00060    dsMmapStreambuf *rdbuf() const;
00061 
00062     size_t pcount(); 
00063     char *str(); 
00064          
00065     void clear();
00066 };  
00067 
00068 #endif

Generated on Mon May 16 18:26:58 2005 for libdms4 by doxygen1.3-rc2