/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
sal_Int32 SAL_CALL MemoryInputStream::readSomeBytes( Sequence<sal_Int8>& aData, sal_Int32 nMaxBytesToRead )
{ // all data is available at once return readBytes(aData, nMaxBytesToRead);
}
// ensure the sequence has enough space left if (m_nSize + _rData.getLength() > m_rSequence.getLength())
{
sal_Int32 nCurrentLength = m_rSequence.getLength();
sal_Int32 nNewLength = static_cast< sal_Int32 >(
nCurrentLength * m_nResizeFactor);
if (m_nMinimumResize > nNewLength - nCurrentLength) // we have a minimum so it's not too inefficient for small sequences and small write requests
nNewLength = nCurrentLength + m_nMinimumResize;
if (nNewLength < m_nSize + _rData.getLength())
{ // it's not enough... the data would not fit
// let's take the double amount of the length of the data to be written, as the next write // request could be as large as this one
sal_Int32 nNewGrowth = _rData.getLength() * 2;
nNewLength = nCurrentLength + nNewGrowth;
}
// round it off to the next multiple of 4...
nNewLength = (nNewLength + 3) / 4 * 4;
m_rSequence.realloc(nNewLength);
}
OSL_ENSURE(m_rSequence.getLength() >= m_nSize + _rData.getLength(), "ooops ... the realloc algorithm seems to be wrong :( !");
// cut the sequence to the real size
m_rSequence.realloc(m_nSize);
}
void OSequenceOutputStream::finalizeOutput()
{ // cut the sequence to the real size
m_rSequence.realloc(m_nSize); // and don't allow any further accesses
m_bConnected = false;
}
void SAL_CALL OSequenceOutputStream::closeOutput()
{
std::scoped_lock aGuard(m_aMutex); if (!m_bConnected) throw NotConnectedException();
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.