Alien-FreeImage

 view release on metacpan or  search on metacpan

src/Source/LibRawLite/libraw/libraw_datastream.h  view on Meta::CPAN

};


class DllDef  LibRaw_buffer_datastream : public LibRaw_abstract_datastream
{
  public:
                        LibRaw_buffer_datastream(void *buffer, size_t bsize);
    virtual             ~LibRaw_buffer_datastream();
    virtual int         valid();
    virtual void        *make_jas_stream();
    virtual int         jpeg_src(void *jpegdata);
    virtual int         read(void * ptr,size_t sz, size_t nmemb);
    virtual int         eof();
    virtual int         seek(INT64 o, int whence);
    virtual INT64       tell();
    virtual INT64	size() { return streamsize;}
    virtual char*       gets(char *s, int sz);
    virtual int         scanf_one(const char *fmt, void* val);
    virtual int         get_char()
    { 
        if(substream) return substream->get_char();
        if(streampos>=streamsize)
            return -1;
        return buf[streampos++];
    }

  private:
    unsigned char *buf;
    size_t   streampos,streamsize;
};

class DllDef LibRaw_bigfile_datastream : public LibRaw_abstract_datastream
{
  public:
                        LibRaw_bigfile_datastream(const char *fname);
#if defined(_WIN32) && !defined(__MINGW32__) && defined(_MSC_VER) && (_MSC_VER > 1310)
			LibRaw_bigfile_datastream(const wchar_t *fname);
#endif
    virtual             ~LibRaw_bigfile_datastream();
    virtual int         valid();
    virtual int         jpeg_src(void *jpegdata);
    virtual void        *make_jas_stream();

    virtual int         read(void * ptr,size_t size, size_t nmemb); 
    virtual int         eof();
    virtual int         seek(INT64 o, int whence);
    virtual INT64       tell();
    virtual INT64	size() { return _fsize;}
    virtual char*       gets(char *str, int sz);
    virtual int         scanf_one(const char *fmt, void*val);
    virtual const char *fname();
#if defined(_WIN32) && !defined(__MINGW32__) && defined(_MSC_VER) && (_MSC_VER > 1310)
    virtual const wchar_t* wfname();
    virtual int         subfile_open(const wchar_t *fn);
#endif
    virtual int         subfile_open(const char *fn);
    virtual void        subfile_close();
    virtual int         get_char()
    { 
#ifndef WIN32
        return substream?substream->get_char():getc_unlocked(f);
#else
        return substream?substream->get_char():fgetc(f);
#endif
    }

protected:
    FILE *f,*sav;
    std::string filename;
    INT64 _fsize;
#ifdef WIN32
    std::wstring wfilename;
#endif
};

#ifdef WIN32
class DllDef  LibRaw_windows_datastream : public LibRaw_buffer_datastream 
{
public:
    /* ctor: high level constructor opens a file by name */
    LibRaw_windows_datastream(const TCHAR* sFile);
    /* ctor: construct with a file handle - caller is responsible for closing the file handle */
    LibRaw_windows_datastream(HANDLE hFile);
    /* dtor: unmap and close the mapping handle */
    virtual ~LibRaw_windows_datastream();
    virtual INT64 size() { return cbView_;}

protected:
    void Open(HANDLE hFile);
    inline void reconstruct_base()
	{
            /* this subterfuge is to overcome the private-ness of LibRaw_buffer_datastream */
            (LibRaw_buffer_datastream&)*this = LibRaw_buffer_datastream(pView_, (size_t)cbView_);
	}

    HANDLE		hMap_;			/* handle of the file mapping */
    void*		pView_;			/* pointer to the mapped memory */
    __int64	cbView_;		/* size of the mapping in bytes */
};

#endif


#endif /* cplusplus */

#endif



( run in 1.220 second using v1.01-cache-2.11-cpan-d7f47b0818f )