3rdparty/licenseReport: Add seperate LGPL checks
[haiku.git] / src / add-ons / media / plugins / matroska / libebml / ebml / MemIOCallback.h
blobabe1a92110d65a58d15c55c6d427060e0375f238
1 /****************************************************************************
2 ** libebml : parse EBML files, see http://embl.sourceforge.net/
3 **
4 ** <file/class description>
5 **
6 ** Copyright (C) 2003-2004 Jory Stone. All rights reserved.
7 **
8 ** This library is free software; you can redistribute it and/or
9 ** modify it under the terms of the GNU Lesser General Public
10 ** License as published by the Free Software Foundation; either
11 ** version 2.1 of the License, or (at your option) any later version.
12 **
13 ** This library is distributed in the hope that it will be useful,
14 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 ** Lesser General Public License for more details.
17 **
18 ** You should have received a copy of the GNU Lesser General Public
19 ** License along with this library; if not, write to the Free Software
20 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 ** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.
24 ** Contact license@matroska.org if any conditions of this licensing are
25 ** not clear to you.
27 **********************************************************************/
29 /*!
30 \file
31 \version \$Id: MemIOCallback.h 1298 2008-02-21 22:14:18Z mosu $
32 \author Jory Stone <jcsston @ toughguy.net>
34 #ifndef LIBEBML_MEMIOCALLBACK_H
35 #define LIBEBML_MEMIOCALLBACK_H
37 #include "IOCallback.h"
38 #include <string>
39 #if (!defined(__BEOS__) && !defined(__HAIKU__))
40 #include <sstream>
41 #else
42 #include <strstream>
43 #define stringstream strstream
44 #endif
46 START_LIBEBML_NAMESPACE
48 class EBML_DLL_API MemIOCallback : public IOCallback
50 public:
51 MemIOCallback(uint64 DefaultSize = 128);
52 ~MemIOCallback();
54 /*!
55 Use this to copy some data to the Buffer from this classes data
57 uint32 read(void *Buffer, size_t Size);
59 /*!
60 Seek to the specified position. The mode can have either SEEK_SET, SEEK_CUR
61 or SEEK_END. The callback should return true(1) if the seek operation succeeded
62 or false (0), when the seek fails.
64 void setFilePointer(int64 Offset, seek_mode Mode=seek_beginning);
66 /*!
67 This callback just works like its read pendant. It returns the number of bytes written.
69 size_t write(const void *Buffer, size_t Size);
71 /*!
72 Although the position is always positive, the return value of this callback is signed to
73 easily allow negative values for returning errors. When an error occurs, the implementor
74 should return -1 and the file pointer otherwise.
76 If an error occurs, an exception should be thrown.
78 virtual uint64 getFilePointer() {return dataBufferPos;};
80 /*!
81 The close callback flushes the file buffers to disk and closes the file. When using the stdio
82 library, this is equivalent to calling fclose. When the close is not successful, an exception
83 should be thrown.
85 void close() {};
87 binary *GetDataBuffer() const {return dataBuffer;};
88 uint64 GetDataBufferSize() {return dataBufferTotalSize;};
89 void SetDataBufferSize(uint64 newDataBufferSize) {dataBufferTotalSize = newDataBufferSize;};
90 /*!
91 Use this to write some data from another IOCallback
93 uint32 write(IOCallback & IOToRead, size_t Size);
95 bool IsOk() { return mOk; };
96 const std::string &GetLastErrorStr() { return mLastErrorStr; };
97 protected:
98 bool mOk;
99 std::string mLastErrorStr;
101 binary *dataBuffer;
103 Postion where we start 'writing' to the dataBuffer
105 uint64 dataBufferPos;
107 Size of the data in the dataBuffer
109 uint64 dataBufferTotalSize;
111 Size of the memory malloc()/realloc()
113 uint64 dataBufferMemorySize;
116 END_LIBEBML_NAMESPACE
118 #endif // LIBEBML_MEMIOCALLBACK_H