Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef UT_BYTEBUF_H
00023 #define UT_BYTEBUF_H
00024
00025
00026
00027
00028
00029 #include <stdio.h>
00030 #include <memory>
00031 #include <gsf/gsf-input.h>
00032
00033
00034
00035
00036
00037 #ifndef UT_TYPES_H
00038 #include "ut_types.h"
00039 #endif
00040
00041
00042
00043
00044
00045
00046
00047
00048 #ifndef abi_std_truncate
00049 #define abi_std_truncate truncate
00050 #endif
00051 #ifdef truncate
00052 #undef truncate
00053 #endif
00054
00055 class ABI_EXPORT UT_ByteBuf
00056 {
00057 public:
00058 UT_ByteBuf(UT_uint32 iChunk = 0);
00059 ~UT_ByteBuf();
00060
00061 bool append(const UT_Byte * pValue, UT_uint32 length);
00062 bool ins(UT_uint32 position, const UT_Byte * pValue, UT_uint32 length);
00063 bool ins(UT_uint32 position, UT_uint32 length);
00064 bool del(UT_uint32 position, UT_uint32 amount);
00065 bool overwrite(UT_uint32 position, const UT_Byte * pValue, UT_uint32 length);
00066 void truncate(UT_uint32 position);
00067 UT_uint32 getLength(void) const;
00068 const UT_Byte * getPointer(UT_uint32 position) const;
00069 bool writeToFile(const char* pszFileName) const;
00070 bool writeToURI(const char* pszURI) const;
00071 bool insertFromFile(UT_uint32 iPosition, const char* pszFilename);
00072 bool insertFromURI(UT_uint32 iPosition, const char* pszURI);
00073 bool insertFromInput(UT_uint32 iPosition, GsfInput * fp);
00074 bool insertFromFile(UT_uint32 iPosition, FILE * fp);
00075 private:
00076 bool _byteBuf(UT_uint32 spaceNeeded);
00077
00078 UT_Byte * m_pBuf;
00079 UT_uint32 m_iSize;
00080 UT_uint32 m_iSpace;
00081 UT_uint32 m_iChunk;
00082 };
00083
00084 typedef std::shared_ptr<UT_ByteBuf> UT_ByteBufPtr;
00085 typedef std::shared_ptr<const UT_ByteBuf> UT_ConstByteBufPtr;
00086
00087 #endif