Skip to content

Commit

Permalink
OpenEXR/ImfStdIO.[cpp h]: Added StdISStream.
Browse files Browse the repository at this point in the history
This class was missing; ie the "input" stringstream version of StdOSStream.
Based off istringstream.

Signed-off-by: Arkell Rasiah <[email protected]>
  • Loading branch information
arkellr authored and cary-ilm committed Feb 27, 2020
1 parent d9019d8 commit 9a172a2
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 0 deletions.
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

0 comments on commit 9a172a2

Please sign in to comment.