2017-02-02 17:24:40 +01:00
|
|
|
//
|
|
|
|
// libtgvoip is free and unencumbered public domain software.
|
|
|
|
// For more information, see http://unlicense.org or the UNLICENSE file
|
|
|
|
// you should have received with this source code distribution.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef LIBTGVOIP_BUFFEROUTPUTSTREAM_H
|
|
|
|
#define LIBTGVOIP_BUFFEROUTPUTSTREAM_H
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
2017-04-17 20:57:07 +02:00
|
|
|
#include <stdint.h>
|
2017-02-02 17:24:40 +01:00
|
|
|
|
2017-04-28 13:17:56 +02:00
|
|
|
namespace tgvoip{
|
|
|
|
class BufferOutputStream{
|
2017-02-02 17:24:40 +01:00
|
|
|
|
|
|
|
public:
|
2017-04-28 13:17:56 +02:00
|
|
|
BufferOutputStream(size_t size);
|
2017-07-03 03:42:49 +02:00
|
|
|
BufferOutputStream(unsigned char* buffer, size_t size);
|
2017-04-28 13:17:56 +02:00
|
|
|
~BufferOutputStream();
|
2017-02-02 17:24:40 +01:00
|
|
|
void WriteByte(unsigned char byte);
|
|
|
|
void WriteInt64(int64_t i);
|
|
|
|
void WriteInt32(int32_t i);
|
|
|
|
void WriteInt16(int16_t i);
|
2017-03-30 16:06:59 +02:00
|
|
|
void WriteBytes(unsigned char* bytes, size_t count);
|
|
|
|
unsigned char* GetBuffer();
|
2017-02-02 17:24:40 +01:00
|
|
|
size_t GetLength();
|
|
|
|
void Reset();
|
|
|
|
|
|
|
|
private:
|
|
|
|
void ExpandBufferIfNeeded(size_t need);
|
2017-03-30 16:06:59 +02:00
|
|
|
unsigned char* buffer;
|
2017-02-02 17:24:40 +01:00
|
|
|
size_t size;
|
|
|
|
size_t offset;
|
2017-07-03 03:42:49 +02:00
|
|
|
bool bufferProvided;
|
2017-02-02 17:24:40 +01:00
|
|
|
};
|
2017-04-28 13:17:56 +02:00
|
|
|
}
|
2017-02-02 17:24:40 +01:00
|
|
|
|
|
|
|
#endif //LIBTGVOIP_BUFFEROUTPUTSTREAM_H
|