42namespace ALEMBIC_VERSION_NS {
44class OStream::PrivateData
47 PrivateData(
const std::string &
iFileName) :
50 std::ofstream *
filestream =
new std::ofstream(fileName.c_str(),
51 std::ios_base::trunc | std::ios_base::binary);
55 stream->exceptions ( std::ofstream::failbit |
56 std::ofstream::badbit );
69 stream->exceptions ( std::ostream::failbit |
70 std::ostream::badbit );
72 startPos = stream->tellp();
75 throw std::runtime_error(
"Illegal start of Ogawa stream");
83 if (!fileName.empty() && stream)
85 std::ofstream *
filestream =
dynamic_cast<std::ofstream *
>(stream);
94 std::ostream * stream;
96 Alembic::Util::uint64_t startPos;
97 Alembic::Util::mutex lock;
100OStream::OStream(
const std::string &
iFileName) :
118 mData->stream->seekp(
mData->startPos + 5).write(&frozen, 1).flush();
122bool OStream::isValid()
139 throw std::runtime_error(
140 "Ogawa currently only supports little-endian writing.");
146 'O',
'g',
'a',
'w',
'a',
149 0, 0, 0, 0, 0, 0, 0, 0};
154Alembic::Util::uint64_t OStream::getAndSeekEndPos()
158 Alembic::Util::scoped_lock
l(
mData->lock);
159 Alembic::Util::uint64_t
lastp =
160 mData->stream->seekp(0, std::ios_base::end).tellp();
163 throw std::runtime_error(
164 "Illegal position returned Ogawa::OStream::getAndSeekEndPos");
173void OStream::seek(Alembic::Util::uint64_t
iPos)
177 Alembic::Util::scoped_lock
l(
mData->lock);
182void OStream::write(
const void *
iBuf, Alembic::Util::uint64_t
iSize)
186 Alembic::Util::scoped_lock
l(
mData->lock);