Blame IlmImf/ImfStdIO.h

Packit 0d464f
///////////////////////////////////////////////////////////////////////////
Packit 0d464f
//
Packit 0d464f
// Copyright (c) 2004, Industrial Light & Magic, a division of Lucas
Packit 0d464f
// Digital Ltd. LLC
Packit 0d464f
// 
Packit 0d464f
// All rights reserved.
Packit 0d464f
// 
Packit 0d464f
// Redistribution and use in source and binary forms, with or without
Packit 0d464f
// modification, are permitted provided that the following conditions are
Packit 0d464f
// met:
Packit 0d464f
// *       Redistributions of source code must retain the above copyright
Packit 0d464f
// notice, this list of conditions and the following disclaimer.
Packit 0d464f
// *       Redistributions in binary form must reproduce the above
Packit 0d464f
// copyright notice, this list of conditions and the following disclaimer
Packit 0d464f
// in the documentation and/or other materials provided with the
Packit 0d464f
// distribution.
Packit 0d464f
// *       Neither the name of Industrial Light & Magic nor the names of
Packit 0d464f
// its contributors may be used to endorse or promote products derived
Packit 0d464f
// from this software without specific prior written permission. 
Packit 0d464f
// 
Packit 0d464f
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
Packit 0d464f
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
Packit 0d464f
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
Packit 0d464f
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
Packit 0d464f
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
Packit 0d464f
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
Packit 0d464f
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
Packit 0d464f
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
Packit 0d464f
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
Packit 0d464f
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Packit 0d464f
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Packit 0d464f
//
Packit 0d464f
///////////////////////////////////////////////////////////////////////////
Packit 0d464f
Packit 0d464f
Packit 0d464f
#ifndef INCLUDED_IMF_STD_IO_H
Packit 0d464f
#define INCLUDED_IMF_STD_IO_H
Packit 0d464f
Packit 0d464f
//-----------------------------------------------------------------------------
Packit 0d464f
//
Packit 0d464f
//	Low-level file input and output for OpenEXR
Packit 0d464f
//	based on C++ standard iostreams.
Packit 0d464f
//
Packit 0d464f
//-----------------------------------------------------------------------------
Packit 0d464f
Packit 0d464f
#include "ImfIO.h"
Packit 0d464f
#include "ImfNamespace.h"
Packit 0d464f
#include "ImfExport.h"
Packit 0d464f
Packit 0d464f
#include <fstream>
Packit 0d464f
#include <sstream>
Packit 0d464f
Packit 0d464f
Packit 0d464f
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
Packit 0d464f
Packit 0d464f
//-------------------------------------------
Packit 0d464f
// class StdIFStream -- an implementation of
Packit 0d464f
// class OPENEXR_IMF_INTERNAL_NAMESPACE::IStream based on class std::ifstream
Packit 0d464f
//-------------------------------------------
Packit 0d464f
Packit 0d464f
class IMF_EXPORT StdIFStream: public OPENEXR_IMF_INTERNAL_NAMESPACE::IStream
Packit 0d464f
{
Packit 0d464f
  public:
Packit 0d464f
Packit 0d464f
    //-------------------------------------------------------
Packit 0d464f
    // A constructor that opens the file with the given name.
Packit 0d464f
    // The destructor will close the file.
Packit 0d464f
    //-------------------------------------------------------
Packit 0d464f
Packit 0d464f
    StdIFStream (const char fileName[]);
Packit 0d464f
Packit 0d464f
    
Packit 0d464f
    //---------------------------------------------------------
Packit 0d464f
    // A constructor that uses a std::ifstream that has already
Packit 0d464f
    // been opened by the caller.  The StdIFStream's destructor
Packit 0d464f
    // will not close the std::ifstream.
Packit 0d464f
    //---------------------------------------------------------
Packit 0d464f
Packit 0d464f
    StdIFStream (std::ifstream &is, const char fileName[]);
Packit 0d464f
Packit 0d464f
Packit 0d464f
    virtual ~StdIFStream ();
Packit 0d464f
Packit 0d464f
    virtual bool	read (char c[/*n*/], int n);
Packit 0d464f
    virtual Int64	tellg ();
Packit 0d464f
    virtual void	seekg (Int64 pos);
Packit 0d464f
    virtual void	clear ();
Packit 0d464f
Packit 0d464f
  private:
Packit 0d464f
Packit 0d464f
    std::ifstream *	_is;
Packit 0d464f
    bool		_deleteStream;
Packit 0d464f
};
Packit 0d464f
Packit 0d464f
Packit 0d464f
//-------------------------------------------
Packit 0d464f
// class StdOFStream -- an implementation of
Packit 0d464f
// class OPENEXR_IMF_INTERNAL_NAMESPACE::OStream based on class std::ofstream
Packit 0d464f
//-------------------------------------------
Packit 0d464f
Packit 0d464f
class IMF_EXPORT StdOFStream: public OPENEXR_IMF_INTERNAL_NAMESPACE::OStream
Packit 0d464f
{
Packit 0d464f
  public:
Packit 0d464f
Packit 0d464f
    //-------------------------------------------------------
Packit 0d464f
    // A constructor that opens the file with the given name.
Packit 0d464f
    // The destructor will close the file.
Packit 0d464f
    //-------------------------------------------------------
Packit 0d464f
Packit 0d464f
    StdOFStream (const char fileName[]);
Packit 0d464f
    
Packit 0d464f
Packit 0d464f
    //---------------------------------------------------------
Packit 0d464f
    // A constructor that uses a std::ofstream that has already
Packit 0d464f
    // been opened by the caller.  The StdOFStream's destructor
Packit 0d464f
    // will not close the std::ofstream.
Packit 0d464f
    //---------------------------------------------------------
Packit 0d464f
Packit 0d464f
    StdOFStream (std::ofstream &os, const char fileName[]);
Packit 0d464f
Packit 0d464f
Packit 0d464f
    virtual ~StdOFStream ();
Packit 0d464f
Packit 0d464f
    virtual void	write (const char c[/*n*/], int n);
Packit 0d464f
    virtual Int64	tellp ();
Packit 0d464f
    virtual void	seekp (Int64 pos);
Packit 0d464f
Packit 0d464f
  private:
Packit 0d464f
Packit 0d464f
    std::ofstream *	_os;
Packit 0d464f
    bool		_deleteStream;
Packit 0d464f
};
Packit 0d464f
Packit 0d464f
Packit 0d464f
//------------------------------------------------
Packit 0d464f
// class StdOSStream -- an implementation of class
Packit 0d464f
// OPENEXR_IMF_INTERNAL_NAMESPACE::OStream, based on class std::ostringstream
Packit 0d464f
//------------------------------------------------
Packit 0d464f
Packit 0d464f
class IMF_EXPORT StdOSStream: public OPENEXR_IMF_INTERNAL_NAMESPACE::OStream
Packit 0d464f
{
Packit 0d464f
  public:
Packit 0d464f
Packit 0d464f
    StdOSStream ();
Packit 0d464f
Packit 0d464f
    virtual void	write (const char c[/*n*/], int n);
Packit 0d464f
    virtual Int64	tellp ();
Packit 0d464f
    virtual void	seekp (Int64 pos);
Packit 0d464f
Packit 0d464f
    std::string		str () const {return _os.str();}
Packit 0d464f
Packit 0d464f
  private:
Packit 0d464f
Packit 0d464f
    std::ostringstream 	_os;
Packit 0d464f
};
Packit 0d464f
Packit 0d464f
Packit 0d464f
OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
Packit 0d464f
Packit 0d464f
#endif