bump product version to 4.1.6.2
[LibreOffice.git] / hwpfilter / source / hstream.cxx
blob5cd93542e844f5fb8f2f34f8b712829c5979ddea
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <string.h>
21 #include <stdlib.h>
22 #include "hstream.h"
24 HStream::HStream() : size(0), pos(0)
26 seq = 0;
30 HStream::~HStream()
32 if( seq )
33 free( seq );
37 void HStream::addData( const byte *buf, int aToAdd)
39 seq = (byte *)realloc( seq, size + aToAdd );
40 memcpy( seq + size, buf, aToAdd );
41 size += aToAdd;
45 int HStream::readBytes(byte * buf, int aToRead)
47 if (aToRead >= (size - pos))
48 aToRead = size - pos;
49 for (int i = 0; i < aToRead; i++)
50 buf[i] = seq[pos++];
51 return aToRead;
55 int HStream::skipBytes(int aToSkip)
57 if (aToSkip >= (size - pos))
58 aToSkip = size - pos;
59 pos += aToSkip;
60 return aToSkip;
64 int HStream::available() const
66 return size - pos;
70 void HStream::closeInput()
74 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */