1234567891011121314151617181920212223242526272829303132333435363738 |
- #include "zerocopy_output_writer.h"
- namespace NSkiff {
- ////////////////////////////////////////////////////////////////////////////////
- TZeroCopyOutputStreamWriter::TZeroCopyOutputStreamWriter(IZeroCopyOutput* output)
- : Output_(output)
- {
- ObtainNextBlock();
- }
- TZeroCopyOutputStreamWriter::~TZeroCopyOutputStreamWriter()
- {
- if (RemainingBytes_ > 0) {
- UndoRemaining();
- }
- }
- void TZeroCopyOutputStreamWriter::ObtainNextBlock()
- {
- if (RemainingBytes_ > 0) {
- UndoRemaining();
- }
- RemainingBytes_ = Output_->Next(&Current_);
- TotalWrittenBlockSize_ += RemainingBytes_;
- }
- void TZeroCopyOutputStreamWriter::UndoRemaining()
- {
- Output_->Undo(RemainingBytes_);
- TotalWrittenBlockSize_ -= RemainingBytes_;
- RemainingBytes_ = 0;
- }
- ////////////////////////////////////////////////////////////////////////////////
- } // namespace NSkiff
|