Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenEXR/ImfStdIO.[cpp h]: Added StdISStream. #638

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions OpenEXR/IlmImf/ImfStdIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,61 @@ StdIFStream::clear ()
_is->clear();
}


StdISStream::StdISStream (): OPENEXR_IMF_INTERNAL_NAMESPACE::IStream ("(string)")
{
// empty
}

bool
StdISStream::read (char c[/*n*/], int n)
{
if (!_is)
throw IEX_NAMESPACE::InputExc ("Unexpected end of file.");

clearError();
_is.read (c, n);
return checkError (_is, n);
}


Int64
StdISStream::tellg ()
{
return std::streamoff (_is.tellg());
}


void
StdISStream::seekg (Int64 pos)
{
_is.seekg (pos);
checkError (_is);
}


void
StdISStream::clear ()
{
_is.clear();
}


std::string
StdISStream::str () const
{
return _is.str ();
}


void
StdISStream::str (const std::string &s)
{
_is.str(s);
}



StdOFStream::StdOFStream (const char fileName[])
: OPENEXR_IMF_INTERNAL_NAMESPACE::OStream (fileName)
, _os (make_ofstream (fileName))
Expand Down
34 changes: 34 additions & 0 deletions OpenEXR/IlmImf/ImfStdIO.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,40 @@ class StdIFStream: public OPENEXR_IMF_INTERNAL_NAMESPACE::IStream
};


//------------------------------------------------
// class StdISStream -- an implementation of class
// OPENEXR_IMF_INTERNAL_NAMESPACE::IStream, based on class std::istringstream
//------------------------------------------------

class StdISStream: public OPENEXR_IMF_INTERNAL_NAMESPACE::IStream
{
public:

IMF_EXPORT
StdISStream ();

IMF_EXPORT
virtual bool read (char c[/*n*/], int n);
IMF_EXPORT
virtual Int64 tellg ();
IMF_EXPORT
virtual void seekg (Int64 pos);
IMF_EXPORT
virtual void clear ();

IMF_EXPORT
std::string str () const;

IMF_EXPORT
void str (const std::string &s);

private:

std::istringstream _is;
};



//-------------------------------------------
// class StdOFStream -- an implementation of
// class OPENEXR_IMF_INTERNAL_NAMESPACE::OStream based on class std::ofstream
Expand Down